#!/usr/local/bin/python ## # Smiley # ------ # This program draws a smiley inside a window. It also uses the # the setredraw function so that whenever the window is redrawn # (e.g. after being obscured by another window) the smiley is # drawn again. ## from graphapp import * def draw_smile(w, r): r1 = insetr(r, 10) # inset r1 from edge of window p = pt(0,0) setcolour(LightBlue) # blue face !?! fillellipse(r1) # draw face setcolour(Red) # red lips setlinewidth(2) # thicker lips r2 = insetr(r1, 30) # inset from face rectangle drawarc(r2, 270-60, 270+60) # smile between arc angles setcolour(Brown) # brown eyes p.x = r1.x + r1.width * 1/2 p.y = r1.y + r1.height * 1/4 r2 = rect(p.x - 30, p.y, 20,20) fillellipse(r2) # draw left eye r2 = rect(p.x + 10, p.y, 20,20) fillellipse(r2) # draw right eye def main(): w = newwindow("Smile!", rect(50,50,120,120), StandardWindow) setredraw(w, draw_smile) show(w) mainloop() main()