Python お絵描きツールで必要なクラス
class SimpleCircle:
def __init__(self,x,y,wid,len,color):
self.y = x
self.x = y
self.wid = wid
self.len = len
self.color = color
def draw(self,canvas):
print("drawメソッドによる描画処理");
x1 = self.x - self.wid/2
y1 = self.y - self.len/2
canvas.create_oval(x1,y1,x1 + self.wid, y1 + self.len, outline = self.color)
class SimpleRectangle:
def __init__(self,x,y,wid,len,color):
self.y = x
self.x = y
self.wid = wid
self.len = len
self.color = color
def draw(self,canvas):
print("drawメソッドによる描画処理");
x1 = self.x - self.wid/2
y1 = self.y - self.len/2
canvas.create_rectangle(x1,y1,x1 + self.wid, y1 + self.len, outline = self.color)
class Shape:
def __init__(self,x,y,wid,len,color):
self.x = x
self.y = y
self.wid = wid
self.len = len
self.color = color
from Shape import Shape
class Circle(Shape):
def draw(self,canvas):
print("Circleクラスのdrawメソッドによる描画処理")
x1 = self.x-self.wid/2
y1 = self.y-self.len/2
canvas.create_oval(x1,y1,x1+self.wid,y1+self.len,outline=self.color)
from Shape import Shape
class Line(Shape):
def draw(self,canvas):
print("Lineクラスのdrawメソッドによる描画処理")
x1 = self.x-self.wid/2
y1 = self.y-self.len/2
canvas.create_line(x1,y1,x1+self.wid,y1+self.len,fill=self.color)
from Shape import Shape
class Rectangle(Shape):
def draw(self,canvas):
print("Rectangleクラスのdrawメソッドによる描画処理")
x1 = self.x-self.wid/2
y1 = self.y-self.len/2
canvas.create_rectangle(x1,y1,x1+self.wid,y1+self.len,outline=self.color)