Example #1
0
 def erosion(self, other):
     ext1 = self.extent()
     ext2 = other.extent()
     #Generous margin
     r = max(abs(item) for item in list(ext1)+list(ext2))
     inner_loop = shape.square(r*3)
     outer_loop = shape.square(r*5)
     
     negative = outer_loop.shape_2()
     negative.remove(self)
     dilation = negative.minkowski_sum(other)
     result = inner_loop.shape_2()
     result.remove(dilation)
     return result
Example #2
0
    def erosion(self, other):
        ext1 = self.extent()
        ext2 = other.extent()
        #Generous margin
        r = max(abs(item) for item in list(ext1) + list(ext2))
        inner_loop = shape.square(r * 3)
        outer_loop = shape.square(r * 5)

        negative = outer_loop.shape_2()
        negative.remove(self)
        dilation = negative.minkowski_sum(other)
        result = inner_loop.shape_2()
        result.remove(dilation)
        return result
Example #3
0
def main():
    print(list(set([11, 22, 33, 44, 11, 22])))
    defaultshape = sp.shape()
    if (isinstance(defaultshape, sp.shape)):
        print('default area is {}'.format(defaultshape.area()))

    squareshape = sp.square(5)
    if (isinstance(squareshape, sp.shape)):
        print('Square area is {}'.format(squareshape.area()))

    c1 = cn.ComplexNumber(4, 2)
    c2 = cn.ComplexNumber(5, 3)

    c3 = c1.add(c2)
    #print("Complex Number {}+i{}".format(c3.real, c3.complex))
    print('Sum is {}'.format(c3))
import shape
import turtle

screen = turtle.Screen()
alex = turtle.Turtle()

shape.square(alex, 120)

shape.rectangle(alex, 80, 40)

shape.octagon(alex, 20)

alex.up()
alex.forward(-150)
alex.down()

shape.square(alex, 80)

screen.exitonclick()
Example #5
0
 def setUp(self):
     self.sea = Battlefield(Vec2D(6, 6))
     terrain = [Vec2D(1, 1), Vec2D(-1, -1)]
     self.sea2 = Battlefield(Vec2D(6, 6), terrain)
     self.ship = Ship("Battle Criuser", line(5))
     self.ship2 = Ship("Carrier", square(3))
Example #6
0
 def test_square(self):
     expected = [Vec2D(0, 0), Vec2D(0, 1), Vec2D(1, 0), Vec2D(1, 1)]
     must_be_equal(set(expected), set(square(2).coords))
import shape

if __name__ == '__main__':

    cerchio = shape.circle(10)
    pentagono = shape.pentagons(5)
    rettangolo = shape.rectangle(5,2)
    quadrato = shape.square(2)
    triangolo = shape.triangoloeq(3)
    listOfShapes = [cerchio, pentagono, rettangolo, quadrato, triangolo]
    print(listOfShapes)
    print(cerchio.calculate_area(), pentagono.calculate_area(), rettangolo.calculate_area(), quadrato.calculate_area(), triangolo.calculate_area())
    print([x.calculate_area() for x in  shape.shape.sortarea(listOfShapes)])