# moveShapesOnCircle

moveShapesOnCircle( referenceShape, distance, startAngle, shapeToMove1, shapeToMove2, …)

Moves the shapeToMove(s) relative to the referenceShape the given distance away and at the given angle (which must be in degrees, not radians).

The location of the shape is saved into the database and automatically associated with the current session, trial and phase (if applicable).

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

This function is quite handy when you need to move more than one shape at a time and want them all equidistant.

When using this function, it can be handy to have a reference diagram of the basic angles:

The shapes are all spaced evenly around the circle by angle (that is, the size of the shapes is not used when spacing them around the circle). Thus, the angle between the shapes is calculated using this equation:

Arguments

referenceShape |
- the reference shape (this shape is not moved) acts as the centre of the imaginary circle around which the other shapes will be placed. Note that this shape does not need to be visible to use it as the reference shape. |

distance |
- the distance away from the referenceShape to move the shapeToMove (basically, the radius of the imaginary circle on which the shapes will be placed). This value may be either absolute or a percent; if it is a percent then it is a percentage of the larger of the screen’s width. |

startAngle |
- The starting angle (in degrees) for the first shape to move. |

shapeToMove# |
- Any number of shapes to move. Each shape will be placed on the imaginary circle defined by reference shape and the distance, and the first of these shapes will be positioned at the startAngle with subsequent shapes being placed equally around the circle (as defined by the equation above). |

Returns

The number of shapes that were moved, which is always the number of shapes passed in.

This function also sets a variable “angle” on the shape itself that describes the angle the shape was positioned at; like everything else, this angle is saved in the database. You can access this variable after calling the function, but setting the variable does nothing.

Example

The following displays a black circle in the centre of the screen, and then moves three equally spaced circles all the way around it:

// Define a basic circle

define type of circle CircleType

radius = 50

colour = #FF0000

x = 50%

y = 50%

isVisible = true

end circle

// Create a centre circle that is black

define centre = create CircleType

centre.Colour = #000000

// Create the first circle red

define circle1 = create CircleType

circle1.colour = #550000

// Create the second circle blue

define circle2 = create CircleType

circle2.colour = #004400

// Create the third circle green

define circle3 = create CircleType

circle3.colour = #000059

// Move all three circles around the centre keeping them evenly spaced apart

define counter = 0

while counter <= 360

moveShapesOnCircle(centre, 200, counter, circle1, circle2, circle3 )

wait for 10ms

counter += 1

end while

wait for 5 sec

Here’s a screen shot of what this looks like in action: