Skip to content
This repository was archived by the owner on Mar 31, 2020. It is now read-only.

Commit 4bba551

Browse files
committed
fixed serious bug regarding color mixing
1 parent 4576fc1 commit 4bba551

File tree

8 files changed

+165
-45
lines changed

8 files changed

+165
-45
lines changed

.idea/workspace.xml

Lines changed: 136 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

project/ArtiQule.py

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ def mixColor(self, tool):
134134
("Pointy Pen", "Pointy Pen Broken", "Eraser"):
135135
return None
136136

137-
print("------------------")
138-
print(tool.color.red(), tool.color.green(), tool.color.blue())
139-
print(self.r, self.g, self.b)
140137
# TODO: pointy pen & no tool crashes upon clicking here with it
141138
if tool.toolName in ["A bucket", "Straggly Paintbrush",
142139
"Solid Brush"]:
@@ -148,44 +145,41 @@ def mixColor(self, tool):
148145
]
149146
)
150147

151-
if (not(colorSum) and tool.color.alpha() and self.alpha):
148+
if ( colorSum and tool.color.alpha() and self.alpha):
152149
# self.alpha so that color pallette is not empty
153-
tool.color = QColor(self.r, self.g, self.b, 255)
150+
self.r = (self.r + tool.color.red()) // 2
151+
self.g = (self.g + tool.color.green()) // 2
152+
self.b = (self.b + tool.color.blue()) // 2
154153
elif tool.toolName == "A bucket filled":
155-
self.r = (self.r + tool.color.red()) // 4
154+
# TODO: bucket has to be able to
155+
# overflow other color pallette
156+
self.r = (self.r + tool.color.red()) // 4 #
156157
self.g = (self.g + tool.color.green()) // 4
157-
# TODO:this if malfunctions after first activation
158158
self.b = (self.b + tool.color.blue()) // 4
159-
elif tool.toolName == "A bucket":
159+
elif not sum((self.r, self.g, self.b, self.alpha)): pass
160+
161+
self.palletteColor = (self.r, self.g, self.b, self.alpha)
162+
tool.color = QColor(self.r, self.g, self.b, self.alpha)
163+
164+
if tool.toolName in ["Straggly Paintbrush",
165+
"Solid Brush"]:
166+
tool.isDipped = True
167+
elif "A bucket" in tool.toolName and self.alpha:
160168
"""The pallette gets emptied """
161169
self.r = 0
162170
self.g = 0
163171
self.b = 0
164172
self.alpha = 0
165173
self.palletteColor = (self.r, self.g,
166174
self.b, self.alpha)
167-
elif not sum((self.r, self.g, self.b, self.alpha)):
168-
pass # might not need this if
169-
else:
170-
self.r = (self.r + tool.color.red()) // 2
171-
self.g = (self.g + tool.color.green()) // 2
172-
self.b = (self.b + tool.color.blue()) // 2
173-
174-
self.palletteColor = (self.r, self.g, self.b, self.alpha)
175-
tool.color = QColor(self.r, self.g, self.b, self.alpha)
176-
if tool.toolName in ["Straggly Paintbrush",
177-
"Solid Brush"]:
178-
tool.isDipped = True
179-
elif tool.toolName == "A bucket":
180175
tool.toolName = "A bucket filled"
181176
tool.PaintBoard.connectTool(tool)
182177
tool.duration = tool.constDuration
183178

184-
self.parentBtn.setStyleSheet("background-color: rgba{0}".format(
179+
self.parentBtn.setStyleSheet(
180+
"background-color: rgba{0}; border-radius:20px".format(
185181
self.palletteColor))
186182

187-
print(self.r, self.g, self.b)
188-
189183

190184
class PaintBoard(QMainWindow):
191185
def __init__(self, parent=None):
@@ -325,27 +319,27 @@ def colorBoxRun(self):
325319
c5 = PalletteButton(p5)
326320
c6 = PalletteButton(p6)
327321

328-
p1.setStyleSheet("background-color: rgba{0}; border-radius:50px"
322+
p1.setStyleSheet("background-color: rgba{0}; border-radius:20px"
329323
.format(c1.palletteColor))
330324
p1.clicked.connect(lambda: c1.mixColor(self.currentTool))
331325
self.colorBox.addPallette(p1)
332-
p2.setStyleSheet("background-color: rgba{0}"
326+
p2.setStyleSheet("background-color: rgba{0}; border-radius:20px"
333327
.format(c2.palletteColor))
334328
p2.clicked.connect(lambda: c2.mixColor(self.currentTool))
335329
self.colorBox.addPallette(p2)
336-
p3.setStyleSheet("background-color: rgba{0}"
330+
p3.setStyleSheet("background-color: rgba{0}; border-radius:20px"
337331
.format(c3.palletteColor))
338332
p3.clicked.connect(lambda: c3.mixColor(self.currentTool))
339333
self.colorBox.addPallette(p3)
340-
p4.setStyleSheet("background-color: rgba{0};"
334+
p4.setStyleSheet("background-color: rgba{0}; border-radius:20px;"
341335
.format(c4.palletteColor))
342336
p4.clicked.connect(lambda: c4.mixColor(self.currentTool))
343337
self.colorBox.addPallette(p4)
344-
p5.setStyleSheet("background-color: rgba{0}"
338+
p5.setStyleSheet("background-color: rgba{0}; border-radius:20px"
345339
.format(c5.palletteColor))
346340
p5.clicked.connect(lambda: c5.mixColor(self.currentTool))
347341
self.colorBox.addPallette(p5)
348-
p6.setStyleSheet("background-color: rgba{0}"
342+
p6.setStyleSheet("background-color: rgba{0}; border-radius:20px"
349343
.format(c6.palletteColor))
350344
p6.clicked.connect(lambda: c6.mixColor(self.currentTool))
351345
self.colorBox.addPallette(p6)
@@ -366,12 +360,12 @@ def mousePressEvent(self, event):
366360
self.painter.drawEllipse(event.pos(), 100, 150)
367361
self.currentTool.duration -= 1
368362
self.currentTool.toolName = "A bucket"
363+
self.currentTool.color = QColor(0,0,0,0)
369364
self.connectTool(self.currentTool)
370365
self.lastPoint = event.pos()
371366
self.update()
372367
else:
373-
return None # TODO: app still crashes
374-
# when moving with NoneType cusor
368+
return None
375369

376370
def mouseMoveEvent(self, event):
377371
if (event.buttons() and Qt.LeftButton) and \
@@ -383,6 +377,8 @@ def mouseMoveEvent(self, event):
383377
Pen.setDashPattern([0, 0, 0, 0])
384378
self.drawing = False
385379
else:
380+
#while self.currentTool.duration:
381+
# self.currentTool.color.alpha()
386382
self.currentTool.duration -= 0.1
387383

388384
if self.currentTool.toolName == "Pointy Pen":
@@ -463,4 +459,4 @@ def exit(self):
463459
app.setStyleSheet("QMainWindow{background-color:white}")
464460
myGUI = PaintBoard()
465461

466-
sys.exit(app.exec_())
462+
sys.exit(app.exec_())
11.1 KB
Binary file not shown.
4.09 KB
Binary file not shown.
7.51 KB
Binary file not shown.
1.82 MB
Binary file not shown.
70 KB
Binary file not shown.
358 KB
Binary file not shown.

0 commit comments

Comments
 (0)