def draw_line(self, ctx, x, y, width, height):
ctx.move_to(x, y)
ctx.rel_line_to(width, height)
ctx.close_path()
ctx.set_operator(cairo.OPERATOR_SOURCE)
ctx.set_line_width(1.0)
ctx.set_source_rgb(0, 0, 0)
ctx.stroke()
python类OPERATOR_SOURCE的实例源码
def transparent_pix(self):
op = self.ctx.get_operator()
self.ctx.set_operator(OPERATOR_SOURCE)
self.ctx.set_source_rgba(*[1, 1, 1, 0.95])
self.dot(1-self.pix, 1.0-self.pix)
self.ctx.set_operator(op)
def area_draw(wid, cr):
"""
area_draw: Çizim Alan?
Çizilen pencere alan?nda görsel de?i?iklikler yapmam?z? sa?lar. Pencere'nin
Arkaplan rengini siyah, görünürlü?ünü'de %90 opak yaparak %10 transparan
Olmas?n? sa?lad?k ve ard?ndan cizimin yap?lmas?n? istedik.
"""
cr.set_source_rgba(0, 0, 0, 0.9)
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.paint()
cr.set_operator(cairo.OPERATOR_OVER)
def transparent_pix(self):
op = self.ctx.get_operator()
self.ctx.set_operator(OPERATOR_SOURCE)
self.ctx.set_source_rgba(*[1, 1, 1, 0.95])
self.dot(1-self.pix, 1.0-self.pix)
self.ctx.set_operator(op)
def area_draw(self, widget, cr): # pragma: no cover
cr.set_source_rgba(.0, .0, .0, 0.0)
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.paint()
cr.set_operator(cairo.OPERATOR_OVER)
cr.set_source_rgb(0.9, 0.1, 0.1)
cr.set_line_width(6)
cr.rectangle(0, 0, self.get_size()[0], self.get_size()[1])
cr.stroke()