Creating drawings consisting of geometric shapes
Code: "stddraw.py". Programming language: Python
DMelt Version 2.2. Last modified: 10/27/1972. License: Free
https://datamelt.org/code/cache/stddraw_7988.py
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.
from edu.princeton.cs.algs4 import StdDraw
StdDraw.square(0.2, 0.8, 0.1)
StdDraw.filledSquare(0.8, 0.8, 0.2)
StdDraw.circle(0.8, 0.2, 0.2)
StdDraw.setPenColor(StdDraw.BOOK_RED)
StdDraw.setPenRadius(0.02)
StdDraw.arc(0.8, 0.2, 0.1, 200, 45)
StdDraw.setPenRadius()
StdDraw.setPenColor(StdDraw.BOOK_BLUE)
x = [ 0.1, 0.2, 0.3, 0.2 ]
y = [ 0.2, 0.3, 0.2, 0.1 ]
StdDraw.filledPolygon(x, y)
StdDraw.setPenColor(StdDraw.BLACK)
StdDraw.text(0.2, 0.5, "black text")
StdDraw.setPenColor(StdDraw.WHITE)
StdDraw.text(0.8, 0.8, "white text")