| 
									
										
										
										
											2019-04-15 00:07:51 +00:00
										 |  |  | # Alexandre B A Villares - https://abav.lugaralgum.com/sketch-a-day | 
					
						
							|  |  |  | """ | 
					
						
							| 
									
										
										
										
											2019-04-16 02:57:50 +00:00
										 |  |  | Unfold extrusion | 
					
						
							| 
									
										
										
										
											2019-04-15 00:07:51 +00:00
										 |  |  | """ | 
					
						
							|  |  |  | add_library('GifAnimation') | 
					
						
							|  |  |  | from gif_exporter import gif_export | 
					
						
							|  |  |  | from parts import Face | 
					
						
							|  |  |  | from glue_tab import glue_tab | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | faces = [] | 
					
						
							|  |  |  | THICK = 20 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def setup(): | 
					
						
							|  |  |  |     size(740, 480, P3D) | 
					
						
							|  |  |  |     zig = [(2.5, 3.5), (5.5, 3.5), (2.5, 5.5), | 
					
						
							|  |  |  |            (5.5, 5.5), (2.5, 7.5), (5.5, 7.5), | 
					
						
							|  |  |  |            (3.5, 9.5), (8.5, 6.5), (5.5, 6.5), | 
					
						
							|  |  |  |            (8.5, 4.5), (5.5, 4.5), (8.5, 2.5), | 
					
						
							|  |  |  |            (5.5, 2.5), (7.5, 0.5)] | 
					
						
							|  |  |  |     faces.append(Face(zig, THICK)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def draw(): | 
					
						
							|  |  |  |     background(200, 210, 220) | 
					
						
							|  |  |  |     for f in faces: | 
					
						
							|  |  |  |         f.draw_3D(frameCount / -50.) | 
					
						
							|  |  |  |         translate(200, 0) | 
					
						
							| 
									
										
										
										
											2019-04-15 00:12:12 +00:00
										 |  |  |         fill(170) | 
					
						
							| 
									
										
										
										
											2019-04-15 00:07:51 +00:00
										 |  |  |         f.draw_2D() | 
					
						
							|  |  |  |         translate(200, 0) | 
					
						
							| 
									
										
										
										
											2019-04-15 00:12:12 +00:00
										 |  |  |         fill(230) | 
					
						
							| 
									
										
										
										
											2019-04-15 00:07:51 +00:00
										 |  |  |         f.draw_2D() | 
					
						
							|  |  |  |         x, y = 25, 350 | 
					
						
							|  |  |  |         translate(-400, 0) | 
					
						
							|  |  |  |         for p1, p2 in f.edges(): | 
					
						
							|  |  |  |             d = dist(p1[0], p1[1], p2[0], p2[1]) * 35 | 
					
						
							| 
									
										
										
										
											2019-04-15 00:12:12 +00:00
										 |  |  |             fill(250) | 
					
						
							| 
									
										
										
										
											2019-04-15 00:07:51 +00:00
										 |  |  |             glue_tab((x, y), (x + d, y)) | 
					
						
							|  |  |  |             glue_tab((x + d, y + THICK),( x, y + THICK)) | 
					
						
							|  |  |  |             rect(x, y , d, THICK) | 
					
						
							|  |  |  |             x += d | 
					
						
							|  |  |  |             if x > width - d: | 
					
						
							|  |  |  |                 glue_tab((x, y), (x, y + THICK)) | 
					
						
							|  |  |  |                 x = 25 | 
					
						
							|  |  |  |                 y += THICK * 2.2 | 
					
						
							|  |  |  |         else: # a for else... | 
					
						
							|  |  |  |             glue_tab((x, y), (x, y + THICK)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if frameCount/50. < TWO_PI: | 
					
						
							|  |  |  |         if frameCount % 2: | 
					
						
							|  |  |  |             gif_export(GifMaker, filename=SKETCH_NAME) | 
					
						
							|  |  |  |     else: | 
					
						
							|  |  |  |         exit() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # print text to add to the project's README.md | 
					
						
							|  |  |  | def settings(): | 
					
						
							|  |  |  |     from os import path | 
					
						
							|  |  |  |     global SKETCH_NAME | 
					
						
							|  |  |  |     SKETCH_NAME = path.basename(sketchPath()) | 
					
						
							|  |  |  |     OUTPUT = ".gif" | 
					
						
							|  |  |  |     println( | 
					
						
							|  |  |  |         """ | 
					
						
							|  |  |  |  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-19 00:23:34 +00:00
										 |  |  | [{0}](https://github.com/villares/sketch-a-day/tree/master/2019/{0}) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)] | 
					
						
							| 
									
										
										
										
											2019-04-15 00:07:51 +00:00
										 |  |  | """.format(SKETCH_NAME, OUTPUT) | 
					
						
							|  |  |  |     ) |