Beispiel #1
0
	def update(self):
		self.cache_pattern_img = None
		self.cache_ps_pattern_img = None
		self.cache_gray_pattern_img = None
		self.cache_paths = self.get_initial_paths()
		self.cache_cpath = libgeom.create_cpath(self.cache_paths)
		libgeom.apply_trafo(self.cache_cpath, self.trafo)
		self.update_bbox()
Beispiel #2
0
def get_arrow_cpath(arrow, trafo=None):
    if trafo is None:
        trafo = sk2const.NORMAL_TRAFO
    if isinstance(arrow, int):
        if not ARROWS_CACHE:
            ARROWS_CACHE.extend([None, ] * len(ARROWS))
        if not arrow < len(ARROWS):
            arrow = 0
        if ARROWS_CACHE[arrow] is None:
            ARROWS_CACHE[arrow] = libgeom.create_cpath(ARROWS[arrow])
        return libgeom.apply_trafo(ARROWS_CACHE[arrow], trafo, True)
    ret = None
    if arrow and isinstance(arrow, list):
        try:
            ret = libgeom.create_cpath(arrow)
        except Exception:
            ret = None
    if ret:
        return libgeom.apply_trafo(ret, trafo, True)
    return ret
Beispiel #3
0
 def is_point_on_path(self, win_point, path):
     self.clear()
     trafo = self.get_context_trafo(win_point)
     self.ctx.set_matrix(libcairo.get_matrix_from_trafo(trafo))
     stroke_width = config.stroke_sensitive_size
     stroke_width /= trafo[0]
     cpath = libgeom.create_cpath([path, ])
     self.ctx.new_path()
     self.ctx.append_path(cpath)
     self.ctx.set_line_width(stroke_width)
     self.ctx.stroke()
     return not libcairo.check_surface_whiteness(self.surface)
Beispiel #4
0
 def is_point_on_path(self, win_point, path):
     self.clear()
     trafo = self.get_context_trafo(win_point)
     self.ctx.set_matrix(libcairo.get_matrix_from_trafo(trafo))
     stroke_width = config.stroke_sensitive_size
     stroke_width /= trafo[0]
     cpath = libgeom.create_cpath([path])
     self.ctx.new_path()
     self.ctx.append_path(cpath)
     self.ctx.set_line_width(stroke_width)
     self.ctx.stroke()
     return not libcairo.check_surface_whiteness(self.surface)