Make Shape Functions¶
This is a set of convience functions for creating shapes.
Functions
makeDebugColor (r, g, b, a, debug) |
Creates visible or invisible color depending on the debug flag |
makeDebugPicture (picture, debug) |
Takes a picture and makes all pixels transparant. |
makePic (fileName[, scale]) |
Takes a filename and create a centered picture without border. |
makeCircle ([radius, color, bodyType, x, y]) |
Creates a Circle that can be added to the simulator. |
makeRectangle ([w, h, color, outline, fill, ...]) |
Creates a Rectangle that can be added to the simulator. |
makeColCircle (radius[, bodyType]) |
Creates a transparant circle with the indicated radius |
makeColRec (width, height[, bodyType]) |
Creates a transparant, centered rectangle of the indicated width and height. |
makeColCircleAvatar (avatar[, bodyType]) |
Creates an invisible circle based on the size of an avatar. |
makeText ([text, size, color, xjust, yjust, ...]) |
Creates a text object with the Helvetica font. |
Details
-
makeDebugColor
(r, g, b, a, debug)[source]¶ Creates visible or invisible color depending on the debug flag
If debug is True, creates the indicated color; otherwise returns a transparant color.
Parameters: - r – The red component.
- g – The green component.
- b – The blue component.
- a – The alpha component.
- debug – Boolean, indicating whether this should be a ‘visible’ color.
Returns: - Returns the indicated color if debug is True; returns an invisible
transparant color if debug is False.
-
makeDebugPicture
(picture, debug)[source]¶ Takes a picture and makes all pixels transparant.
Parameters: - avatar – Picture object.
- debug – Boolean. If false, this function return the avatar unmodified.
-
makePic
(fileName, scale=1.0)[source]¶ Takes a filename and create a centered picture without border.
Parameters: - fileName – The name of a file containing a picture (.jpg and .png are supported)
- scale – The scale of the picture.
Returns: A Picture object.
-
makeCircle
(radius=50, color=color, bodyType='static', x=0, y=0)[source]¶ Creates a
Circle
that can be added to the simulator.Parameters: - radius – float indicating the radius of the circle.
- color –
Color
for both the fill and border of the rectangle. - bodyType – string indicating whether this rectangle should be moved by the simulator. Options are: “static” or “dynamic”.
- x – float indicating the x coordinate of the rectangle.
- y – float indicating the y coordinate of the rectangle.
-
makeRectangle
(w=100, h=100, color=color, outline=None, fill=None, bodyType='static', x=0, y=0)[source]¶ Creates a
Rectangle
that can be added to the simulator.Parameters: - w – float indicating the width of the rectangle.
- h – float indicating the heigth of the rectangle.
- color –
Color
for both the fill and border of the rectangle. - outline –
Color
for the border of the rectangle. - fill –
Color
for the fill of the rectangle. - bodyType – string indicating whether this rectangle should be moved by the simulator. Options are: “static” or “dynamic”.
- x – float indicating the x coordinate of the rectangle.
- y – float indicating the y coordinate of the rectangle.
-
makeColCircle
(radius, bodyType='static')[source]¶ Creates a transparant circle with the indicated radius
Parameters: - radius – The radius of the circle.
- bodyType – The body type of the circle, either ‘dynamic’ or ‘static’.
Returns: A Circle object.
-
makeColRec
(width, height, bodyType='static')[source]¶ Creates a transparant, centered rectangle of the indicated width and height.
Parameters: - width – The width of the rectangle
- height – The height of the rectangle
- bodyType – The body type of the rectangle, either ‘dynamic’ or ‘static’.
-
makeColCircleAvatar
(avatar, bodyType='static')[source]¶ Creates an invisible circle based on the size of an avatar.
Creates a transparant circle with a radius equal to the smallest side of the avatar.
Parameters: avatar – Usually a Picture object, must implement getP1() and getP2(). Returns: A Circle object.
-
makeText
(text=' ', size=16, color=color, xjust='left', yjust='bottom', pos=(0, 0), bodyType='static')[source]¶ Creates a text object with the Helvetica font.
Not much different from creating a text object manually, but applies the standard Scribbler Adventure font, which is currently Helvetica, and makes the color black, which is arguably more useful than Calico’s purple.
Parameters: - text (string) – The text to display in the text object.
- size (float) – The font size of the text.
- color (
Color
) – The color of the text. - xjust (string) – Horizontal alignment of the text. Options are: ‘left’, ‘right’, and ‘center’.
- yjust (string) – Vertical alignment of the text. Options are: ‘top’, ‘bottom’, and ‘center’.
- bodyType (string) – The body type of the text, used if the text is ever added to the physics simulator. Options are: ‘static’ and ‘dynamic’.