Creating drawings consisting of geometric shapes
Source code name: ""
Programming language: Python
Topic: Graphics/2D
DMelt Version 2.2. Last modified: 10/27/1972. License: Free
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.

# StdDraw class provides a basic capability for creating drawings with your programs. It uses a simple graphics model that allows you to create drawings consisting of points, lines, squares, circles, and other geometric shapes in a window on your computer and to save the drawings to a file.

# You can save the image using "File" and use "*.png" as a file extension.

from edu.princeton.cs.algs4 import StdDraw

StdDraw.square(0.2, 0.8, 0.1)
StdDraw.filledSquare(0.8, 0.8, 0.2), 0.2, 0.2)

StdDraw.arc(0.8, 0.2, 0.1, 200, 45)

# draw a blue diamond
x = [ 0.1, 0.2, 0.3, 0.2 ]
y = [ 0.2, 0.3, 0.2, 0.1 ]
StdDraw.filledPolygon(x, y)

# text
StdDraw.text(0.2, 0.5, "black text")
StdDraw.text(0.8, 0.8, "white text")