CabMasterPro User Guide
In This Topic
    Colours : Developer
    In This Topic

    You can specify colours in formulas in CabMasterPro. There are several ways.

    To access the standard Colour Picker dialog use the middleware call pickcolor("mycolorvariable").

    Example

    Here are some examples to try this:-

    The built-in constants return a Color type and the rgb(...) function returns an Int

    Pure red is rgb(255,0,0). Try calculating the formula above with r=255, g=0, b=0 and you will see it is just 255 + 0 + 0 = 255, as per the value of the variable myred.

    Similarly, myblue, which is rgb(0,0,255) can be calculated giving 256*256*255 which is 16711680.

    Notice that if we evaluate the formula blue it is recognised as the predefined variable for blue and gives the same value as rgb(0,0,255). Be careful not to use quotes in this formula. The formula "blue" is a string with the four letters b l u e. This is quite different to the predefined colour constant blue which is what you get with no quotes.


    To see exactly what the other predefined colour constants evaluate to, you can just type them in. For example CYAN (which is green plus blue) is given by  0 + 256 * (255 + 256 * 255) which is 16776960 as per the example.

    CYAN example

    Whenever CabMasterPro expects a colour for a formula, you can use a whole number variable or expression and follow these rules. This way, you can build your own rainbows if you like, or have quite complex colourings generated automatically.

    Example

    Here is a little brain teaser example for advanced users. It just illustrates how formulas can be built up to do things like colour coding sections.

    Load the drawing colour.qid into CabMasterPro. This is a fairly simple drawing, there is a single cabinet with 11 sections called box00, box01, box02, ...., box10.

    The cabinet has the property n, set to 10. There is a formula which picks up the last number from the section name (Using the built in variable #) and uses that to generate an RGB colour which has R varying from zero to 255 in 10 steps, while G varies from 255 back to zero in those ten steps. The blue component is added in from the friendly page question.

    Click to view Answers & Setup

    Click to view Answers & Setup