Navigation: Processing Concepts >

Colors

 

 

 

 

Colors are specified for many uses in MakerPlot-J, for both drawing instructions and as properties of interfaces and controls. For controls they can be set from the Interface Editor by either entering a color or using the ellipses (…) to select a color.

Color for drawing instructions, such as for the main interface, use instructions such as to draw a line:
 !drawLine x1, x1, x2, y2, color, size or thickness, rotation
 When testing code in the DEBUG/CLI or for a control in the Code Editor, start typing the instruction to see a list of choices. To select the first choice in the list type CTRL-SPACE. To get help, type F1 or right-click on the instruction in the list.
 

While not necessary in the code, opening a bracket ([) will show the list of drawing constants for colors.

 

Defining Colors

There are 4 ways to define the 24-bit color to be used with interfaces, controls and drawing:

Color Constant: As shown in the prior image, there are a list of defined color constants that may be used, with or without brackets.
 [RED]
 [BLACK]
 [YELLOW]

Decimal Value: A decimal value up to 224, 16777215, may be used. This is not a preferred choice as it’s difficult to define the amount of Red, Green and Blue to be used.
 !drawLine 0,0,100,100,1138984,10

Hex RGB: This is a hexadecimal value defining the amount of RED, GREEN and BLUE from 00 to FF in the format of $RRGGBB, such as $10FF80, meaning little red, full green and half blue.
 !drawLine 0,0,100,100,$10FF80,10

Decimal RGB: These use decimal values separated by a colon to define the RED, GREEN and BLUE amounts of color, with each being 0 to 255 in the format of:
RED:GREEN:BLUE, such as 16:255:128 for same color as the example Hex RGB color.

Note that value replacement can be done for color using real time data, such as incoming analog value in the range of 0-255:
 !drawLine 0,0,100,100,[ain0]:[ain1]:[ain2],10

ALPHA: Decimal RGB accepts a fourth parameter: alpha. This defines the opacity of the draw element from 0 to 255, allowing overlap to be seen. The lower the value, the more transparent it will be.
RED:GREEN:BLUE:ALPHA

!backColor=WHITE
 !drawCircle 40,50,50,16:255:128:128,50
 !drawCircle 60,50,50,16:255:128:128,50
 !drawText 50,50,MakerPlot-J,25,255:0:0:150,,C

Colors and alpha can be used on text and other control colors as well, in code or entered in the property box:
 !txt.backColor=0:0:255:50
 !txtGreeting.fontColor=0:0:255:128
 

The value, [dialogColor] may be used in code to request the palette and assign it to a control. Note that processing will stop until the operation is complete. The operation may be passed a color as the default value: [dialogColor defaultColor]
 (Ensure labels have transparency turned off)
 !lblTest.backColor=[dialogColor [lblTest.backColor]]



 

 

 

 

 

Copyright © 2024 SelmaWare Solutions, LLC