mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 15:26:37 +00:00
39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
|
#!/usr/bin/env python3
|
||
|
#
|
||
|
# MiRCARTToolCircle.py -- XXX
|
||
|
# Copyright (c) 2018 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||
|
#
|
||
|
|
||
|
from MiRCARTTool import MiRCARTTool
|
||
|
|
||
|
class MiRCARTToolCircle(MiRCARTTool):
|
||
|
"""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]
|
||
|
_brushSize = brushSize[0]*2
|
||
|
originPoint = (_brushSize/2, _brushSize/2)
|
||
|
radius = _brushSize
|
||
|
for brushY in range(-radius, radius + 1):
|
||
|
for brushX in range(-radius, radius + 1):
|
||
|
if ((brushX**2)+(brushY**2) < (((radius**2)+radius)*0.8)):
|
||
|
patch = [ \
|
||
|
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
|