Screenshot 2024-10-18 130325.png

Screenshot 2024-10-18 130148.png

Screenshot 2024-10-18 130325.png

Screenshot 2024-10-18 123440.png

Screenshot 2024-10-09 132413.png

image.png

from pygame import *
from random import *
from math import *

from tkinter import *                
from pygame import *
from tkinter import filedialog

root = Tk()         
root.withdraw()   

YELLOW = (255,255,0)
WHITE = (255,255,255)
    
screen = display.set_mode((1200,1000))
screen.fill((WHITE))

openRect = Rect(20,30,40,40)
saveRect = Rect(65,30,40,40)
#colourRect = Rect(100,50,40,40)

# TOOLS
pencilRect = Rect(20,80,40,40)
eraserRect = Rect(65,80,40,40)

# TK
draw.rect(screen,(0,255,0),openRect,2)
draw.rect(screen,(0,255,0),saveRect,2)
drawcolor = (0,0,0)

# running event
running = True

draw.rect(screen,(0,255,0),openRect,2)
draw.rect(screen,(0,255,0),saveRect,2)
drawcolor = (0,0,0)

while running:
    for e in event.get():
        if e.type == QUIT:
            running = False

    mb = mouse.get_pressed()
    mx,my = mouse.get_pos()

    draw.rect(screen,(0,255,0),pencilRect,2)
    draw.rect(screen,(0,255,0),eraserRect,2)

    # Select tool
    if mb[0]:
        if pencilRect.collidepoint(mx,my):
            draw.rect(screen,YELLOW,pencilRect,2)
            draw.circle(screen, YELLOW, (mx,my),4)
        if eraserRect.collidepoint(mx,my):
            draw.rect(screen,(255,255,0),eraserRect,2)
                draw.circle(screen, WHITE, (mx,my),4)

            
    # TK SAVING STUFF!
        if click:
            if openRect.collidepoint(mx,my):
               result = filedialog.askopenfilename(filetypes = [("Picture files", "*.png;*.jpg")]) 
               print(result)
        elif saveRect.collidepoint(mx,my):
            result = filedialog.asksaveasfilename() ###
            print(result)

            

    display.flip()

quit()

'''
tkinter is a Graphical User Interface toolkit.
tk == toolkit
inter == interface to your python program

Unlike pygame, you don't need to install anything new to use tkinter. You can
do a lot with tkinter. I suggest that you only use it for dialog boxes. The ones
below are some of the most useful dialogs, but certainly not the only ones.
'''
from tkinter import *                
from tkinter.colorchooser import *  # don't need this if you are not using colorchooser
from pygame import *
from tkinter import filedialog

root = Tk()             # this initializes the Tk engine
root.withdraw()         # by default the Tk root will show a little window. This
                        # just hides that window

screen = display.set_mode((800,600))
screen.fill((0,128,192))
openRect = Rect(20,80,40,40)
saveRect = Rect(65,80,40,40)
colourRect = Rect(110,80,40,40)

running =True
draw.rect(screen,(0,255,0),openRect,2)
draw.rect(screen,(0,255,0),saveRect,2)
drawcolor = (0,0,0)

while running:
    click = False
    for e in event.get():
        if e.type == QUIT:
            running = False
        if e.type == MOUSEBUTTONDOWN:
            if e.button == 1:
                click = True

    mb = mouse.get_pressed()
    mx,my = mouse.get_pos()

    if click:
        if openRect.collidepoint(mx,my):
            result = filedialog.askopenfilename(filetypes = [("Picture files", "*.png;*.jpg")]) # There are some options you can use to make these look nicer.
            print(result)
        elif saveRect.collidepoint(mx,my):
            result = filedialog.asksaveasfilename() ###
            print(result)

    display.flip()

quit()
from pygame import *
from random import *
from math import *
from tkinter import *                
from tkinter import filedialog

font.init()
helFont = font.SysFont("Helvetica", 36)
timFont = font.SysFont("Times New Roman", 46)

root = Tk()         
root.withdraw()   

YELLOW = (255,255,0)
WHITE = (255,255,255)
BLACK = (0,0,0)
BROWN = (102,51,0)

