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

Commit ce59987

Browse files
committed
reverted a bit; added more pallettes because it'll increase variation
1 parent e487c86 commit ce59987

File tree

4 files changed

+46
-38
lines changed

4 files changed

+46
-38
lines changed

.idea/workspace.xml

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

project/ArtiQule.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
from PyQt5.QtWidgets import (QAction, QApplication, QFileDialog,
88
QMainWindow, QPushButton,)
99

10-
# QBrush
11-
1210
"""
1311
Hover on QPaint detection
1412
def paintEvent(self, event):
@@ -23,7 +21,7 @@ def paintEvent(self, event):
2321

2422

2523
class ColorBox(QMainWindow):
26-
""" """
24+
""" This window holds all the color pallettes"""
2725
objs = []
2826

2927
def __init__(self, parent=None):
@@ -60,6 +58,7 @@ def closeEvent(self, *args, **kwargs):
6058

6159
@classmethod
6260
def setWindowCursor(cls, currentTool):
61+
"""Connects Canvas window with colorBox window"""
6362

6463
for obj in cls.objs:
6564
obj.setCursor(QCursor(QPixmap("Design/icons/{}.png".format(
@@ -121,7 +120,7 @@ def create_button(self):
121120

122121

123122
class PalletteButton:
124-
"""Class for color pallete; allows for mixing color"""
123+
"""Class for color pallete; allows for mixing colors"""
125124
def __init__(self, parentBtn):
126125
self.parentBtn = parentBtn
127126
self.r = randint(0, 255)
@@ -135,6 +134,12 @@ def __init__(self, parentBtn):
135134

136135

137136
def mixColor(self, tool):
137+
"""Mixes colors from tool holding the color
138+
NO COLOR IN TOOL: Pick up color pallette color
139+
IS TOOL BUCKET: empties palette
140+
COLOR IN TOOL: Mix pallette and tool color;
141+
IS BUCKET: mixes
142+
"""
138143
if tool is None or tool.toolName in \
139144
("Pointy Pen", "Pointy Pen Broken", "Sunbathing Eraser"):
140145
return None
@@ -155,8 +160,6 @@ def mixColor(self, tool):
155160
self.g = (self.g + tool.color.green()) // 2
156161
self.b = (self.b + tool.color.blue()) // 2
157162
elif tool.toolName == "A bucket filled":
158-
# TODO: bucket has to be able to
159-
# overflow other color pallette
160163
self.r = (self.r + tool.color.red()) // 4
161164
self.g = (self.g + tool.color.green()) // 4
162165
self.b = (self.b + tool.color.blue()) // 4
@@ -196,13 +199,13 @@ def __init__(self, parent=None):
196199
self.Setup()
197200

198201
def Setup(self):
202+
199203
self.canvas = QImage(self.size(), QImage.Format_RGB32)
200204
self.canvas.fill(Qt.white)
201205
self.connectTool()
202206
self.painter = QPainter(self.canvas)
203207

204-
# TODO: custom paintPatterns
205-
208+
## MENUBARS ##
206209
mainMenu = self.menuBar()
207210

208211
fileMenu = mainMenu.addMenu('File')
@@ -235,6 +238,8 @@ def Setup(self):
235238
save_file_action.triggered.connect(self.saveFile)
236239
exit_action.triggered.connect(self.exit)
237240

241+
## TOOLBAR AND WITH TOOL ICONS ##
242+
238243
self.toolbar = self.addToolBar("Toolbar")
239244
self.toolbar.setStyleSheet('background-color: white')
240245

@@ -274,7 +279,8 @@ def Setup(self):
274279
)
275280

276281
self.sunbathing_eraser = Tool("Sunbathing Eraser", 10, Qt.white,
277-
[0, 0, 0, 0.0], self, "", "Ctrl+F",
282+
[0, 0, 0, 0.0], self, "Design/icons/Sunbathing Eraser",
283+
"Ctrl+F",
278284
"Erase Your Mistakes, Kid!",
279285
(99999, 99999)) # infinte duration
280286

@@ -304,9 +310,7 @@ def connectTool(self, curTool=None):
304310
)
305311
)))
306312

307-
# TODO: make a variable self.currentTool
308-
# that'll hold the current selected tool, i fixed the class
309-
# TODO: check if window already exists if not make one
313+
310314
def colorBoxRun(self):
311315

312316
self.colorBox = ColorBox(self)
@@ -422,33 +426,27 @@ def mouseMoveEvent(self, event):
422426
if self.currentTool.toolName == "Pointy Pen":
423427
Pen.setCapStyle(Qt.RoundCap)
424428
Pen.setJoinStyle(Qt.MiterJoin)
425-
Pen.setWidth(self.currentTool.brushSize)
426429
elif "Brush" in self.currentTool.toolName:
427-
Pen = QBrush()
428430
if self.currentTool.toolName == "Straggly Paintbrush":
429-
Pen.setStyle(Qt.HorPattern)
431+
# TODO: this should more be like a brush
432+
Pen.setCapStyle(Qt.SquareCap)
433+
Pen.setJoinStyle(Qt.MiterJoin)
430434
else:
431435
pass
432436
Pen.setColor(self.currentTool.color)
437+
Pen.setWidth(self.currentTool.brushSize)
433438

434439
self.painter.setOpacity(self.currentTool.opacityDuration)
435-
self.painter.setPen(Pen) if Pen is QPen else \
436-
self.painter.setBrush(Pen)
440+
self.painter.setPen(Pen)
437441
if self.currentTool.duration <= 0:
438442
if self.currentTool.toolName == "Pointy Pen":
439443
self.setCursor(QCursor(
440444
QPixmap("Design/icons/Pointy Pen Broken.png")))
441445

442-
try:
443-
self.painter.drawLine(self.lastPoint, event.pos()) if Pen is QPen \
444-
else self.painter.drawRect(event.x(), event.y(), 100, 100)
446+
self.painter.drawLine(self.lastPoint, event.pos())
445447
self.lastPoint = event.pos()
446448
self.update()
447-
except Exception as ex:
448-
template = "An exception of type {0} occurred. Arguments:\n{1!r}"
449-
message = template.format(type(ex).__name__, ex.args)
450-
print(message)
451-
print(self.currentTool.duration, self.currentTool.opacityDuration)
449+
452450
else:
453451
return None
454452

1.13 KB
Loading

0 commit comments

Comments
 (0)