kopia lustrzana https://github.com/villares/sketch-a-day
				
				
				
			
			
			
			
				main
			
			
		
		
							rodzic
							
								
									3150be81db
								
							
						
					
					
						commit
						dc07c0d9f2
					
				|  | @ -1,28 +1,30 @@ | |||
| """Grid study""" | ||||
| shapes = [] | ||||
| 
 | ||||
| def setup(): | ||||
|     size(500, 500) | ||||
|     rectMode(CENTER) | ||||
|     shapes.extend(grid(10, 12, 25, thing)) | ||||
|      | ||||
|     global shapes | ||||
|     shapes = grid(cols=10, | ||||
|                   rows=12, | ||||
|                   space=25, | ||||
|                   func=(create_element, 10)) | ||||
| 
 | ||||
| def draw(): | ||||
|     translate(width / 2, height / 2) | ||||
|     translate(width / 2., height / 2.) | ||||
|     rect(0, 0, 250, 300) | ||||
|     for s in shapes: | ||||
|         shape(s) | ||||
|          | ||||
| 
 | ||||
| def grid(cols, rows, space, func): | ||||
|     result = [] | ||||
|     half_w = -cols * space / 2. | ||||
|     half_h = -rows * space / 2. | ||||
|     half_w = cols * space / 2. | ||||
|     half_h = rows * space / 2. | ||||
|     for ix in range(cols): | ||||
|         x = half_w + ix * space + space / 2 | ||||
|         x = ix * space + space / 2. - half_w | ||||
|         for iy in range(rows): | ||||
|             y = half_h + iy * space + space / 2 | ||||
|             result.append(func(x, y)) | ||||
|             y = iy * space + space / 2. - half_h | ||||
|             result.append(func[0](x, y, *func[1:])) | ||||
|     return result | ||||
|          | ||||
| def thing(x=0, y=0, w=10, h=10): | ||||
|     t = createShape(ELLIPSE, x, y, w, h) | ||||
|     return t | ||||
| 
 | ||||
| def create_element(x, y, *args): | ||||
|     return createShape(ELLIPSE, x, y, args[0], args[0]) | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 villares
						villares