omx, omy = 0, 0

tool = "pencil"
colour = (BLACK)

screen = display.set_mode((1000,800))
display.set_caption("Right click to save canvas to file")

back = image.load("Untitled.png")
screen.blit(back, (0,0))
colourSpectrum = image.load("colourSpectrum.png")
screen.blit(colourSpectrum, (0, 800))

# making the canvas
canvasRect = Rect(85, 60, 835, 650)
draw.rect(screen, WHITE, canvasRect)
draw.rect(screen, BLACK, (85, 60, 835, 650),1)

# TK rects
openRect = Rect(930,150,60,60)
saveRect = Rect(930,230,60,60)
#colourRect = Rect(100,50,40,40)

# TOOLS rectangles
pencilRect = Rect(20,150,60,60)
eraserRect = Rect(20,230,60,60)

# running event
running =True
while running:
    for e in event.get():
        if e.type == QUIT:
            running = False

        if e.type == MOUSEBUTTONDOWN:       
            if e.button == 3:       # right click saves whatever's on canvas:
                saved = screen.subsurface(canvasRect).copy()  

                # Opens file explorer and asks for file name
                filename = filedialog.asksaveasfilename(defaultextension=".png")
                image.save(saved, filename)
                display.set_caption(f"Your masterpiece, '{filename}' has been saved!")

    mb = mouse.get_pressed()
    mx,my = mouse.get_pos()

    mx,my = mouse.get_pos()
    c = screen.get_at((mx,my))
    draw.rect(screen,c,(20,60,60,60))

    draw.rect(screen,BROWN,pencilRect,2)
    draw.rect(screen,BROWN,eraserRect,2)

    if mb[0]:
        if pencilRect.collidepoint(mx,my):
            draw.rect(screen,WHITE,pencilRect,2)
            tool = "pencil"
        if eraserRect.collidepoint(mx,my):
            draw.rect(screen,WHITE,eraserRect,2)
            tool = "eraser"

    draw.rect(screen,BROWN,openRect,2)
    draw.rect(screen,BROWN,saveRect,2)
    #drawcolor = (0,0,0)

    
    txtPic = timFont.render("SIP & SPLASH", True, (WHITE))
    screen.blit(txtPic,(90,10))

    txtPic = helFont.render(f"{(mx,my)}", True, (WHITE))
    screen.blit(txtPic,(400,15))

    draw.rect(screen, (0, 0, 0), canvasRect, 2)  # Draw the canvas boundary
    if mb[0] == 1 and canvasRect.collidepoint(mx, my):  # Left click and within canvas
        display.set_caption("Right click to save canvas to file")
        draw.circle(screen, (0, 0, 0), (mx, my), 3)

    
        if openRect.collidepoint(mx,my):
            result = filedialog.askopenfilename(filetypes = [("Picture files", "*.png;*.jpg")])
            print(result)
        elif saveRect.collidepoint(mx,my):
            result = filedialog.asksaveasfilename() 
            print(result)
     
        screen.set_clip(canvasRect)
        if tool == "pencil":
            draw.line(screen, colour, (omx, omy), (mx, my), 5)
        elif tool == "eraser":
            draw.line(screen, WHITE, (omx, omy), (mx, my), 5)

        screen.set_clip(None)

    omx, omy = mx,my
    display.flip()

quit()

from pygame import *
from random import *
from math import *

from tkinter import *                
from pygame import *
from tkinter import filedialog

font.init()
helFont = font.SysFont("Helvetica", 36)
timFont = font.SysFont("Times New Roman", 46)

root = Tk()         
root.withdraw()   

YELLOW = (255,255,0)
WHITE = (255,255,255)
BLACK = (0,0,0)
WHITE = (255,255,255)
BROWN = (102,51,0)

omx, omy = 0, 0

tool = "pencil"
colour = (BLACK)

screen = display.set_mode((1000,800))
display.set_caption("Right click to save canvas to file")

back = image.load("Untitled1.png")
screen.blit(back, (0,0))

# making the canvas
canvasRect = Rect(85, 60, 835, 650)
draw.rect(screen, WHITE, canvasRect)
draw.rect(screen, BLACK, (85, 60, 835, 650),1)

# sticker rect
coffee = image.load("coffee.png")

colourSpectrum = image.load("colourSpectrum.png")
screen.blit(colourSpectrum, (900, 0))

# TK rects
openRect = Rect(930,150,60,60)
saveRect = Rect(930,230,60,60)
#colourRect = Rect(100,50,40,40)

# TOOLS rectangles
pencilRect = Rect(20,150,60,60)
eraserRect = Rect(20,230,60,60)

# TK
draw.rect(screen,(0,255,0),openRect,2)
draw.rect(screen,(0,255,0),saveRect,2)
drawcolor = (0,0,0)

# running event
running =True
while running:
    for e in event.get():
        if e.type == QUIT:
            running = False

        if e.type == MOUSEBUTTONDOWN:       
            if e.button == 3:       # right click saves whatever's on canvas:
                saved = screen.subsurface(canvasRect).copy()  

                # Opens file explorer and asks for file name
                filename = filedialog.asksaveasfilename(defaultextension=".png")
                image.save(saved, filename)
                display.set_caption(f"Your masterpiece, '{filename}' has been saved!")

    mb = mouse.get_pressed()
    mx,my = mouse.get_pos()

    mx,my = mouse.get_pos()
    c = screen.get_at((mx,my))
    draw.rect(screen,c,(20,60,60,60))

    draw.rect(screen,BROWN,pencilRect,2)
    draw.rect(screen,BROWN,eraserRect,2)

    if mb[0]:
        if pencilRect.collidepoint(mx,my):
            draw.rect(screen,WHITE,pencilRect,2)
            tool = "pencil"
        if eraserRect.collidepoint(mx,my):
            draw.rect(screen,WHITE,eraserRect,2)
            tool = "eraser"

    draw.rect(screen,BROWN,openRect,2)
    draw.rect(screen,BROWN,saveRect,2)
    #drawcolor = (0,0,0)

    txtPic = timFont.render("SIP & SPLASH", True, (WHITE))
    screen.blit(txtPic,(90,10))

    txtPic = helFont.render(f"{(mx,my)}", True, (WHITE))
    screen.blit(txtPic,(400,15))

    draw.rect(screen, (0, 0, 0), canvasRect, 2)  # Draw the canvas boundary
    if mb[0] == 1 and canvasRect.collidepoint(mx, my):  # Left click and within canvas
        display.set_caption("Right click to save canvas to file")
        draw.circle(screen, (0, 0, 0), (mx, my), 3)

    # selecting tool

        
##    if openRect.collidepoint(mx,my):
##        result = filedialog.askopenfilename(filetypes = [("Picture files", "*.png;*.jpg")])
##        print(result)
##    elif saveRect.collidepoint(mx,my):
##         result = filedialog.asksaveasfilename() 
##        print(result)

    
     
    screen.set_clip(canvasRect)
    if mb[0]:
        if tool == "pencil":
            draw.line(screen, colour, (omx, omy), (mx, my), 5)
        elif tool == "eraser":
            draw.line(screen, WHITE, (omx, omy), (mx, my), 5)

 
    # TK SAVING STUFF!
##    
##        if openRect.collidepoint(mx,my):
##            result = filedialog.askopenfilename(filetypes = [("Picture files", "*.png;*.jpg")])
##            print(result)
##        elif saveRect.collidepoint(mx,my):
##            result = filedialog.asksaveasfilename() 
##            print(result)
##     
##        screen.set_clip(canvasRect)
##        if tool == "pencil":
##            pygame.draw.line(screen, BLACK, (omx, omy), (mx, my), 5)
##        elif tool == "eraser":
##            pygame.draw.line(screen, WHITE, (omx, omy), (mx, my), 5)
##
        screen.set_clip(None)

    omx, omy = mx,my
    display.flip()

quit()
from pygame import *
from random import *
from math import *

from tkinter import *                
from pygame import *
from tkinter import filedialog

font.init()
helFont = font.SysFont("Helvetica", 36)
timFont = font.SysFont("Times New Roman", 46)

root = Tk()         
root.withdraw()   

