![]() Width and height of a rectangle can be scaled independently by using xscale, yscale parameters: Rt = shapes.rectangle(width=10, height=6, scale=2)Įffectively creates a rectangle of size 20 x 12. The rectangle or its sides can be scaled by using the scale parameter: Rt = shapes.rectangle(width=10, height=6, A roundness of 0.1 is often a good choice.Īn inverted rounding (called a chamfer) can be obtained by setting the invert parameter as True, together with the roundness parameter. The radius of this arc is calculated by multiplying the roundness parameter by the shortest side of the rectangle, the height in this case. This creates a rectangle with its corners replaced by a circular arc of radius 0.6. Rt = shapes.rectangle(width=10, height=6, roundness=0.1) A negative angle rotates the figure clockwise.Ī rounded rectangle (a rectangle whose corners are rounded) can be obtained by using the roundness parameter: This produces a rectangle rotated counterclockwise pi/6 radians (30 degrees) around the path. Rt = shapes.rectangle(width=10, height=6, rotate=pi/6) The shape is shown in gray on the default black canvas background.Ī rotated rectangle can be obtained like this: The shape can be visualized in VPython by executing the following statement, which extrudes the rectangular shape into the screen, along the line from vec(0,0,0) to vec(0,0,-0.1):Įxtrusion(path=, If you print rt you will see this list of 2D coordinates, starting at the lower right and continuing counterclockwise, end at the starting location: If the height value is omitted the shape is a square with its sides equal to the given width. Rt = shapes.rectangle(width=10, height=6)Ĭreates a list of 2D x-y coordinates of the corners of a rectangle of width=10 and height=6. ![]() The paths library is similar but provides lists of 3D points along which the 2D shape is extruded.Ĭhoose one of the shapes that are available in these libraries:īe sure to read about rectangle, which explains features common to all of these objects (rotate, scale, xscale, yscale, roundness, thickness, and invert). In the shape shown above, a circular region has been removed from a star. The shapes library helps in creating complex 2D shapes by creating and combining basic geometric shapes. ![]() The shapes and paths libraries are mainly used together with the 3D extrusion object.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |