Created
          June 10, 2021 19:11 
        
      - 
      
 - 
        
Save villares/bd5368842bdc307e7a105afe914577c2 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from __future__ import division | |
| def setup(): | |
| size(600, 600) | |
| def draw(): | |
| background(0) | |
| grid_elem = 10 | |
| spac_size = width / (grid_elem + 1) | |
| v = spac_size * 1.5 | |
| h = spac_size * sqrt(3) | |
| for ix in range(-1, grid_elem + 1): | |
| for iy in range(-1, grid_elem + 1): | |
| if iy % 2: | |
| fill(0, 200, 0) | |
| x = ix * h + h / 4.0 | |
| else: | |
| fill(0, 0, 200) | |
| x = ix * h - h / 4.0 | |
| es = spac_size - 1 | |
| y = iy * v | |
| hexagon(x, y, es, rot=1) # rot=1 gira 90 graus | |
| def hexagon(x, y, r, rot=0): | |
| pushMatrix() | |
| translate(x, y) | |
| beginShape() | |
| for i in range(6): | |
| sx = cos(i * TWO_PI / 6 + HALF_PI * rot) * r | |
| sy = sin(i * TWO_PI / 6 + HALF_PI * rot) * r | |
| vertex(sx, sy) | |
| endShape(CLOSE) | |
| popMatrix() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment