roar/libtools/ToolCircle.py

38 lines
1.5 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
#
2019-09-03 16:58:50 +00:00
# ToolCircle.py -- XXX
# Copyright (c) 2018 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
#
2019-09-03 16:58:50 +00:00
from Tool import Tool
2019-09-03 16:58:50 +00:00
class ToolCircle(Tool):
"""XXX"""
name = "Circle"
#
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc): XXX
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
brushColours = brushColours.copy()
if isLeftDown:
brushColours[1] = brushColours[0]
elif isRightDown:
brushColours[0] = brushColours[1]
else:
brushColours[1] = brushColours[0]
2019-09-03 16:58:50 +00:00
_brushSize = brushSize[0] * 2
originPoint, radius = (_brushSize / 2, _brushSize / 2), _brushSize
for brushY in range(-radius, radius + 1):
for brushX in range(-radius, radius + 1):
2019-09-03 16:58:50 +00:00
if ((brushX ** 2) + (brushY ** 2) < (((radius ** 2) + radius) * 0.8)):
patch = [ \
2019-09-03 16:58:50 +00:00
atPoint[0] + int(originPoint[0] + brushX), \
atPoint[1] + int(originPoint[1] + brushY), \
*brushColours, 0, " "]
if isLeftDown or isRightDown:
dispatchFn(eventDc, False, patch); dispatchFn(eventDc, True, patch);
else:
dispatchFn(eventDc, True, patch)
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120