예제 #1
0
파일: polygon.py 프로젝트: HENRDS/INE5408
 def draw(self, ctx: DrawContext) -> None:
     cairo_ctx = ctx.ctx
     pts = iter(self._ppc)
     x = ctx.viewport_transform(next(pts))
     cairo_ctx.move_to(*x[:-1])
     for p in pts:
         cairo_ctx.line_to(*ctx.viewport_transform(p)[:-1])
     cairo_ctx.line_to(*x[:-1])
     cairo_ctx.stroke()
예제 #2
0
파일: curve.py 프로젝트: HENRDS/INE5408
 def draw(self, ctx: DrawContext) -> None:
     cairo_ctx = ctx.ctx
     pts = [ctx.viewport_transform(p) for p in self._ppc]
     cairo_ctx.move_to(*pts[0][:2])
     for p in pts[1:]:
         cairo_ctx.line_to(*p[:2])
     cairo_ctx.stroke()
예제 #3
0
파일: polygon.py 프로젝트: HENRDS/INE5408
 def draw_verbose(self, ctx: DrawContext) -> None:
     self.draw(ctx)
     cairo_ctx = ctx.ctx
     with this_source_rgb(cairo_ctx, 0., 1., 0.):
         for point in self._ppc:
             x, y = ctx.viewport_transform(point)[:-1]
             cairo_ctx.arc(x, y, 5, 0, 2 * np.pi)
             cairo_ctx.fill()
             cairo_ctx.close_path()
예제 #4
0
파일: point.py 프로젝트: HENRDS/INE5408
 def draw_verbose(self, ctx: DrawContext) -> None:
     self.draw(ctx)
     cairo_ctx = ctx.ctx
     x, y = ctx.viewport_transform(self._ppc[0])[:-1]
     cairo_ctx.move_to(x + 5, y + 5)
     src = cairo_ctx.get_source()
     cairo_ctx.set_source_rgb(0., 1., 0.)
     cairo_ctx.show_text(self.name)
     cairo_ctx.set_source(src)
예제 #5
0
 def draw_verbose(self, ctx: DrawContext) -> None:
     self.draw(ctx)
     p1, p2 = [ctx.viewport_transform(p) for p in self._ppc][:2]
     cairo_ctx = ctx.ctx
     src = cairo_ctx.get_source()
     cairo_ctx.set_source_rgb(0., 1., 0.)
     cairo_ctx.arc(*p1[:-1], 5, 0, 2 * np.pi)
     cairo_ctx.fill()
     cairo_ctx.arc(*p2[:-1], 5, 0, 2 * np.pi)
     cairo_ctx.fill()
     cairo_ctx.set_source(src)
예제 #6
0
    def on_canvas_draw(self, sender: Gtk.DrawingArea, ctx) -> None:
        # self.viewport.resize(float(self.canvas.get_allocated_width()) - 20.,
        #                      float(self.canvas.get_allocated_height()) - 20.)
        # print((float(self.canvas.get_allocated_width()) - 20., float(self.canvas.get_allocated_height()) - 20.))
        from util import this_source_rgb
        with this_source_rgb(ctx, 1., 1., 1.):
            ctx.rectangle(0, 0, 900, 500)
            ctx.fill()

        draw_ctx = DrawContext(self.viewport, self.model.window, ctx)
        from clipping import CohenSutherland
        for obj in self.model.objects(CohenSutherland(self.model.window)):
            if obj.name == self.get_selected_name():
                ctx.set_source_rgb(1., 0., 0.)
                obj.draw_verbose(draw_ctx)
                ctx.set_source_rgb(0., 0., 0.)
            else:
                obj.draw(draw_ctx)
        self.viewport.draw(ctx)
예제 #7
0
 def draw(self, ctx: DrawContext) -> None:
     p1, p2 = [ctx.viewport_transform(p) for p in self._ppc][:2]
     cairo_ctx = ctx.ctx
     cairo_ctx.move_to(*p1[:-1])
     cairo_ctx.line_to(*p2[:-1])
     cairo_ctx.stroke()
예제 #8
0
 def draw(self, ctx: DrawContext) -> None:
     list_points = [ctx.viewport_transform(p) for p in self._ppc]
     cairo_ctx = ctx.ctx
     cairo_ctx.move_to(*list_points[:-1])
     cairo_ctx.line_to(*list_points[:-1])
     cairo_ctx.stroke()
예제 #9
0
파일: point.py 프로젝트: HENRDS/INE5408
 def draw(self, ctx: DrawContext) -> None:
     cairo_ctx = ctx.ctx
     x, y = ctx.viewport_transform(self._ppc[0])[:-1]
     cairo_ctx.arc(x, y, 5, 0, 2 * np.pi)
     cairo_ctx.fill()