From 61eba783b985d970fde3e7dc3d6c69fef1c1ccfe Mon Sep 17 00:00:00 2001 From: Alexandre B A Villares Date: Tue, 9 Jan 2018 19:34:34 -0200 Subject: [PATCH] Update PlatonicSolids.py --- s180108_liveEdu/PlatonicSolids.py | 32 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/s180108_liveEdu/PlatonicSolids.py b/s180108_liveEdu/PlatonicSolids.py index 16b4936e..1a61c312 100644 --- a/s180108_liveEdu/PlatonicSolids.py +++ b/s180108_liveEdu/PlatonicSolids.py @@ -1,21 +1,17 @@ -from functools import partial +def PlatonicFactory(type_=0, size_=None): + classes = {0: Tetrahedron, + 1: Hexahedron, + 2: Octahedron, + 3: Dodecahedron, + 4: Icosahedron, + } + default_sizes = {0: 36, 1: 28, 2: 44, 3: 36, 4: 36} + if size_: + solid_size = size_ + else: + solid_size = default_sizes[type_] -def PlatonicFactory(type): - s = Tetrahedron(18*2) - if type == 1: - s = Hexahedron(14*2) - elif type == 2: - s = Octahedron(22*2) - elif type == 3: - s = Dodecahedron(18*2) - elif type == 4: - s = Icosahedron(18*2) - - def platotonic_s(self): - stroke(self.c) - s.platonic_stroke = partial(platotonic_s, s) - - return s + return classes[type_](solid_size) class Tetrahedron(): @@ -275,4 +271,4 @@ class Dodecahedron(): vertex(self.vert[self.faces[i][j]].x, self.vert[self.faces[i][j]].y, self.vert[self.faces[i][j]].z) - endShape() \ No newline at end of file + endShape()