YELLOW = (255,255,0)
WHITE = (255,255,255)
BLACK = (0,0,0)
BROWN = (102,51,0)

# old coordintes set to 0
omx, omy = 0, 0

# the tool is automatically set to a black pencil
tool = "pencil"
drawcolour = (0,0,0)

screen = display.set_mode((1200, 800))
display.set_caption("Right click to save canvas to file")

# Load display
back = image.load("Untitled.png")
screen.blit(back, (0, 0))

# making the canvas
canvasRect = Rect(85, 60, 835, 650)
draw.rect(screen, WHITE, canvasRect)
draw.rect(screen, BLACK, (85, 60, 835, 650), 1)

# importing colours and stickers
colourSpectrum = image.load("colourSpectrum.png")
screen.blit(colourSpectrum, (850,400))
coffee = image.load("coffee.png")
donuts = image.load("donuts.png")
tea = image.load("tea.png")
croissant = image.load("croissant.png")
coffeeBean = image.load("coffeebean.png")
icedCoffee = image.load("icedCoffee.png")
coffee = transform.scale(coffee, (350,350))

# setting up sizes for rectangles
openRect = Rect(930,150,60,60)
saveRect = Rect(930,230,60,60)
#colourRect = Rect(100,50,40,40)
pencilRect = Rect(20,150,60,60)
eraserRect = Rect(20,230,60,60)
coffeestamp = Rect(20,310,60,60)

# drawing rectanlgles
draw.rect(screen,BROWN,openRect)
draw.rect(screen,BROWN,saveRect)
draw.rect(screen,BROWN,pencilRect)
draw.rect(screen,BROWN,eraserRect)
draw.rect(screen,BROWN,coffeestamp)

