kopia lustrzana https://github.com/villares/sketch-a-day
				
				
				
			
			
			
			
				main
			
			
		
		
							rodzic
							
								
									d4e83f81e2
								
							
						
					
					
						commit
						603c6ae31c
					
				
										
											Plik binarny nie jest wyświetlany.
										
									
								
							| Po Szerokość: | Wysokość: | Rozmiar: 118 KiB | 
|  | @ -0,0 +1,41 @@ | |||
| def setup(): | ||||
|     size(500, 500) | ||||
|     rectMode(CENTER) | ||||
|     translate(width / 2, height / 2) | ||||
|     # grid(10, 10, 45, elem_1234) | ||||
|     grid(10, 10, 45, elem_1234, rule_1234) | ||||
| 
 | ||||
| def grid(cols, rows, spacing, element, rule=lambda *args: None): | ||||
|     wid, hei = cols * spacing, rows * spacing | ||||
|     for i in range(cols): | ||||
|         x = spacing / 2. + i * spacing - wid / 2. | ||||
|         for j in range(rows): | ||||
|             y = spacing / 2. + j * spacing - hei / 2. | ||||
|             element(x, y, rule(i, j, cols, rows, spacing)) | ||||
| 
 | ||||
| def rule_1234(i, j, cols, rows, spacing): | ||||
|     """ border and chess """ | ||||
|     w, h = cols - 1, rows - 1 | ||||
|     if i == 0 or i == w or j == 0 or j == h: | ||||
|         c = color(255) | ||||
|     else: | ||||
|         c = color(0) | ||||
|     if (i + j) % 3 == 0: | ||||
|         rot = 0 | ||||
|     else: | ||||
|         rot = QUARTER_PI | ||||
|     siz = spacing / (1.02 + (i + j) % 2) | ||||
|     return c, rot, siz | ||||
| 
 | ||||
| def elem_1234(x, y, args): | ||||
|     if args != None: | ||||
|         c, rot, siz = args | ||||
|     else: | ||||
|         c, rot, siz = 0, 0, 40 | ||||
|     noStroke() | ||||
|     fill(c) | ||||
|     pushMatrix() | ||||
|     translate(x, y) | ||||
|     rotate(rot) | ||||
|     rect(0, 0, siz, siz) | ||||
|     popMatrix() | ||||
|  | @ -20,6 +20,12 @@ You may also support my artistic work, open teaching resources and research with | |||
| 
 | ||||
| --- | ||||
| 
 | ||||
|  | ||||
| 
 | ||||
| [sketch_190818a](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190818a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)] | ||||
| 
 | ||||
| --- | ||||
| 
 | ||||
|  | ||||
| 
 | ||||
| [sketch_190817a](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190817a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)] | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Alexandre B A Villares
						Alexandre B A Villares