Advertisement
Guest User

draw_path_kivy.py

a guest
Aug 14th, 2015
230
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def draw_path(self, gc, path, transform, rgbFace=None):
  2.         polygons = path.to_polygons(transform, self.widget.width,
  3.                                     self.widget.height)
  4.         list_canvas_instruction = self.get_path_instructions(gc, polygons,
  5.                                     rgbFace=rgbFace)
  6.         for widget, instructions in list_canvas_instruction:
  7.             widget.canvas.add(instructions)
  8.  
  9. def get_path_instructions(self, gc, polygons, rgbFace=None):
  10.         instructions_list = []
  11.         points_line = []
  12.         for polygon in polygons:
  13.             for x, y in polygon:
  14.                 x = x + self.widget.x
  15.                 y = y + self.widget.y
  16.                 points_line += [float(x), float(y), ]
  17.             tess = Tesselator()
  18.             tess.add_contour(points_line)
  19.             if not tess.tesselate():
  20.                 Logger.warning("Tesselator didn't work :(")
  21.                 return
  22.             newclip = self.handle_clip_rectangle(gc, x, y)
  23.             if newclip > -1:
  24.                 instructions_list.append((self.clip_rectangles[newclip],
  25.                         self.get_graphics(gc, tess, points_line, rgbFace)))
  26.             else:
  27.                 instructions_list.append((self.widget,
  28.                         self.get_graphics(gc, tess, points_line, rgbFace)))
  29.         return instructions_list
Advertisement
RAW Paste Data Copied
Advertisement