def render_plant(plant, size): #print "render_plant:", plant, size ### buffer = plant.buffer if not buffer: size = (600, 600) ### #print "render_plant: Rendering", plant, "at", size ### buffer = Surface(size, SRCALPHA, 32) pos = vector(size[0] // 2, size[1]) turtle = Turtle(buffer, pos, -90) render_string(turtle, plant.structure) plant.buffer = buffer return buffer
def forward(self, distance, color, width): #print "Turtle.forward:", distance, color ### a = self.heading * deg p0 = self.position x0, y0 = p0 dx = distance * cos(a) dy = distance * sin(a) x1 = x0 + dx y1 = y0 + dy p1 = vector(x1, y1) #print "...", p0, p1 ### if self.enable_drawing: draw.line(self.surface, color, p0, p1, width) self.position = p1 self.path.append(p1)