This commit is contained in:
Ian Jauslin 2021-11-24 22:46:47 -05:00
parent 7ea7b56556
commit cf80682890
2 changed files with 32 additions and 2 deletions

View File

@ -4,7 +4,7 @@ from kivy.uix.widget import Widget
from kivy.core.window import Window
from point import Point
from polyomino import Square
from polyomino import Cross
from polyomino import Square_element
from tools import remove_fromlist
@ -81,7 +81,7 @@ class Painter(Widget):
# create new cross
if touch.button=="right":
new=Square(touch.x/Square_element.size,touch.y/Square_element.size)
new=Cross(touch.x/Square_element.size,touch.y/Square_element.size)
if not self.check_interaction_any(new,Point(0,0)):
# add to list
self.particles.append(new)

View File

@ -68,6 +68,36 @@ class Square(Polyomino):
def __init__(self,x,y,**kwargs):
super(Square,self).__init__(**kwargs,squares=[Square_element(x,y)])
# cross
class Cross(Polyomino):
def __init__(self,x,y,**kwargs):
super(Cross,self).__init__(**kwargs,squares=[\
Square_element(x,y),\
Square_element(x+1,y),\
Square_element(x-1,y),\
Square_element(x,y+1),\
Square_element(x,y-1)\
])
# redefine stroke to avoid lines between touching squares
def stroke(self):
Color(1,1,1)
Line(points=(
*((self.squares[0].pos.x-0.5)*Square_element.size,(self.squares[0].pos.y-0.5)*Square_element.size),
*((self.squares[0].pos.x-0.5)*Square_element.size,(self.squares[0].pos.y-1.5)*Square_element.size),
*((self.squares[0].pos.x+0.5)*Square_element.size,(self.squares[0].pos.y-1.5)*Square_element.size),
*((self.squares[0].pos.x+0.5)*Square_element.size,(self.squares[0].pos.y-0.5)*Square_element.size),
*((self.squares[0].pos.x+1.5)*Square_element.size,(self.squares[0].pos.y-0.5)*Square_element.size),
*((self.squares[0].pos.x+1.5)*Square_element.size,(self.squares[0].pos.y+0.5)*Square_element.size),
*((self.squares[0].pos.x+0.5)*Square_element.size,(self.squares[0].pos.y+0.5)*Square_element.size),
*((self.squares[0].pos.x+0.5)*Square_element.size,(self.squares[0].pos.y+1.5)*Square_element.size),
*((self.squares[0].pos.x-0.5)*Square_element.size,(self.squares[0].pos.y+1.5)*Square_element.size),
*((self.squares[0].pos.x-0.5)*Square_element.size,(self.squares[0].pos.y+0.5)*Square_element.size),
*((self.squares[0].pos.x-1.5)*Square_element.size,(self.squares[0].pos.y+0.5)*Square_element.size),
*((self.squares[0].pos.x-1.5)*Square_element.size,(self.squares[0].pos.y-0.5)*Square_element.size),
*((self.squares[0].pos.x-0.5)*Square_element.size,(self.squares[0].pos.y-0.5)*Square_element.size),
))
# square building block of polyominos