<commit_before>
# import modules

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import math

#find globals
WIDTH = 500
HEIGHT = 500
paint_shape = "circle"
paint_color = "Lightgrey"
pos = [WIDTH / 2, HEIGHT / 2]
shape_radius = 25

#define event handler for mouse click, paint


#mouse click 
def click(position):
    global pos
    pos = list(position)
    
#colors and shapes
#colors
def paint_lightgrey():
    global paint_color
    paint_color = "Lightgrey"
    
def paint_silver():
    global paint_color
    paint_color = "Silver"

def paint_blue():
    global paint_color
    paint_color = "Blue"

#shapes
def draw_circle():
    global paint_shape
    paint_shape = "circle"

def draw_square():
    global paint_shape
    paint_shape = "square"

def draw_triangle():
    global paint_shape
    paint_shape = "triangle"

#canvas
def draw(canvas):
    draw_pos = list(pos)
    x = pos[0]
    y = pos[1]
    r = shape_radius
    if paint_shape == "triangle":
       canvas.draw_polygon([(x,y+r),(x-r,y-r/2),(x+r,y-r/2)], 1, "White", paint_color)
    elif paint_shape == "square":
       canvas.draw_polygon([(x-r, y-r),(x-r, y+r),(x+r, y+r),(x+r, y-r)],1,"White",paint_color)
    elif paint_shape == "circle":
       canvas.draw_circle(draw_pos, shape_radius ,1, "White", paint_color)




     
  
# Create frames and assign callbacks to event handlers

##create frame and set color and canvas
frame = simplegui.create_frame("The Painter", WIDTH, HEIGHT)
frame.set_canvas_background("white")

frame.add_button("circle",draw_circle,100)
frame.add_button("square", draw_square,100)
frame.add_button("triangle", draw_triangle,100)
frame.add_button("lightgrey", paint_lightgrey,100)
frame.add_button("silver", paint_silver,100)
frame.add_button("blue", paint_blue,100)

#register event handlers
frame.set_draw_handler(draw)
frame.set_mouseclick_handler(click)

#start frame 
frame.start()




            <commit_msg>circles of each color are in the list but squares and triangles are not. "canvas.draw_polygon(draw_pos[0], 1 , "White", draw_pos[2])"->"undefined: TypeError: undefined is not a function"<commit_after>
# import modules

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
import math

#find globals
WIDTH = 500
HEIGHT = 500
paint_shape = "circle"
paint_color = "Lightgrey"
pos = [WIDTH / 2, HEIGHT / 2]
shape_radius = 25
shape_list = []

#define event handler for mouse click, paint

#mouse click 
def click(position):
    global pos, shape_list
    pos = list(position)
    shape_list.append([pos,paint_shape,paint_color])
    
#colors and shapes
#colors
def paint_lightgrey():
    global paint_color
    paint_color = "Lightgrey"
    
def paint_silver():
    global paint_color
    paint_color = "Silver"

def paint_blue():
    global paint_color
    paint_color = "Blue"

#shapes
def draw_circle():
    global paint_shape
    paint_shape = "circle"

def draw_square():
    global paint_shape
    paint_shape = "square"

def draw_triangle():
    global paint_shape
    paint_shape = "triangle"

#canvas
def draw(canvas):
    draw_pos = list(pos)
    x = pos[0]
    y = pos[1]
    r = shape_radius
    
    if paint_shape == "triangle":
       canvas.draw_polygon([(x,y+r),(x-r,y-r/2),(x+r,y-r/2)], 1, "White", paint_color)
    elif paint_shape == "square":
       canvas.draw_polygon([(x-r, y-r),(x-r, y+r),(x+r, y+r),(x+r, y-r)],1,"White",paint_color)
    elif paint_shape == "circle":
       canvas.draw_circle(draw_pos, shape_radius ,1, "White", paint_color)

# record in list
    for draw_pos in shape_list:
        if draw_pos[1] =="circle":
            canvas.draw_circle(draw_pos[0], shape_radius,1,"White", draw_pos[2])
        else:
            canvas.draw_polygon(draw_pos[0], 1 , "White", draw_pos[2])

  
# Create frames and assign callbacks to event handlers

##create frame and set color and canvas
frame = simplegui.create_frame("The Painter", WIDTH, HEIGHT)
frame.set_canvas_background("white")

frame.add_button("circle",draw_circle,100)
frame.add_button("square", draw_square,100)
frame.add_button("triangle", draw_triangle,100)
frame.add_button("lightgrey", paint_lightgrey,100)
frame.add_button("silver", paint_silver,100)
frame.add_button("blue", paint_blue,100)

#register event handlers
frame.set_draw_handler(draw)
frame.set_mouseclick_handler(click)

#start frame 
frame.start()




            
{'fraction_non_alphanumeric': 0.12425355994487827, 'fraction_numerical': 0.01929260450160772, 'mean_word_length': 4.221822541966427, 'pattern_counts': {'":': 7, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6575770', 'n_tokens_mistral': 1595, 'n_tokens_neox': 1502, 'n_words': 356}