colourShapes

colourShapes( coloursCollection, shapeToColour1, shapeToColour2, … )

Attempts to set the colour all of the shapeToColour# arguments that are passed in (you may pass in as many as you want) without duplicating any of the other shapes’ colours that are on the screen – even if those other shapes are not currently visible (that is, their IsVisible property is False).

The new colours assigned to each shape are saved into the database and automatically associated with the current session, trial and phase (if applicable).

Note that just like the moveShape(…) function, using colourShapeN creates the dedicated “coloured” event in the Events table within the database.

Arguments

coloursCollection

- A collection of colours to be used when colouring the shapes.

shapeToColour#

- You may pass in any number of shapes that you want to be coloured.

Returns

The number of shapes that were coloured.

Example #1

The following example randomly assigns colours to the three visible shapes from the given collection of colours.

// Set-up the margins to be larger than our shapes just in case

// our shape is positioned really close to the edge

screen.MarginTop = 100

screen.MarginBottom = 100

screen.MarginLeft = 100

screen.MarginRight = 100


// Define a bunch of colours

define green = #55AA2B

define red = #FF0000

define blue = #0000FF

define fuchsia = #FF00FF

define orange = #FFA500

define maroon = #800000

define black = #000000


// For easier use, put all the colours in a collection

define collection ColoursCollectionType

       green

       red

       blue

       fuchsia

       orange

       maroon

       black

end collection

define colours = create ColoursCollectionType


// Define our type of circle

define type of circle MainShapeType

       radius = 50

       colour = #FF2255

       isVisible = true

end circle


// Create our three shapes

define shape1 = create MainShapeType

define shape2 = create MainShapeType

define shape3 = create MainShapeType


// Move the shapes around on the screen

moveShapeN( 200, shape1, shape2, shape3 )


// Now colour the shapes as well

colourShapes( colours, shape1, shape2, shape3 )


wait for 20sec


Produces screens similar to these:

 

Example #2

The following colours three circles around the central black fixation point.  Notice that because the fixation point is black, the other shapes will never be assigned black even though it is in the collection that we are passing to the colourShapesN() function.

// Set-up the margins to be larger than our shapes just in case

// our shape is positioned really close to the edge

screen.MarginTop = 100

screen.MarginBottom = 100

screen.MarginLeft = 100

screen.MarginRight = 100


// Define a bunch of colours

define green = #55AA2B

define red = #FF0000

define blue = #0000FF

define fuchsia = #FF00FF

define orange = #FFA500

define maroon = #800000

define black = #000000


// For easier use, put all the colours in a collection

define collection ColoursCollectionType

       green

       red

       blue

       fuchsia

       orange

       maroon

       black

end collection

define colours = create ColoursCollectionType


// Define our type of circle

define type of circle MainShapeType

       radius = 50

       colour = #FF2255

       isVisible = true

end circle


// Create our three shapes

define shape1 = create MainShapeType

define shape2 = create MainShapeType

define shape3 = create MainShapeType


// Create a black fixation point in the centre of the screen

define fixation = create MainShapeType

fixation.X = 50%

fixation.Y = 50%

fixation.Colour = black


// Move the 3 shapes around the fixation point

moveShapesOnCircle( fixation, 100, 0, shape1, shape2, shape3 )


// Loop slowly 100 times to show off the colours of the three circles changing

define counter = 0

while counter < 100


       // Now colour the shapes

       // Notice that even though black is in our colours collection, black

       // will never be selected because the fixation point is black

       // (even if the fixation point is not currently visible on the screen).

       colourShapeN( colours, shape1, shape2, shape3 )


       wait for 2sec

end while


Produces screens similar to these: