Created
January 15, 2014 03:04
-
-
Save csgregorian/8430038 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class brushTool(Tool): | |
"""Draws continuous circles at a given size""" | |
def canvasDown(self): | |
global toolLoc | |
toolLoc = cm() | |
def canvasHold(self): | |
if key.get_pressed()[K_LCTRL] or key.get_pressed()[K_RCTRL]: | |
color = tuple(map(cc, hls(hue/255, 0.5, 1))) | |
else: | |
color = currentColour | |
global layers | |
global toolLoc | |
self.m = (cm()[1] - toolLoc[1])/(cm()[0] - toolLoc[0] + (1 if cm()[0] - toolLoc[0] == 0 else 0)) | |
self.b = cm()[1] - (self.m * cm()[0]) | |
if abs(cm()[0] - toolLoc[0]) > abs(cm()[1] - toolLoc[1]): | |
if cm()[0] < toolLoc[0]: | |
for i in range(cm()[0], toolLoc[0]): | |
draw.circle(layers[currentLayer], color, (i, round(self.m*i + self.b)), size) | |
else: | |
for i in range(toolLoc[0], cm()[0]): | |
draw.circle(layers[currentLayer], color, (i, round(self.m*i + self.b)), size) | |
else: | |
if cm()[1] < toolLoc[1]: | |
for i in range(cm()[1], toolLoc[1]): | |
draw.circle(layers[currentLayer], color, (round((i-self.b)/self.m) if self.m != 0 else round(self.b), i), size) | |
else: | |
for i in range(toolLoc[1], cm()[1]): | |
draw.circle(layers[currentLayer], color, (round((i-self.b)/self.m) if self.m != 0 else round(self.b), i), size) | |
toolLoc = cm() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment