Property Getting and Setting
Property Getting
object.property_name
To get any property from an Easy Draw object, simply use the variable name of storing the object dot the name of the property.
Example: Getting the radius
property from a Regular Polygon object named pentagon
Example: Getting the color
property from a Text object named title
Property Setting
object.set_property(property_name = new_value)
To set a property to a new value, you must call the .set_property()
method on the object you want to change, identifying the property you want to change and its new value.
Example: Changing the text
property of a Text object named title
Example: Changing the width
property of a Rectangle object named box
Examples
In this example we will create a square with a random color and an octagon with default color, "black"
. Whenever the octagon is clicked, its color will change to the square's color.
To do this, we need to get the color
property of the square and set the color
property of the octagon.
Get the square's color property -- square.color
Set the octagon's property -- octagon.set_property()
In this example, we create a growing circle by increasing the circle's radius by 10 each time it is clicked.
Notice how the Circle object's radius
property is set to the current cir.radius
plus 10.
Last updated