from piscript.PiModule import * init("pythagoras", 50, 50) import math beginpage() center() translate(-8.5,-7) scale(4.2) a = 3.0 b = 4.0 c = math.sqrt(a*a + b*b) newpath() moveto(0, 0) rlineto(b, 0) rlineto(0,-b) rlineto(-b,0) closepath() fill(0, 1, 0) stroke() gsave() newpath() moveto(0, 0) rlineto(0, a) rlineto(-a, 0) rlineto(0,-a) closepath() fill(1, 0, 0) stroke() grestore() gsave newpath() translate(b,0) rotate(math.atan(-a/b)) moveto(0, 0) rlineto(-c, 0) rlineto(0,c) rlineto(c,0) closepath() fill(0, 0, 1) stroke() grestore() endpage() flush()