Refasctoring brush 'events' to be under data and named as such, moved cbindings to libs
This commit is contained in:
44
src/data/events/brushes/arrow.py
Normal file
44
src/data/events/brushes/arrow.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import cairo
|
||||
|
||||
# Application imports
|
||||
from data.point import Point
|
||||
from data.points import Points
|
||||
|
||||
from . import BrushEvent
|
||||
|
||||
|
||||
class Arrow(BrushEvent):
|
||||
def __init__(self):
|
||||
super(Arrow, self).__init__()
|
||||
|
||||
self.points: Points = Points()
|
||||
|
||||
def __copy__(self):
|
||||
copy = type(self)()
|
||||
copy.color = self.color
|
||||
|
||||
return copy
|
||||
|
||||
|
||||
def update(self, eve = None):
|
||||
if len(self.points) < 2:
|
||||
self.points.append( Point(eve.x, eve.y) )
|
||||
return
|
||||
|
||||
self.points[1] = Point(eve.x, eve.y)
|
||||
self.is_valid = True
|
||||
|
||||
|
||||
def process(self, brush: cairo.Context):
|
||||
|
||||
brush.set_line_width(self.size)
|
||||
brush.set_line_cap(1) # 0 = BUTT, 1 = ROUND, 2 = SQUARE
|
||||
brush.set_source_rgba(*self.color)
|
||||
brush.set_operator(cairo.OPERATOR_OVER);
|
||||
|
||||
brush.move_to(self.points[0].x, self.points[0].y)
|
||||
brush.line_to(self.points[1].x, self.points[1].y)
|
||||
brush.stroke()
|
||||
Reference in New Issue
Block a user