#! python import math class point: def __init__(self, xloc, yloc): self.x = xloc self.y = yloc def rotateorigin(self, degrees): radians = degrees * math.pi / 180.0 return point(self.x * math.cos(radians) - self.y * math.sin(radians), self.x * math.sin(radians) + self.y * math.cos(radians)) def rotate(self, degrees, xorigin, yorigin): rot = point(self.x - xorigin, self.y - yorigin).rotateorigin(degrees) return point(rot.x + xorigin, rot.y + yorigin) def translate(self, x, y): return point(self.x + x, self.y + y) class actor: _width = 80 _depth = 48 def __init__(self, boyOrGirl, x, y, angle): self._x = x self._y = y self._angle = angle if boyOrGirl == "boy": self._isGirl = False self._class = "boy" else: self._isGirl = True self._class = "girl" def center(self): return point(self._x, self._y) def point(self, id): return self.pointrel(id).rotateorigin(self._angle).translate(self._x, self._y) def pointrel(self, id): if id == "center": return point(0, 0) elif id == "L shoulder": return point(self._width/2 - 2, -self._depth/2 + 2) elif id == "R shoulder": return point( - self._width/2 + 2, -self._depth/2 + 2) elif id == "L hip": return point(self._width/2 - 2, -self._depth/2 + 2) elif id == "R hip": return point( - self._width/2 + 2, -self._depth/2 + 2) elif id == "L arm": return point(self._width/2 - 2, 0) elif id == "R arm": return point( - self._width/2 + 2, 0) elif id == "ribcage": return point(0, - self._depth / 2 + 2) elif id == "L outward": return point(self._width, self._depth) elif id == "R outward": return point(- self._width, self._depth) def armto(self, origid, dest): orig = self.point(origid) print '' def draw(self): x = self._x y = self._y if self._isGirl: symbol = "girl" else: symbol = "boy" print ' ' def fileheader(): print """ Salsa Notes in SVG

Salsa Notes in SVG

$Id$

""" def startscene(title): print "

" + title + "

" print """ """ def endscene(): print " " def filefooter(): print """ """ def drawline(orig, dest): print '' fileheader() startscene("Closed Hold") boy = actor("boy", 100, 134, 180) boy.draw() girl = actor("girl", 100, 34, 0) girl.draw() boy.armto("R arm", girl.point("ribcage")) girl.armto("L arm", boy.point("R shoulder")) boy.armto("L arm", boy.point("L outward")) girl.armto("R arm", boy.point("L outward")) endscene() startscene("XB") boy = actor("boy", 180, 104, 90) boy.draw() girl = actor("girl", 100, 34, 0) girl.draw() boy.armto("R arm", girl.point("ribcage")) girl.armto("L arm", boy.point("R shoulder")) boy.armto("L arm", boy.point("L outward")) girl.armto("R arm", boy.point("L outward")) endscene() startscene("and slide") boy = actor("boy", 100, 34, 0) boy.draw() girl = actor("girl", 100, 134, 180) girl.draw() boy.armto("R arm", boy.point("R outward")) boy.armto("L arm", boy.point("L outward")) girl.armto("L arm", boy.point("R outward")) girl.armto("R arm", boy.point("L outward")) endscene() startscene("XB open") boy = actor("boy", 180, 104, 90) boy.draw() girl = actor("girl", 100, 34, 0) girl.draw() boy.armto("R arm", boy.point("R outward")) boy.armto("L arm", boy.point("L outward")) girl.armto("L arm", boy.point("R outward")) girl.armto("R arm", boy.point("L outward")) endscene() startscene("with one CCW turn - step 1") boy = actor("boy", 180, 104, 90) boy.draw() girl = actor("girl", 100, 104, 180) girl.draw() boy.armto("R arm", boy.point("R outward")) boy.armto("L arm", boy.point("L outward")) girl.armto("L arm", boy.point("R outward")) girl.armto("R arm", boy.point("L outward")) endscene() # this isn't right -- the girl's arm should go across in front, # not behind. startscene("with one CCW turn - step 2") boy = actor("boy", 140, 34, 0) boy.draw() girl = actor("girl", 100, 104, 0) girl.draw() boy.armto("R arm", girl.point("R hip")) boy.armto("L arm", girl.point("R hip")) girl.armto("L arm", girl.point("R hip")) girl.armto("R arm", boy.point("R shoulder")) endscene() filefooter()