kopia lustrzana https://github.com/villares/sketch-a-day
				
				
				
			sketch 8 + GIF
							rodzic
							
								
									41d8fae265
								
							
						
					
					
						commit
						c1d818aa2a
					
				| 
						 | 
				
			
			@ -4,9 +4,11 @@
 | 
			
		|||
 | 
			
		||||
Hi! I'm [Alexandre Villares](https://abav.lugaralgum.com), let's see if I can make one small program (*sketch*) a day.
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
#### 007: [s180107](https://github.com/villares/sketch-a-day/tree/master/s180107) [[Processing Java](https://www.processing.org)]  Colorful grid of Platonic Solids in Java Mode [GIF](s180107/s180107.gif)
 | 
			
		||||
#### 008: [s180108](https://github.com/villares/sketch-a-day/tree/master/s180108)  [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]   Grid of Platonic Solids in Python Mode [GIF](s180108/s180108.gif)
 | 
			
		||||
 | 
			
		||||
007: [s180107](https://github.com/villares/sketch-a-day/tree/master/s180107) [[Processing Java](https://www.processing.org)]  Another grid of Platonic Solids in Java Mode [GIF](s180107/s180107.gif)
 | 
			
		||||
 | 
			
		||||
006: [s180106](https://github.com/villares/sketch-a-day/tree/master/s180106) [[Processing Java](https://www.processing.org)]  Grid of Platonic Solids in Java Mode  [GIF](s180106/s180106.gif)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Plik binarny nie jest wyświetlany.
										
									
								
							| 
						 | 
				
			
			@ -1,11 +1,127 @@
 | 
			
		|||
from functools import partial
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
class Tetrahedron():
 | 
			
		||||
        
 | 
			
		||||
    def __init__(self, radius):
 | 
			
		||||
        self.vert = [0] * 4
 | 
			
		||||
        self.radius = radius
 | 
			
		||||
        a = radius * 0.6666
 | 
			
		||||
        self.vert[0] = PVector(a, a, a)    
 | 
			
		||||
        self.vert[1] = PVector(-a, -a, a)        
 | 
			
		||||
        self.vert[2] = PVector(-a, a, -a)    
 | 
			
		||||
        self.vert[3] = PVector(a, -a, -a)     
 | 
			
		||||
    
 | 
			
		||||
    # draws tetrahedron
 | 
			
		||||
    def create(self):
 | 
			
		||||
        vert = self.vert
 | 
			
		||||
        beginShape(TRIANGLE_STRIP)
 | 
			
		||||
        vertex(vert[0].x, vert[0].y, vert[0].z)    
 | 
			
		||||
        vertex(vert[1].x, vert[1].y, vert[1].z)        
 | 
			
		||||
        vertex(vert[2].x, vert[2].y, vert[2].z)    
 | 
			
		||||
        vertex(vert[3].x, vert[3].y, vert[3].z)     
 | 
			
		||||
        vertex(vert[0].x, vert[0].y, vert[0].z)    
 | 
			
		||||
        vertex(vert[1].x, vert[1].y, vert[1].z)        
 | 
			
		||||
        vertex(vert[3].x, vert[3].y, vert[3].z)     
 | 
			
		||||
        vertex(vert[2].x, vert[2].y, vert[2].z)    
 | 
			
		||||
        vertex(vert[1].x, vert[1].y, vert[1].z)        
 | 
			
		||||
        endShape(CLOSE)
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
class Hexahedron():
 | 
			
		||||
 | 
			
		||||
    def __init__(self, radius) :
 | 
			
		||||
        self.radius = radius
 | 
			
		||||
        a = radius/1.1414
 | 
			
		||||
        faces = [0] * 6
 | 
			
		||||
        vert = [0] * 8
 | 
			
		||||
        vert[0] = PVector(  a, a, a )
 | 
			
		||||
        vert[1] = PVector(  a, a, -a )
 | 
			
		||||
        vert[2] = PVector(  a, -a, -a )
 | 
			
		||||
        vert[3] = PVector(  a, -a, a )
 | 
			
		||||
        vert[4] = PVector( -a, -a, a )
 | 
			
		||||
        vert[5] = PVector( -a, a, a )
 | 
			
		||||
        vert[6] = PVector( -a, a, -a )
 | 
			
		||||
        vert[7] = PVector( -a, -a, -a )
 | 
			
		||||
 | 
			
		||||
        faces[0] = (0, 1, 2, 3)
 | 
			
		||||
        faces[1] = (4, 5, 6, 7)
 | 
			
		||||
        faces[2] = (0, 3, 4, 5)
 | 
			
		||||
        faces[3] = (1, 2, 7, 6)
 | 
			
		||||
        faces[4] = (2, 3, 4, 7)
 | 
			
		||||
        faces[5] = (0, 5, 6, 1)
 | 
			
		||||
         
 | 
			
		||||
        self.vert, self.faces = vert, faces
 | 
			
		||||
 | 
			
		||||
    # draws hexahedron 
 | 
			
		||||
    def create(self): 
 | 
			
		||||
        for i in range(6):
 | 
			
		||||
            beginShape()
 | 
			
		||||
            for j in range(4):
 | 
			
		||||
                vertex(self.vert[self.faces[i][j]].x,
 | 
			
		||||
                       self.vert[self.faces[i][j]].y,
 | 
			
		||||
                       self.vert[self.faces[i][j]].z)
 | 
			
		||||
            endShape()
 | 
			
		||||
        
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Octahedron():
 | 
			
		||||
 | 
			
		||||
    def __init__(self, radius) :
 | 
			
		||||
        self.radius = radius
 | 
			
		||||
        a = radius
 | 
			
		||||
        vert = [0] * 6
 | 
			
		||||
        vert[0] = PVector( a, 0, 0 ) 
 | 
			
		||||
        vert[1] = PVector( 0, a, 0 )
 | 
			
		||||
        vert[2] = PVector( 0, 0, a ) 
 | 
			
		||||
        vert[3] = PVector( -a, 0, 0 ) 
 | 
			
		||||
        vert[4] = PVector( 0, -a, 0 ) 
 | 
			
		||||
        vert[5] = PVector( 0, 0, -a )
 | 
			
		||||
        self.vert = vert
 | 
			
		||||
 | 
			
		||||
    # draws octahedron 
 | 
			
		||||
    def create(self):
 | 
			
		||||
        vert = self.vert
 | 
			
		||||
        beginShape(TRIANGLE_FAN) 
 | 
			
		||||
        vertex(vert[4].x, vert[4].y, vert[4].z)
 | 
			
		||||
        vertex(vert[0].x, vert[0].y, vert[0].z)
 | 
			
		||||
        vertex(vert[2].x, vert[2].y, vert[2].z)
 | 
			
		||||
        vertex(vert[3].x, vert[3].y, vert[3].z)
 | 
			
		||||
        vertex(vert[5].x, vert[5].y, vert[5].z)
 | 
			
		||||
        vertex(vert[0].x, vert[0].y, vert[0].z)
 | 
			
		||||
        endShape()
 | 
			
		||||
 | 
			
		||||
        beginShape(TRIANGLE_FAN)        
 | 
			
		||||
        vertex(vert[1].x, vert[1].y, vert[1].z)
 | 
			
		||||
        vertex(vert[0].x, vert[0].y, vert[0].z)
 | 
			
		||||
        vertex(vert[2].x, vert[2].y, vert[2].z)
 | 
			
		||||
        vertex(vert[3].x, vert[3].y, vert[3].z)
 | 
			
		||||
        vertex(vert[5].x, vert[5].y, vert[5].z)
 | 
			
		||||
        vertex(vert[0].x, vert[0].y, vert[0].z)
 | 
			
		||||
        endShape()
 | 
			
		||||
 | 
			
		||||
class Icosahedron():
 | 
			
		||||
 | 
			
		||||
    def __init__(self, radius):
 | 
			
		||||
        topPent = [PVector()] * 5  # PVector[5]
 | 
			
		||||
        bottomPent = [PVector()] * 5  # PVector[5]
 | 
			
		||||
        topPent = [0] * 5  # PVector[5]
 | 
			
		||||
        bottomPent = [0] * 5  # PVector[5]
 | 
			
		||||
        angle = 0
 | 
			
		||||
        c = dist(cos(0) * radius,
 | 
			
		||||
                 sin(0) * radius,
 | 
			
		||||
| 
						 | 
				
			
			@ -106,4 +222,57 @@ class Icosahedron():
 | 
			
		|||
                vertex(bottomPent[1].x, bottomPent[1].y, bottomPent[1].z)
 | 
			
		||||
                vertex(topPent[i].x, topPent[i].y, topPent[i].z)
 | 
			
		||||
                vertex(topPent[0].x, topPent[0].y, topPent[0].z)
 | 
			
		||||
                endShape(CLOSE)
 | 
			
		||||
                endShape(CLOSE)
 | 
			
		||||
 | 
			
		||||
class Dodecahedron():
 | 
			
		||||
    def __init__(self, radius):
 | 
			
		||||
        self.radius = radius
 | 
			
		||||
        a = radius / 1.618033989
 | 
			
		||||
        b = radius
 | 
			
		||||
        c = 0.618033989 * a
 | 
			
		||||
        faces = [0] * 12
 | 
			
		||||
        vert = [0] * 20
 | 
			
		||||
        vert[0] = PVector(a, a, a)
 | 
			
		||||
        vert[1] = PVector(a, a, -a)
 | 
			
		||||
        vert[2] = PVector(a, -a, a)
 | 
			
		||||
        vert[3] = PVector(a, -a, -a)
 | 
			
		||||
        vert[4] = PVector(-a, a, a)
 | 
			
		||||
        vert[5] = PVector(-a, a, -a)
 | 
			
		||||
        vert[6] = PVector(-a, -a, a)
 | 
			
		||||
        vert[7] = PVector(-a, -a, -a)
 | 
			
		||||
        vert[8] = PVector(0, c, b)
 | 
			
		||||
        vert[9] = PVector(0, c, -b)
 | 
			
		||||
        vert[10] = PVector(0, -c, b)
 | 
			
		||||
        vert[11] = PVector(0, -c, -b)
 | 
			
		||||
        vert[12] = PVector(c, b, 0)
 | 
			
		||||
        vert[13] = PVector(c, -b, 0)
 | 
			
		||||
        vert[14] = PVector(-c, b, 0)
 | 
			
		||||
        vert[15] = PVector(-c, -b, 0)
 | 
			
		||||
        vert[16] = PVector(b, 0, c)
 | 
			
		||||
        vert[17] = PVector(b, 0, -c)
 | 
			
		||||
        vert[18] = PVector(-b, 0, c)
 | 
			
		||||
        vert[19] = PVector(-b, 0, -c)
 | 
			
		||||
 | 
			
		||||
        faces[0] = (0, 16, 2, 10, 8)
 | 
			
		||||
        faces[1] = (0, 8, 4, 14, 12)
 | 
			
		||||
        faces[2] = (16, 17, 1, 12, 0)
 | 
			
		||||
        faces[3] = (1, 9, 11, 3, 17)
 | 
			
		||||
        faces[4] = (1, 12, 14, 5, 9)
 | 
			
		||||
        faces[5] = (2, 13, 15, 6, 10)
 | 
			
		||||
        faces[6] = (13, 3, 17, 16, 2)
 | 
			
		||||
        faces[7] = (3, 11, 7, 15, 13)
 | 
			
		||||
        faces[8] = (4, 8, 10, 6, 18)
 | 
			
		||||
        faces[9] = (14, 5, 19, 18, 4)
 | 
			
		||||
        faces[10] = (5, 19, 7, 11, 9)
 | 
			
		||||
        faces[11] = (15, 7, 19, 18, 6)
 | 
			
		||||
        self.faces, self.vert = faces, vert
 | 
			
		||||
 | 
			
		||||
    # draws dodecahedron
 | 
			
		||||
    def create(self):
 | 
			
		||||
        for i in range(12):
 | 
			
		||||
            beginShape()
 | 
			
		||||
            for j in range(5):
 | 
			
		||||
                vertex(self.vert[self.faces[i][j]].x,
 | 
			
		||||
                       self.vert[self.faces[i][j]].y,
 | 
			
		||||
                       self.vert[self.faces[i][j]].z)
 | 
			
		||||
            endShape()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Plik binarny nie jest wyświetlany.
										
									
								
							| 
		 Po Szerokość: | Wysokość: | Rozmiar: 27 KiB  | 
| 
						 | 
				
			
			@ -14,9 +14,10 @@ def setup():
 | 
			
		|||
    noFill()
 | 
			
		||||
    colorMode(HSB)
 | 
			
		||||
    for i in range(NUM_CELLS):
 | 
			
		||||
        s = Icosahedron(CELL_SIZE / 2.5)
 | 
			
		||||
        s = PlatonicFactory(int(random(5)))
 | 
			
		||||
        c = color(random(256), 200, 200, 128)  # random HSB translucent colors
 | 
			
		||||
        solids.append((s, c))  # (solid, color)
 | 
			
		||||
        s.c = c # tasca uma cor no sólido! mas ele mesmo não sabe usar
 | 
			
		||||
        solids.append(s)
 | 
			
		||||
 | 
			
		||||
def draw():
 | 
			
		||||
    global r_x, r_y
 | 
			
		||||
| 
						 | 
				
			
			@ -34,9 +35,10 @@ def draw():
 | 
			
		|||
            if d < 80:
 | 
			
		||||
                rotateX(r_y)
 | 
			
		||||
                rotateY(r_x)
 | 
			
		||||
            stroke(solids[i][1])
 | 
			
		||||
            solids[i][0].create()
 | 
			
		||||
    # if (frameCouNUM_CELLS < 200): saveFrame("###.tga")
 | 
			
		||||
            # cuidado, só nos sólidos criados pela Factory
 | 
			
		||||
            solids[i].platonic_stroke()
 | 
			
		||||
            solids[i].create()
 | 
			
		||||
    if (frameCount < 200): saveFrame("###.tga")
 | 
			
		||||
 | 
			
		||||
def x_y_from_i(i, max_x, max_y):
 | 
			
		||||
    return i % max_x, (i / max_x) % max_y
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,203 +0,0 @@
 | 
			
		|||
 | 
			
		||||
def PlatonicFactory(type, c):
 | 
			
		||||
  if type == 0:
 | 
			
		||||
    s = Tetrahedron(18)
 | 
			
		||||
  elif type == 1:
 | 
			
		||||
    s = Hexahedron(14)
 | 
			
		||||
  elif type == 2:
 | 
			
		||||
    s = Octahedron(22)
 | 
			
		||||
  elif type == 3:
 | 
			
		||||
    s = Dodecahedron(18)
 | 
			
		||||
  elif type == 4:
 | 
			
		||||
    s = Icosahedron(18)
 | 
			
		||||
  s.c = c  # sets a color attribute
 | 
			
		||||
 | 
			
		||||
  def newCreate(obj):
 | 
			
		||||
      fill(obj.c)
 | 
			
		||||
      obj.create()
 | 
			
		||||
  s.create = newCreate
 | 
			
		||||
  return s
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Tetrahedron():
 | 
			
		||||
    
 | 
			
		||||
  def __init__(radius):
 | 
			
		||||
    self.vert = [PVector] * 4
 | 
			
		||||
    self.radius = radius
 | 
			
		||||
    a = radius * 0.6666
 | 
			
		||||
    self.vert[0] = PVector(a, a, a)  # vertex 1
 | 
			
		||||
    self.vert[1] = PVector(-a, -a, a)    # vertex 2
 | 
			
		||||
    self.vert[2] = PVector(-a, a, -a)  # vertex 3
 | 
			
		||||
    self.vert[3] = PVector(a, -a, -a)   # vertex 4
 | 
			
		||||
  
 | 
			
		||||
  # draws tetrahedron
 | 
			
		||||
  def create():
 | 
			
		||||
    super.create()
 | 
			
		||||
    beginShape(TRIANGLE_STRIP)
 | 
			
		||||
    vertex(vert[0].x, vert[0].y, vert[0].z)  # vertex 1
 | 
			
		||||
    vertex(vert[1].x, vert[1].y, vert[1].z)    # vertex 2
 | 
			
		||||
    vertex(vert[2].x, vert[2].y, vert[2].z)  # vertex 3
 | 
			
		||||
    vertex(vert[3].x, vert[3].y, vert[3].z)   # vertex 4
 | 
			
		||||
    vertex(vert[0].x, vert[0].y, vert[0].z)  # vertex 1
 | 
			
		||||
    vertex(vert[1].x, vert[1].y, vert[1].z)    # vertex 2
 | 
			
		||||
    vertex(vert[3].x, vert[3].y, vert[3].z)   # vertex 4
 | 
			
		||||
    vertex(vert[2].x, vert[2].y, vert[2].z)  # vertex 3
 | 
			
		||||
    vertex(vert[1].x, vert[1].y, vert[1].z)    # vertex 2
 | 
			
		||||
    endShape(CLOSE)
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
class Hexahedron extends PlatonicSolid:
 | 
			
		||||
 | 
			
		||||
  # Tetrahedron
 | 
			
		||||
   x, y, z
 | 
			
		||||
   radius
 | 
			
		||||
   a
 | 
			
		||||
  PVector[] vert = PVector[8]
 | 
			
		||||
  [][] faces
 | 
			
		||||
 | 
			
		||||
  # constructor
 | 
			
		||||
  Hexahedron( radius) :
 | 
			
		||||
    self.radius = radius
 | 
			
		||||
 | 
			
		||||
    a = radius/1.1414
 | 
			
		||||
    faces = [6][4]
 | 
			
		||||
    vert[0] = PVector(  a, a, a )
 | 
			
		||||
    vert[1] = PVector(  a, a, -a )
 | 
			
		||||
    vert[2] = PVector(  a, -a, -a )
 | 
			
		||||
    vert[3] = PVector(  a, -a, a )
 | 
			
		||||
    vert[4] = PVector( -a, -a, a )
 | 
			
		||||
    vert[5] = PVector( -a, a, a )
 | 
			
		||||
    vert[6] = PVector( -a, a, -a )
 | 
			
		||||
    vert[7] = PVector( -a, -a, -a )
 | 
			
		||||
 | 
			
		||||
    faces[0] = [] :0, 1, 2, 3
 | 
			
		||||
    faces[1] = [] :4, 5, 6, 7
 | 
			
		||||
    faces[2] = [] :0, 3, 4, 5
 | 
			
		||||
    faces[3] = [] :1, 2, 7, 6
 | 
			
		||||
    faces[4] = [] :2, 3, 4, 7
 | 
			
		||||
    faces[5] = [] :0, 5, 6, 1
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # draws hexahedron 
 | 
			
		||||
  def create() : 
 | 
			
		||||
    super.create()
 | 
			
		||||
    for ( i=0 i<6 i++)
 | 
			
		||||
    :
 | 
			
		||||
      beginShape()
 | 
			
		||||
      for ( j=0 j<4 j++)
 | 
			
		||||
      :
 | 
			
		||||
        vertex(vert[faces[i][j]].x, vert[faces[i][j]].y, vert[faces[i][j]].z)
 | 
			
		||||
      
 | 
			
		||||
      endShape()
 | 
			
		||||
    
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Octahedron extends PlatonicSolid :
 | 
			
		||||
 | 
			
		||||
  # Octahedron
 | 
			
		||||
   x, y, z
 | 
			
		||||
   radius
 | 
			
		||||
 | 
			
		||||
   a
 | 
			
		||||
  PVector[] vert = PVector[6]
 | 
			
		||||
  [][] faces
 | 
			
		||||
 | 
			
		||||
  # constructor
 | 
			
		||||
  Octahedron( radius) :
 | 
			
		||||
    self.radius = radius
 | 
			
		||||
    a = radius
 | 
			
		||||
    vert[0] = PVector( a, 0, 0 ) 
 | 
			
		||||
    vert[1] = PVector( 0, a, 0 )
 | 
			
		||||
    vert[2] = PVector( 0, 0, a ) 
 | 
			
		||||
    vert[3] = PVector( -a, 0, 0 ) 
 | 
			
		||||
    vert[4] = PVector( 0, -a, 0 ) 
 | 
			
		||||
    vert[5] = PVector( 0, 0, -a )
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # draws octahedron 
 | 
			
		||||
  def create() :
 | 
			
		||||
    super.create()
 | 
			
		||||
    beginShape(TRIANGLE_FAN) 
 | 
			
		||||
    vertex(vert[4].x, vert[4].y, vert[4].z)
 | 
			
		||||
    vertex(vert[0].x, vert[0].y, vert[0].z)
 | 
			
		||||
    vertex(vert[2].x, vert[2].y, vert[2].z)
 | 
			
		||||
    vertex(vert[3].x, vert[3].y, vert[3].z)
 | 
			
		||||
    vertex(vert[5].x, vert[5].y, vert[5].z)
 | 
			
		||||
    vertex(vert[0].x, vert[0].y, vert[0].z)
 | 
			
		||||
    endShape()
 | 
			
		||||
 | 
			
		||||
    beginShape(TRIANGLE_FAN)    
 | 
			
		||||
    vertex(vert[1].x, vert[1].y, vert[1].z)
 | 
			
		||||
    vertex(vert[0].x, vert[0].y, vert[0].z)
 | 
			
		||||
    vertex(vert[2].x, vert[2].y, vert[2].z)
 | 
			
		||||
    vertex(vert[3].x, vert[3].y, vert[3].z)
 | 
			
		||||
    vertex(vert[5].x, vert[5].y, vert[5].z)
 | 
			
		||||
    vertex(vert[0].x, vert[0].y, vert[0].z)
 | 
			
		||||
    endShape()
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Dodecahedron extends PlatonicSolid :
 | 
			
		||||
  # Dodecahedron
 | 
			
		||||
   radius
 | 
			
		||||
   a, b, c
 | 
			
		||||
  PVector[] vert
 | 
			
		||||
  [][] faces
 | 
			
		||||
 | 
			
		||||
  # constructor
 | 
			
		||||
  Dodecahedron( radius) :
 | 
			
		||||
    self.radius = radius
 | 
			
		||||
    a = radius/1.618033989
 | 
			
		||||
    b = radius
 | 
			
		||||
    c = 0.618033989*a
 | 
			
		||||
    faces = [12][5]
 | 
			
		||||
    vert = PVector[20]
 | 
			
		||||
    vert[ 0] = PVector(a, a, a)
 | 
			
		||||
    vert[ 1] = PVector(a, a, -a)
 | 
			
		||||
    vert[ 2] = PVector(a, -a, a)
 | 
			
		||||
    vert[ 3] = PVector(a, -a, -a)
 | 
			
		||||
    vert[ 4] = PVector(-a, a, a)
 | 
			
		||||
    vert[ 5] = PVector(-a, a, -a)
 | 
			
		||||
    vert[ 6] = PVector(-a, -a, a)
 | 
			
		||||
    vert[ 7] = PVector(-a, -a, -a)
 | 
			
		||||
    vert[ 8] = PVector(0, c, b)
 | 
			
		||||
    vert[ 9] = PVector(0, c, -b)
 | 
			
		||||
    vert[10] = PVector(0, -c, b)
 | 
			
		||||
    vert[11] = PVector(0, -c, -b)
 | 
			
		||||
    vert[12] = PVector(c, b, 0)
 | 
			
		||||
    vert[13] = PVector(c, -b, 0)
 | 
			
		||||
    vert[14] = PVector(-c, b, 0)
 | 
			
		||||
    vert[15] = PVector(-c, -b, 0)
 | 
			
		||||
    vert[16] = PVector(b, 0, c)
 | 
			
		||||
    vert[17] = PVector(b, 0, -c)
 | 
			
		||||
    vert[18] = PVector(-b, 0, c)
 | 
			
		||||
    vert[19] = PVector(-b, 0, -c)
 | 
			
		||||
 | 
			
		||||
    faces[ 0] = [] :0, 16, 2, 10, 8
 | 
			
		||||
    faces[ 1] = [] :0, 8, 4, 14, 12
 | 
			
		||||
    faces[ 2] = [] :16, 17, 1, 12, 0
 | 
			
		||||
    faces[ 3] = [] :1, 9, 11, 3, 17
 | 
			
		||||
    faces[ 4] = [] :1, 12, 14, 5, 9
 | 
			
		||||
    faces[ 5] = [] :2, 13, 15, 6, 10
 | 
			
		||||
    faces[ 6] = [] :13, 3, 17, 16, 2
 | 
			
		||||
    faces[ 7] = [] :3, 11, 7, 15, 13
 | 
			
		||||
    faces[ 8] = [] :4, 8, 10, 6, 18
 | 
			
		||||
    faces[ 9] = [] :14, 5, 19, 18, 4
 | 
			
		||||
    faces[10] = [] :5, 19, 7, 11, 9
 | 
			
		||||
    faces[11] = [] :15, 7, 19, 18, 6
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # draws dodecahedron 
 | 
			
		||||
  def create() :
 | 
			
		||||
    super.create()
 | 
			
		||||
    for ( i=0 i<12 i++)
 | 
			
		||||
    :
 | 
			
		||||
      beginShape()
 | 
			
		||||
      for ( j=0 j<5 j++)
 | 
			
		||||
      :
 | 
			
		||||
        vertex(vert[faces[i][j]].x, vert[faces[i][j]].y, vert[faces[i][j]].z)
 | 
			
		||||
      
 | 
			
		||||
      endShape()
 | 
			
		||||
    
 | 
			
		||||
  
 | 
			
		||||
		Ładowanie…
	
		Reference in New Issue