# running event
running =True
while running:
    for e in event.get():
        if e.type == QUIT:
            running = False

    mb = mouse.get_pressed()
    mx,my = mouse.get_pos()

    # choosing colour from colour spectrum
    if mb[0]:
        drawcolour = screen.get_at((mx,my))
        draw.rect(screen,drawcolour,(20,60,60,60))

    # selecting tool based off of button pressed
    if mb[0]:
        if pencilRect.collidepoint(mx,my):
            tool = "pencil"
        elif eraserRect.collidepoint(mx,my):
            tool = "eraser"
        elif openRect.collidepoint(mx,my):
            tool = "opening"
        elif saveRect.collidepoint(mx,my):
            tool = "saving"
        elif coffeestamp.collidepoint(mx,my):
            tool = "coffeestamp"

    # drawing text
    txtPic = timFont.render("SIP & SPLASH", True, (WHITE))
    screen.blit(txtPic,(90,10))

    txtPic = helFont.render(f"{(mx,my)}", True, (WHITE))
    screen.blit(txtPic,(400,15))

    # using tools
    screen.set_clip(canvasRect)
    if mb[0]:
        if tool == "pencil":
            draw.line(screen, drawcolour, (omx, omy), (mx, my), 5)
        elif tool == "eraser":
            draw.rect(screen,WHITE,eraserRect,2)
            draw.line(screen, WHITE, (omx, omy), (mx, my), 5) 
        elif tool == "opening":
            draw.rect(screen,WHITE,openRect,2)
            result = filedialog.askopenfilename(filetypes = [("Picture files", "*.png;*.jpg")])
            print(result)
        elif tool == "saving":
            draw.rect(screen, (0, 0, 0), canvasRect, 2) 
            sav = screen.subsurface(canvasRect)
            image.save(sav,"myPic.png")
            #result = filedialog.asksaveasfilename()
            filename = filedialog.asksaveasfilename(defaultextension=".png")
            image.save(saved, filename)
            display.set_caption("")
            display.set_caption(f"Your masterpiece, '{filename}' has been saved!")
            if ".png" not in result: 
                filename = filename + ".png"
                
                draw.rect(screen, (0, 0, 0), canvasRect, 2)  # Draw the canvas boundary
    if mb[0] == 1 and canvasRect.collidepoint(mx, my):  # Left click and within canvas
        display.set_caption("Right click to save canvas to file")
        draw.circle(screen, (0, 0, 0), (mx, my), 3)
        elif tool == coffeestamp:
         #screen.blit(canvasRect,(0,0))
            screen.blit(coffee, (mx-coffee.get_width()//2,my-coffee.get_height()//2))

        screen.set_clip(None)

    omx, omy = mx,my
    display.flip()

quit()

                
                #if drawing == "True":
                #or openRect.collidepoint(mx,my) or saveRect.collidepoint(mx,my): #if the user is drawing or on the open or save box
##                    currentCanvas=screen.subsurface(canvasRect).copy()  
##                    undo.append(currentCanvas) 
##                if undoRect.collidepoint(mx,my) and mb[0]==1:
##                    if len(undo)>1: # making sure that canvas isnt empty
##                        redo.append(undo.pop()) # bringing back the most recent 
##                        screen.blit(undo[-1],canvasRect) # put back last thing kinda similar to colours = [colours[-1]] + colours[:-1] from pravtice
##                if redoRect.collidepoint(mx,my) and mb[0]==1: #if the redo box is clicked
##                    if len(redo)!=0: #there has to be something on the canvas
##                        undo.append(redo.pop()) #taking the last picture that was redone and putting it into the undo list
##                        screen.blit(undo[-1],canvasRect) #placing the last canvas picture in the list onto the canvas
# importing all features
from pygame import *
from tkinter import *
from tkinter import filedialog
root = Tk()
root.withdraw()
font.init()

# importing some fonts
helFont = font.SysFont("Helvetica", 36)
timFont = font.SysFont("Times New Roman", 46)

# colours
YELLOW = (255, 255, 0)
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
BROWN = (102, 51, 0)
GREEN = (100, 83,31)

# setting up automatic pencil to black, and the old coordinates to 0 bc they dont exist yet
omx, omy = 0, 0     
sx,sy = 0,0         # starting x coordinate and starting y coordinate
size = 10           # starting size
tool = "pencil"     # tool is automatically set to penicl
drawcolour = (GREEN)# green is the automatic colour
drawing = False     # drawing isnt happening unless the user is on the canvas so its false rn

# screen
screen = display.set_mode((1200, 800))      # screen size
display.set_caption("Sip & Splash")         # name of the program at the top 

# enter background and colour spectrum
back = image.load("coffeeShop.jpg")         
screen.blit(back, (0, 0))
colourSpectrum = image.load("colourSpectrum.png")
screen.blit(colourSpectrum, (850, 400))

# creating a white canvas
canvasRect = Rect(85, 60, 835, 650)
draw.rect(screen, WHITE, canvasRect)   

# loading the stickers
coffee = image.load("coffee.png")
coffee = transform.scale(coffee, (120,120)) # sizing it
screen.blit(coffee,(1000, 120)) # putting it on screen
donuts = image.load("donuts.png")
donuts = transform.scale(donuts, (110,110))
screen.blit(donuts,(1000, 200))
icedCoffee = image.load("icedCoffee.png")
icedCoffee = transform.scale(icedCoffee, (120,120))
screen.blit(icedCoffee,(1000, 280))
croissant = image.load("croissant.png")
croissant = transform.scale(croissant, (95,120))
screen.blit(croissant,(1100, 120))
coffeeBean = image.load("coffeebean.png")
coffeeBean = transform.scale(coffeeBean, (160,165))
screen.blit(coffeeBean,(1065, 178))
tea = image.load("tea.png")
tea = transform.scale(tea, (100,100))
screen.blit(tea,(1090,300))

# all the sizing and placement of tool rectangles
pencilRect = Rect(10, 150, 60, 60)
eraserRect = Rect(10, 230, 60, 60)
fillRect = Rect(10, 310, 60, 60)
dropperRect = Rect(10,390, 60,60)
lineRect = Rect(10, 470, 60,60)
colourRect = Rect(943, 530, 210,113)
clearRect = Rect(930, 310,60,60)
highlightRect = Rect(930, 390,60,60)
openRect = Rect(930, 150, 60, 60)
saveRect = Rect(930, 230, 60, 60)
undoRect = Rect (10,720,60,60)
redoRect = Rect(90,720,60,60)
squareRect = Rect (170,720,60,60)
fillSquare = Rect (250,720,60,60)
circleRect = Rect(330,720,60,60)
fillCircle = Rect(410,720,60,60)
#sticker rectangles
coffeeRect = Rect(1025, 150, 60, 60)
donutsRect = Rect(1025, 225, 60, 65)
icedCoffeeRect = Rect(1025, 300, 60,80)
croissantRect = Rect(1125, 150, 60, 60)
coffeeBeanRect = Rect(1125, 225, 60, 60)
teaRect = Rect(1110, 310, 70,70)

# Drawing all the rectangles i created
draw.rect(screen, BROWN, pencilRect)
draw.rect(screen, BROWN, eraserRect)
draw.rect(screen, BROWN, fillRect)
draw.rect(screen, BROWN, dropperRect)
draw.rect(screen, BROWN, lineRect)
draw.rect(screen, BROWN, clearRect)
draw.rect(screen, BROWN, highlightRect)
draw.rect(screen, BROWN, openRect)
draw.rect(screen, BROWN, saveRect)
draw.rect(screen, BROWN, undoRect)
draw.rect(screen, BROWN, redoRect)
draw.rect(screen, BROWN, squareRect)
draw.rect(screen, BROWN, fillSquare)
draw.rect(screen, BROWN, circleRect)
draw.rect(screen, BROWN, fillCircle)

# drawing invisible rectangle for colour spectrum
draw.rect(screen, BLACK, colourRect,-1)

# draw invisible rectangles around the stamps
draw.rect(screen, WHITE, coffeeRect,1)
draw.rect(screen, WHITE, icedCoffeeRect,1)
draw.rect(screen, WHITE, donutsRect,1)
draw.rect(screen, WHITE, croissantRect,1)
draw.rect(screen, WHITE, coffeeBeanRect,1)
draw.rect(screen, WHITE, teaRect, 1)

# setting up alpha for the highlighter
cover = Surface((50,50)).convert()          
cover.set_alpha(5)
cover.fill((drawcolour)) 
cover.set_colorkey((drawcolour))
draw.circle(cover,(drawcolour),(25,25),24)

mx,my=0,0 # setting mx,my to 0,0 until it gets position later on in the code

# undo and redo lists
undo=[screen.copy().subsurface(canvasRect)] # it'll start with whatever is currently on the canvas
redo=[]  # empty list untill we undo stuff, the stuff we undo will get appended to the redo list

# main Loop
running = True
while running:
    for e in event.get():
        if e.type == QUIT:
            running = False
        if e.type == MOUSEBUTTONDOWN:
           if e.button == 1:
               start = e.pos
               back = screen.subsurface(canvasRect).copy()
           if e.button == 4: # scrolling up makes size thicker
               size += 1
           if e.button == 5: # scrolling down makes size thinner
               size -= 1

        if canvasRect.collidepoint(mx,my): # if the mouse is on canvas then drawing = Truw
            drawing=True
        if e.type==MOUSEBUTTONUP: #if the mouse is released
            if e.button==1: #if the left mouse button is clicked
                if drawing or openRect.collidepoint(mx,my): # if you're drawing or if you opened something
                    copyCanvas=screen.subsurface(canvasRect).copy() # copy the current canvas 
                    undo.append(copyCanvas) # add that image to the undo list
        if e.type==MOUSEBUTTONDOWN: # if the mouse is let go
            if e.button==1: # left click
                if undoRect.collidepoint(mx,my) : # if you press undo rect
                    if len(undo)>1: # if there is anything in the undo list
                        redo.append(undo.pop()) # add whatever you just undo'd to the redo
                        screen.blit(undo[-1],canvasRect) # blit the last thing on the undo list on to the canvas
                if redoRect.collidepoint(mx,my): 
                    if len(redo)!=0: # checking to make sure it is not empty
                        undo.append(redo.pop()) # add whatever you just redo'd to the undo
                        screen.blit(undo[-1],canvasRect) # blit the last thing on the redo list on to the canvas
                drawing = False
                
    mb = mouse.get_pressed()            # identifying buttons and getting position
    mx, my = mouse.get_pos()

    # Tool selections
    if mb[0]:       
        if colourRect.collidepoint(mx,my):              # getting the colour from colour spectrum
            drawcolour = screen.get_at((mx,my))         
        if pencilRect.collidepoint(mx, my):
            draw.rect(screen, WHITE, pencilRect,2)
            tool = "pencil"     
        elif eraserRect.collidepoint(mx, my):
            tool = "eraser"
            draw.rect(screen,WHITE, eraserRect,2)
            draw.rect(screen,WHITE, openRect,2)
        elif saveRect.collidepoint(mx, my):
            tool = "saving"
            draw.rect(screen,WHITE, saveRect,2)
        elif lineRect.collidepoint(mx,my):
            draw.rect(screen,WHITE, lineRect,2)
            tool = "line"
        elif clearRect.collidepoint (mx,my):            
            draw.rect(screen,WHITE,clearRect,2)
            tool = "clear"
        elif dropperRect.collidepoint(mx,my):
             draw.rect(screen,WHITE,dropperRect,2)
             tool = "dropper"
        elif fillRect.collidepoint(mx,my):
             draw.rect(screen,WHITE,fillRect,2)
             tool = "fill"
        elif highlightRect.collidepoint(mx,my):
             draw.rect(screen,WHITE,highlightRect,2)
             tool = "highlighter"
        elif squareRect.collidepoint(mx,my):
            draw.rect(screen,WHITE,squareRect,2)
            tool = "drawSquare"
        elif fillSquare.collidepoint(mx,my):
            draw.rect(screen,WHITE,fillSquare,2)
            tool = "filledSquare"
        elif circleRect.collidepoint(mx,my):
            draw.rect(screen,WHITE,circleRect,2)
            tool = "drawCircle"
        elif fillCircle.collidepoint(mx,my):
            draw.rect(screen,WHITE,fillCircle,2)
            tool = "filledCircle"
        

        # sticker selection
        elif coffeeRect.collidepoint(mx,my):
             tool = "coffeeStamp"
        elif donutsRect.collidepoint(mx,my):
             tool = "donutsStamp"
        elif icedCoffeeRect.collidepoint(mx,my):
             tool = "icedCoffeeStamp"
        elif croissantRect.collidepoint(mx,my):
             tool = "croissantStamp"
        elif coffeeBeanRect.collidepoint(mx,my):
             tool = "coffeeBeanStamp"
        elif teaRect.collidepoint(mx,my):
             tool = "teaStamp"        

    draw.rect(screen,drawcolour,(10,80,60,60))          # square to display current colour

    txtPic = timFont.render("SIP & SPLASH", True, WHITE)    # title of program
    screen.blit(txtPic, (90, 10))
        
    txtPic = timFont.render(f"{(mx, my)}", True, WHITE)
    screen.blit(txtPic, (400, 15))

    # Tool Usage
    if mb[0]:
        if tool == "clear":
            draw.rect(screen, WHITE, canvasRect)
    screen.set_clip(canvasRect)
    if mb[0] and canvasRect.collidepoint(mx, my):  # Inside canvas area
        if tool == "pencil":
            draw.line(screen, drawcolour, (omx, omy), (mx, my), 5)
        elif tool == "eraser":
            draw.line(screen, WHITE, (omx, omy), (mx, my), 10)
            pass
        elif tool == "line":
            screen.blit(back, canvasRect)
            draw.line(screen,drawcolour, start,(mx,my), size)
        elif tool == "drawSquare":
            screen.blit(back,canvasRect)
            widtht = abs(mx-sx)
            height = abs (my-sy)
            topX = (min(mx,sx))
            topY = min(my,sy)
            draw.rect(screen,drawcolour,(topX, topY, width, height),size)
        elif tool == "filledSquare":
            width = abs(mx-sx)
            height = abs (my-sy)
            topX = (min(mx,sx))
            topY = (min(my,sy))
            draw.rect(screen,drawcolour,(topX, topY, width, height))
        elif tool == "drawCircle":
            screen.blit(back,canvasRect)
            width = abs(my-sy)
            topX=(min(mx,sx))
            topY=(min(my,sy))
            draw.ellipse(screen,drawcolour,(topX, topY, width, height),size)           
        elif tool == "filledCircle":
            screen.blit(back,canvasRect)
            width = abs(my-sy)
            topX=(min(mx,sx))
            topY=(min(my,sy))
            draw.ellipse(screen,drawcolour,(topX, topY, width, height))   
        elif tool == "dropper":
            drawcolour = screen.get_at((mx,my)) # identifies colour of something on the canvas when clicked
        elif tool == "fill":
            draw.rect(screen, drawcolour, canvasRect) # fills the screen the chosen colour
        elif tool == "highlighter":
            screen.blit(cover,(mx-25,my-25))

            
##        elif tool=='spray':
##            screen.blit(spray,(720,530))
##            screen.blit(dspray,(920,530))
##            draw.rect(screen,BLUE,descriptionRect,3)
##            draw.rect(screen,BLUE,sprayRect,3)

            # stickers
        elif tool == "coffeeStamp":
            screen.blit(back, (0, 0))
            coffee = transform.scale(coffee, (200,200))
            screen.blit(coffee, (mx - coffee.get_width() // 2, my - coffee.get_height() // 2))
        elif tool == "donutsStamp":
            screen.blit(back,(0,0))
            donuts = transform.scale(donuts, (250,250))
            screen.blit(donuts, (mx - donuts.get_width() // 2, my - donuts.get_height() // 2))
        elif tool == "icedCoffeeStamp":
            screen.blit(back,(0,0))
            icedCoffee = transform.scale(icedCoffee, (250,250))
            screen.blit(icedCoffee, (mx - icedCoffee.get_width() // 2, my - icedCoffee.get_height() // 2))
        elif tool == "croissantStamp":
            screen.blit(back,(0,0))
            croissant = transform.scale(croissant, (250,250))
            screen.blit(croissant, (mx - croissant.get_width() // 2, my - croissant.get_height() // 2))
        elif tool == "coffeeBeanStamp":
            screen.blit(back,(0,0))
            coffeeBean = transform.scale(coffeeBean, (250,250))
            screen.blit(coffeeBean, (mx - coffeeBean.get_width() // 2, my - coffeeBean.get_height() // 2))
        elif tool == "teaStamp":
            screen.blit(back,(0,0))
            screen.blit(tea, (mx - tea.get_width() // 2, my - tea.get_height() // 2))
            
    elif tool == "opening":
            name=filedialog.askopenfilename(filetypes=[("Images","*.png;*.jpg;*.jpeg;*.bmp")])
            #if filename: 
            filename=image.load(filename) 
            filename=transform.scale(filename,(790,502)) 
            draw.rect(screen,WHITE,canvasRect) 
            screen.blit(filename,(400,10)) 
            copyCanvas=screen.subsurface(canvasRect).copy() 
            undo.append(copyCanvas) 
    elif tool == "saving":        
            filename=filedialog.asksaveasfilename(defaultextension=".png") 
            image.save(screen.subsurface(canvasRect),filename) 
            copyCanvas=screen.subsurface(canvasRect).copy() 
            undo.append(copyCanvas) 
            display.set_caption(f"Your masterpiece, '{filename}' has been saved!")

    screen.set_clip(None)  # Remove clipping
    omx, omy = mx, my  # Update old mouse position
    display.flip()
    #print(len(undo), len(redo))

quit()

import random

spray_radius = 20 # Radius of the spray area spray_density = 50 # Number of dots per spray (increase for denser spray)

Main loop

while running: for e in event.get():

Handle events...

mx, my = mouse.get_pos()
mb = mouse.get_pressed()

# Inside canvas area
if mb[0] and canvasRect.collidepoint(mx, my):  # Left mouse button and within the canvas
    if tool == "spray":
        # Draw random dots within the spray radius
        for _ in range(spray_density):
            # Random offset from the center (mx, my)
            offset_x = random.randint(-spray_radius, spray_radius)
            offset_y = random.randint(-spray_radius, spray_radius)

            # Check if the random point is within the circular spray area
            if offset_x**2 + offset_y**2 <= spray_radius**2:
                # Draw a small dot at each random point
                screen.set_at((mx + offset_x, my + offset_y), drawcolour)

# Rest of your drawing and display code
display.flip()