Colour class

The Colour class contains constants relating to colours. More...

The PRIMER JavaScript API provides many class constants, properties and methods. For Arup to be able to extend and enhance the API in the future any constant, property or method names beginning with a lowercase or uppercase letter are reserved.
If you need to add your own properties or methods to one of the existing classes then to avoid any potential future conflict you should ensure that the name begins with either an underscore (_) or a dollar sign ($) or the name is prefixed with your own unique identifier.
For example if company 'ABC' need to add a property called 'example' then to avoid any potential future conflict use one of:

Class functions

Colour constants

Name Description
Colour.ASSEMBLY Base colour on assembly
Colour.BACKGROUND Background colour
Colour.BLACK Colour black
Colour.BLUE Colour blue
Colour.CYAN Colour cyan
Colour.DARK_ORANGE Colour dark orange
Colour.DEFAULT Default colour for objects
Colour.GREEN Colour green
Colour.GREEN_CYAN Colour green/cyan
Colour.GREY Colour grey
Colour.INCLUDE Base colour on include file
Colour.LIGHT_BLUE Colour light blue
Colour.MAGENTA Colour magenta
Colour.MATERIAL For elements with part IDs base colour on material ID
Colour.MEDIUM_BLUE Colour medium blue
Colour.MODEL Base colour on model
Colour.NOT_BACKGROUND Not the background colour
Colour.ORANGE Colour orange
Colour.PART For elements with part IDs base colour on part ID
Colour.RED Colour red
Colour.RED_MAGENTA Colour red/magenta
Colour.SECTION For elements with part IDs base colour on section ID
Colour.SKETCH Sketch colour
Colour.TEXT Text colour
Colour.WHITE Colour white
Colour.YELLOW Colour yellow
Colour.YELLOW_GREEN Colour yellow/green

Detailed Description

The Colour class is used to define colours, either by predefined colours or by RGB values. The easiest way to set the colour of something is to use the predefined colour constants. e.g. to set the colour of part p to red:

p.colour = Colour.RED;

For other colours use Colour.RGB().

Details of functions

GetFromName(name[string]) [static]

Description

Returns the colour for a given core or user colour name

Arguments

  • name (string)

    The name of the colour, for example red or user_green or green/cyan.

    Returns

    colour value (integer)

    Return type

    Number


    RGB(red[integer], green[integer], blue[integer]) [static]

    Description

    Creates a colour from red, green and blue components

    Arguments

  • red (integer)

    red component of colour (0-255).

  • green (integer)

    green component of colour (0-255).

  • blue (integer)

    blue component of colour (0-255).

    Returns

    colour value (integer)

    Return type

    Number

    Example

    To set the colour of model m to red:

    m.SetColour( Colour.RGB(255, 0, 0) );

    To set the colour of part p to red:

    p.colour = Colour.RGB(255, 0, 0);