-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPaint project.py
executable file
·1720 lines (924 loc) · 49.9 KB
/
Paint project.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#paintProject.py
#Nafis Fardin
#This is a dragon ballz themed paint prject with the ability to save load, drawing of multiple tools and includes many tools for free hand drawing.
#######################################indvidual features##########################################################################################################
#every tool accept fill and save/load is resizable with the scroll wheel
#theme song of dragon ballz will play while using the program
#pausing and playing can be done with the music
#fixed unfilled rectangle (corners)
#normal spray paint
#dripping spray paint
#polygon tool (closes by itself when close to starting point)
#paint brush with no spacing in between strokes
#fill tool
#transparent background
#eraser that erases transparent background (texture brush)
#text tool
#undo/redo
#eyedropper tool
#tk color paltte added for extra precis color options
#save and load allows user to click on drop down area and choose file
#window is always centered on screen
################################################## attention to detail #################################################################################
#Shows the mouse position only within canvas
#Text box that shows thickness of tools
#A text box shows what tool is currently being used
#scrolling or pressing of button will not add to the undo/redo list
#change of mouse cursor type depedning on mouse location(pencil on canvas, Arrow of canvas)
#filled and unfilled versions of all ashape tools (for filled ellipse tool right click when ellipse tool selected)
#tools highlet blue when hoveering on top of them and green when selected
#save and load is done with getname not tk to prevent crashing
#save tool automatically adds .png if file type not specified
#//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
from pygame import*
from math import*
from random import*
from text import *
from getname import*
from os import*
#--------------------------------------------------------------------------------
font.init()
comicFont = font.SysFont("Comic Sans MS", 20) #text font
#---------------------------------------------------------------------------------
init()
inf = display.Info()
w,h = inf.current_w,inf.current_h
#os.environ['SDL_VIDEO_WINDOW_POS'] = ('300,30')
screen = display.set_mode((1024,760))
running = True
#=======================================================================================
drawingspace_1 = Rect(300,30,700,500) #i just made this so my cursor works
pencil_strings = ( #sized 24x24
"X ",
"XXX ",
"XX.XX ",
"XX...XX ",
"XX.....XX ",
"XX.....XXX ",
"XX..XXX...X ",
" XXX......X ",
" X...X.....X ",
" X...X.....X ",
" X...X.....X ",
" X...X.....X ",
" X...X.....X ",
" X...X.....X ",
" X...X.....X ",
" X...X.....X ",
" X...X.....X ",
" X...X.....X ",
" X...X.....X ",
" X...X...XXX ",
" X...XXXXX ",
" XXXX ",
" ",
" ")
arrow = ( "xX ",
"X.X ",
"X..X ",
"X...X ",
"X....X ",
"X.....X ",
"X......X ",
"X.......X ",
"X........X ",
"X.........X ",
"X......XXXXX ",
"X...X..X ",
"X..XX..X ",
"X.X XX..X ",
"XX X..X ",
"X X..X ",
" X..X ",
" X..X ",
" X..X ",
" XX ",
" ",
" ",
" ",
" ")
#=================================================================================
from tkinter import *
from tkinter.colorchooser import * # module for colorchooser
root = Tk() # this initializes the Tk engine
root.withdraw() # by default the Tk root will show a little window. This
# just hides that window
#================================================================================
black = (0,0,0)
red = (255,0,0)
green = (0,255,0)
blue = (0,0,255)
white = (255,255,255)
yellow = (255,255,0)
pink = (255,105,180)
gold = (212,175,55) #Some frequently used colors
purple = (128,0,128)
orange = (255,165,0)
turquoise = (175,238,238)
grey = (192,192,192)
lightgreen = (144,238,144)
color = black #pen color
r = 1 #pen size
k = 0
#//////////////////////////////////////////////////////////////////////////////////////////
polygon_index = -1
#polygon tool releated lists and index
polygon_cord = []
#//////////////////////////////////////////////////////////////////////////////////////////
background_type = ""
#===========================================================================================
background = image.load("images/dragonballz.jpg") #dragonballz back ground
background = transform.scale(background,(1024,760))
screen.blit(background,(0,0))
#===========================================================================================
logo = image.load("images/Picture3.png")
logo = transform.scale(logo,(300,100)) #paint logo
screen.blit(logo,(10,10))
#===============================================================================================
#=====================================================================================
supers = logo = image.load("images/Picture5.png")
#supers = transform.scale(supers,(300,100)) #pic of gokku #
screen.blit(supers,(50,70))
#=====================================================================================
drawingspace = draw.rect(screen,white,(300,30,700,500)) #canvas
canvas_border = draw.rect(screen,black,(299,29,702,502),1) #canvas border
drawingspace_sub = Rect(300,30,700,500) #subsurface for save and load
draw_sub = Surface((700,500),SRCALPHA) #drawing space sun surface
color_rect = Rect((874,610,140,140)) # imaginary box around color palatte
#======================================================
colorpallate = image.load("images/color-picker.png")
colorpallate=transform.scale(colorpallate,(140,140)) #color picker image
screen.blit(colorpallate,(874,610))
color_pallate_border = draw.rect(screen,orange,(873,608,142,144),2)
#===============================================================
tools_background = Surface((350,500),SRCALPHA)
draw.rect(tools_background,(255,127,80,120),(0,0,190,310)) #orange back ground
screen.blit(tools_background,(20,240))
#===========================================================
pencil_icon = image.load("images/pen.jpg")
pencil_icon = transform.scale(pencil_icon,(50,50)) #bliting and scaling of pencil icon
screen.blit(pencil_icon,(30,250))
draw.rect(screen,black,(30,250,50,50),1)
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++
paint_icon = image.load("images/paint-brush.jpg")
paint_icon = transform.scale(paint_icon,(50,50)) #bliting and scaling of paint icon
screen.blit(paint_icon,(90,250))
#+++++++++++++++++++++++++++++++++++++++++++++++++++
eraser_icon = image.load("images/eraser.png")
eraser_icon = transform.scale(eraser_icon,(50,50)) #eraser image
screen.blit(eraser_icon,(30,310))
#++++++++++++++++++++++++++++++++++++++++++++++++++++
airbrush_icon = image.load("images/airbrush.png")
airbrush_icon = transform.scale(airbrush_icon,(50,50)) #airbrush image
screen.blit(airbrush_icon,(90,310))
#++++++++++++++++++++++++++++++++++++++++++++++++++++++
linetool_icon = image.load("images/linetool.png")
linetool_icon = transform.scale(linetool_icon,(50,50)) #linetool
draw.rect(screen,white,(150,250,50,50)) #White box that the picture sits in
screen.blit(linetool_icon,(150,250))
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rectangle_icon = image.load("images/unfilled-rect.png") #Rectangle tool pic
rectangle_icon = transform.scale(rectangle_icon,(40,40))
draw.rect(screen,white,(150,310,50,50)) #White box that the picture sits in
screen.blit(rectangle_icon,(155,314))
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ellipse_icon = image.load("images/ellipse.jpeg")
ellipse_icon = transform.scale(ellipse_icon,(50,50)) #ellipse tool pic
screen.blit(ellipse_icon,(30,370))
#====================================================================================================
stickersbox = draw.rect(screen,white,(400,650,460,100))
stickerborder = draw.rect(screen,black,(398,648,464,104),2)
#====================================================================================================
polygon_icon = image.load("images/polygon.png")
polygon_icon = transform.scale(polygon_icon,(60,60)) #polygon tool icons
draw.rect(screen,white,(90,370,50,50))
screen.blit(polygon_icon,(85,367))
#=======================================================================================================
fill_icon = image.load("images/fill.png")
fill_icon = transform.scale(fill_icon,(50,50)) #fill tool icon
draw.rect(screen,white,(150,430,50,50))
screen.blit(fill_icon,(150,430))
#====================================================================================================
filled_rect_box = image.load("images/rectangletool.png")
filled_rect_box = transform.scale(filled_rect_box,(50,50))
draw.rect(screen,white,(150,370,50,50)) #White box that the picture sits
screen.blit(filled_rect_box,(150,370)) #filled rectangletool
#======================================================================================================
drip_spray = image.load("images/drip.png")
drip_spray = transform.scale(drip_spray,(50,50))
#draw.rect(screen,white,(150,370,50,50)) #White box that the picture sits
screen.blit(drip_spray,(30,430))
#====================================================================================================
eye_dropper = image.load("images/dropper.png")
eye_dropper = transform.scale(eye_dropper,(48,48))
draw.rect(screen,white,(90,430,50,50)) #White box that the picture sits
screen.blit(eye_dropper,(90,430))
#====================================================================================================
text_icon = image.load("images/text.png")
text_icon = transform.scale(text_icon,(40,40))
draw.rect(screen,white,(30,490,50,50)) #text tool pics
screen.blit(text_icon,(33,493))
#===================================================================================================
dragonballz_bottom_logo = image.load("images/dragonlogo3.png")
#dragonballz_bottom_logo = transform.scale(dragonballz_bottom_logo,(80,80))
screen.blit(dragonballz_bottom_logo,(17,680))
#====================================================================================================
#music stuff
mixer.init()
mixer.music.load('music/themmusic.mp3')
mixer.music.play()
stopplay = 0 # flag for stopping and playing
play_icon = image.load('images/pause.png') #music pics
play_icon = transform.scale(play_icon,(40,40))
draw.rect(screen,white,(150,490,50,50))
screen.blit(play_icon,(155,495))
#-----------------------------------------------------------------------------------------------------
colored_line = image.load("images/coloredline.png")
colored_line = transform.scale(colored_line,(50,50)) #random line color tool
screen.blit(colored_line,(90,490))
#=====================================================================================================
savesquare = draw.rect(screen,white,(250,690,60,60)) #save and load boxes
save_icon = image.load("images/save-icon.png")
save_icon = transform.scale(save_icon,(50,50))
screen.blit(save_icon,(255,695))
draw.rect(screen,black,(250,690,60,60),2)
loadsquare = draw.rect(screen,white,(320,690,60,60))
load_icon = image.load("images/load-icon.png")
load_icon = transform.scale(load_icon,(50,50))
screen.blit(load_icon,(325,694))
draw.rect(screen,black,(320,690,60,60),2)
#=======================================================================================================
undorect = draw.rect(screen,white,(110,690,60,60))
draw.rect(screen,black,(110,690,60,60),2)
undo_icon = image.load("images/undo-icon.png")
undo_icon = transform.scale(undo_icon,(50,50))
screen.blit(undo_icon,(115,695))
redorect = draw.rect(screen,white,(180,690,60,60)) #undo redo related things
draw.rect(screen,black,(180,690,60,60),2)
redo_icon = image.load("images/redo.png")
redo_icon = transform.scale(redo_icon,(50,50))
screen.blit(redo_icon,(185,695))
firstpic = screen.subsurface(Rect(300,30,700,500)).copy()
undo = []
redo = []
#=====================================================================================================
tool = "pencil" #What tool im currently using
stick_tab_tool = "characters"
saveloadtool = ""
#======================================================================================================
#----------------------------------sticker boxes/ lines/ backgrounds------------------------------------------------
#note: dont load images in while loop makes program very slow
# i am loading all my backgrounds here
# ------------------------------------------- TEXT -----------------------------------------------------
draw.rect(screen,orange,(20,210,190,20))
draw.rect(screen,black,(19,209,191,21),1)
comicFont = font.SysFont("Comic Sans MS", 15) #tools text for actual tools
tools_font = comicFont.render("Tools / Shapes", True, (255,0,0))
screen.blit(tools_font,(70,207))
#------------------------------------------------------------------------------------------
tool_text_box = draw.rect(screen,white,(20,600,220,50))
tool_text_box_border = draw.rect(screen,black,(18,598,224,54),2)
text_for_tool = font.SysFont("Comic Sans MS", 20) #tools text for tool text box
#.........................................................................................
canvas_background1 = image.load("images/editedbackground1.jpg")
canvas_background1 = transform.scale(canvas_background1,(700,500))
canvas_background2 = image.load("stickers/toke.png")
canvas_background2 = transform.scale(canvas_background2,(700,500))
canvas_background3 = image.load("stickers/pond.png")
canvas_background3 = transform.scale(canvas_background3,(700,500))
background_sub = background.subsurface((300,30,700,500)) #subsurface for drawing space
#earth_sub = canvas_background1.subsurface((300,30,700,500))
clear_rect = draw.rect(screen,black,(410,665,100,70),1) #rect for clear background
earth_rect = draw.rect(screen,black,(520,665,100,70),1) #rect for earth background
border_b2 = draw.rect(screen,black,(630,665,100,70),1) #rect for dragon background
border_b3 = draw.rect(screen,black,(740,665,100,70),1) #rect for pond background
#============================================================================================================
background1 = image.load("images/background(1).png")
background1 = transform.scale(background1,(100,70))
#--------------------------------------------------------------------------
background2 = image.load('stickers/dragonwallpaper.jpeg')
background2 = transform.scale(background2,(100,70))
#---------------------------------------------------------------------------
background3 = image.load('stickers/water.png')
background3 = transform.scale(background3,(100,70))
while running:
click = False
up = False
mx,my = mouse.get_pos()
mb = mouse.get_pressed()
for e in event.get():
if e.type == QUIT:
running = False
if e.type == MOUSEBUTTONDOWN:
click = True
pic = screen.copy() #takes pic of the screen
if e.button == 1:
startx,starty = e.pos #related to shape tools
if e.button == 3:
startx,starty = e.pos
#-----------------------------------------------------------------
if len(polygon_cord) >= 0 and drawingspace.collidepoint(mx,my) and tool == "polygonmaker":
polygon_index += 1
polygon_cord.append((mx,my))
#---------------------------------------------------------------
if e.button == 4: #makes radius bigger
r += 1
if e.button == 5: #makes radius smaller
r -= 1
if e.type == MOUSEBUTTONUP:
if e.button == 1:
up=True
if tk_color.collidepoint(mx,my):
try:
color, drawcolorAsString = askcolor(title ='pick your colour.')
except:
pass
if up and drawingspace.collidepoint(mx,my):
pic_undo = screen.subsurface(Rect(300,30,700,500)).copy()
undo.append(pic_undo)
if r < 0:
r = 1
mx,my = mouse.get_pos()
mb = mouse.get_pressed()
#-----------------------------------------------------------------
if drawingspace_1.collidepoint(mx,my):
datatuple, masktuple = cursors.compile( pencil_strings,black='.', white='X', xor='o' )
mouse.set_cursor( (24,24), (0,0), datatuple, masktuple )
else:
datatuple, masktuple = cursors.compile( arrow,black='.', white='X', xor='o' )
mouse.set_cursor( (24,24), (0,0), datatuple, masktuple )
print(mx,my)
if mb[0] == 1:
if color_rect.collidepoint(mx,my):
screen.set_clip(color_rect)
color = screen.get_at((mx,my)) #ONly gets color is mouse collides with the color palatte
screen.blit(colorpallate,(874,610,140,140))
draw.ellipse(screen,black,(mx-5,my-5,10,10),1)
#-----------------------------------------------------------------
cord_size = font.SysFont("Comic Sans MS", 13)
#screen.blit(background.subsurface(80,544,200,200),(80,544)) #white box for cordinates
coordinates = cord_size.render("MX: %d, MY: %d"% (mx,my), True, black ) #cordinates when mouse collides with mouse
coordinates_else = cord_size.render("MX: ---, MY: ---", True, black ) #coordinates when mouse not collided with canvas
draw.rect(screen,white,(20,560,190,20))
draw.rect(screen,black,(20,560,190,20),2)
if drawingspace.collidepoint(mx,my):
screen.blit(coordinates,(70,560))
else:
screen.blit(coordinates_else,(75,560))
#====================================================================================================================
size_box = draw.rect(screen,white,(700,567,140,50))
draw.rect(screen,black,(700,567,140,50),2)
pen_size = font.SysFont("Comic Sans MS", 23)
pen_size_text = pen_size.render("Size: %d"% (r), True, black )
screen.blit(pen_size_text,(727,575))
#--------------------------------------------------------------------
pencil = draw.rect(screen,black,(30,250,50,50),1) #box around pencil icon
eraser = draw.rect(screen,black,(30,310,50,50),1) #box around eraser icon
paint = draw.rect(screen,black,(90,250,50,50),1) #box around paint icon
airbrush = draw.rect(screen,black,(90,310,50,50),1) #box around airbrush icon
linemaker = draw.rect(screen,black,(150,250,50,50),1) #box around line maker
rectanglemaker = draw.rect(screen,black,(150,310,50,50),1) #box around rect maker
ellipsemaker = draw.rect(screen,black,(30,370,50,50),1) #box around ellipse maker
polygonmaker = draw.rect(screen,black,(90,370,50,50),1)
filledrectmaker = draw.rect(screen,black,(150,370,50,50),1)
dripspray = draw.rect(screen,black,(30,430,50,50),1)
eyedropper = draw.rect(screen,black,(90,430,50,50),1)
canvasfill = draw.rect(screen,black,(150,430,50,50),1)
textmaker = draw.rect(screen,black,(30,490,50,50),1)
some_other_tool = draw.rect(screen,black,(90,490,50,50),1)
musicmaker = draw.rect(screen,black,(150,490,50,50),1)
#----------------------------------------------------------------
draw.rect(screen,white,(880,556,50,50))
tk_color_icon = image.load("images/color-icon.png")
tk_color_icon = transform.scale(tk_color_icon,(40,40))
screen.blit(tk_color_icon,(885,560))
tk_color = draw.rect(screen,black,(880,556,50,50),1)
colr_indicator = draw.rect(screen,color,(960,556,50,50))
if color == (black):
draw.rect(screen,white,(959,555,52,52),1)
else:
draw.rect(screen,black,(959,555,52,52),1)
#----------------------------------------------------------------
if mb[0] == 1 and pencil.collidepoint(mx,my):
tool = "pencil"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("Pencil Tool", True, (255,0,0))
screen.blit(text_tool,(70,610))
if mb[0] == 1 and eraser.collidepoint(mx,my): #Tool if statements( for collison )
tool = "eraser"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("Eraser Tool", True, (255,0,0))
screen.blit(text_tool,(70,610))
if mb[0] == 1 and paint.collidepoint(mx,my):
tool = "paint"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("Paint Tool", True, (255,0,0))
screen.blit(text_tool,(70,610))
if mb[0] == 1 and airbrush.collidepoint(mx,my):
tool = "airbrush"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("airbrush Tool", True, (255,0,0))
screen.blit(text_tool,(70,610))
if mb[0] == 1 and linemaker.collidepoint(mx,my):
tool = "linemaker"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("linemaker Tool", True, (255,0,0))
screen.blit(text_tool,(60,610))
if mb[0] == 1 and rectanglemaker.collidepoint(mx,my):
tool = "rectanglemaker"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("Rectangle Tool", True, (255,0,0))
screen.blit(text_tool,(60,610))
if mb[0] == 1 and ellipsemaker.collidepoint(mx,my):
tool = "ellipsemaker"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("Ellipse Tool", True, (255,0,0))
screen.blit(text_tool,(70,610))
'''e = font.SysFont("Comic Sans MS", 13)
text_tool = e.render("Ellipse Tool (Right click for filled)", True, (255,0,0))
screen.blit(text_tool,(70,610))'''
if mb[0] == 1 and polygonmaker.collidepoint(mx,my):
tool = "polygonmaker"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("Polygon Tool", True, (255,0,0))
screen.blit(text_tool,(70,610))
if mb[0] == 1 and filledrectmaker.collidepoint(mx,my):
tool = "filledrectmaker"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("Filled Rectangle Tool", True, (255,0,0))
screen.blit(text_tool,(30,610))
if mb[0] == 1 and dripspray.collidepoint(mx,my):
tool = "dripspray"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("dripspray Tool", True, (255,0,0))
screen.blit(text_tool,(70,610))
if mb[0] == 1 and eyedropper.collidepoint(mx,my):
tool = "eyedropper"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("Eyedropper Tool", True, (255,0,0))
screen.blit(text_tool,(60,610))
if mb[0] == 1 and canvasfill.collidepoint(mx,my):
tool = "canvasfill"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("Fill Tool", True, (255,0,0))
screen.blit(text_tool,(70,610))
if mb[0] == 1 and textmaker.collidepoint(mx,my):
tool = "textmaker"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("Text Tool", True, (255,0,0))
screen.blit(text_tool,(70,610))
if mb[0] == 1 and some_other_tool.collidepoint(mx,my):
tool = "some_other_tool"
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("Random Line Tool", True, (255,0,0))
screen.blit(text_tool,(40,610))
if mb[0] == 1 and tk_color.collidepoint(mx,my):
draw.rect(screen,white,(20,600,220,50))
color_tool = text_for_tool.render("Color palatte", True, (255,0,0))
screen.blit(color_tool,(40,610))
#//////////////////////////////////////////////////////////////////////////////////////////////////////
if click and musicmaker.collidepoint(mx,my): #music player
stopplay += 1
if stopplay % 2 == 1:
mixer.music.pause()
elif stopplay % 2 == 0:
mixer.music.play()
#-----------------------------------------------------------------------
if tool == "pencil":
draw.rect(screen,green,pencil,1)
draw.rect(screen,white,(20,600,220,50))
text_tool = text_for_tool.render("Pencil Tool", True, (255,0,0))
screen.blit(text_tool,(70,610))
if tool == "eraser":
draw.rect(screen,green,eraser,1)
if tool == "paint":
draw.rect(screen,green,paint,1)
if tool == "airbrush":
draw.rect(screen,green,airbrush,1)
if tool == "linemaker":
draw.rect(screen,green,linemaker,1)
if tool == "rectanglemaker":
draw.rect(screen,green,rectanglemaker,1)
if tool == "ellipsemaker":
draw.rect(screen,green,ellipsemaker,1)
if tool == "polygonmaker":
draw.rect(screen,green,polygonmaker,1)
if tool == "tkcolormaker":
draw.rect(screen,green,tk_color,1)
if tool == "filledrectmaker":
draw.rect(screen,green,filledrectmaker,1)
if tool == "dripspray":
draw.rect(screen,green,dripspray,1)
if tool == "eyedropper":
draw.rect(screen,green,eyedropper,1)
if tool == "canvasfill":
draw.rect(screen,green,canvasfill,1)
if tool == "textmaker":
draw.rect(screen,green,textmaker,1)
if tool == "some_other_tool":
draw.rect(screen,green,some_other_tool,1)
#----------------------------------------------------------------------
if eraser.collidepoint(mx,my):
draw.rect(screen,blue,(30,310,50,50),1)
if pencil.collidepoint(mx,my):
draw.rect(screen,blue,(30,250,50,50),1)
if paint.collidepoint(mx,my):
draw.rect(screen,blue,(90,250,50,50),1) #makes tools turn blue when mouse collides with it
if airbrush.collidepoint(mx,my):
draw.rect(screen,blue,(90,310,50,50),1)
if linemaker.collidepoint(mx,my):
draw.rect(screen,blue,(150,250,50,50),1)
if rectanglemaker.collidepoint(mx,my):
draw.rect(screen,blue,(150,310,50,50),1)
if ellipsemaker.collidepoint(mx,my):
draw.rect(screen,blue,(30,370,50,50),1)
if polygonmaker.collidepoint(mx,my):
draw.rect(screen,blue,(90,370,50,50),1)
if tk_color.collidepoint(mx,my):
draw.rect(screen,blue,(880,556,50,50),1)
if filledrectmaker.collidepoint(mx,my):
draw.rect(screen,blue,(150,370,50,50),1)
if dripspray.collidepoint(mx,my):
draw.rect(screen,blue,(30,430,50,50),1)
if eyedropper.collidepoint(mx,my):
draw.rect(screen,blue,(90,430,50,50),1)
if canvasfill.collidepoint(mx,my):
draw.rect(screen,blue,(150,430,50,50),1)
if textmaker.collidepoint(mx,my):
draw.rect(screen,blue,(30,490,50,50),1)
if musicmaker.collidepoint(mx,my):
draw.rect(screen,blue,(150,490,50,50),1)
if some_other_tool.collidepoint(mx,my):
draw.rect(screen,blue,(90,490,50,50),1)
#----------------------------------------------------------------
if mb[0] == 1 and drawingspace.collidepoint(mx,my):
screen.set_clip(drawingspace)
if tool == "pencil":
draw.line(screen,color,(omx,omy),(mx,my),1) #draws pencil lines
if tool == "eraser":
x = mx-omx
y = my-omy
d = hypot(x,y)
if d == 0:
d = 1
ex = max(mx,drawingspace.x+r)
ex = min(mx,drawingspace.right-r)
ey = max(my,drawingspace.y-r)
ey = min(my,drawingspace.bottom+r)
for i in range(int(d)):
sx = int(omx+i/d*x)