kopia lustrzana https://github.com/villares/sketch-a-day
				
				
				
			07_and_08
							rodzic
							
								
									993e5a8ed8
								
							
						
					
					
						commit
						bc4c80f103
					
				| 
						 | 
				
			
			@ -34,8 +34,9 @@ class Poly():
 | 
			
		|||
                    vertex(sx, sy)
 | 
			
		||||
                endContour()
 | 
			
		||||
            endShape(CLOSE)
 | 
			
		||||
        Poly.annotate_pts(self.outer_pts, color(200, 0, 0), 5)
 | 
			
		||||
        Poly.annotate_pts(self.holes[0], color(0, 0, 200), 5)
 | 
			
		||||
        if Poly.text_on:    
 | 
			
		||||
            Poly.annotate_pts(self.outer_pts, color(200, 0, 0), 5)
 | 
			
		||||
            Poly.annotate_pts(self.holes[0], color(0, 0, 200), 5)
 | 
			
		||||
        popStyle()
 | 
			
		||||
 | 
			
		||||
    def remove_pt(self):
 | 
			
		||||
| 
						 | 
				
			
			@ -68,7 +69,6 @@ class Poly():
 | 
			
		|||
    
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def annotate_pts(cls, pts, c, scale_m=1):
 | 
			
		||||
        if Poly.text_on:
 | 
			
		||||
            strokeWeight(5)
 | 
			
		||||
            textSize(12)
 | 
			
		||||
            fill(c)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Plik binarny nie jest wyświetlany.
										
									
								
							| 
		 Przed Szerokość: | Wysokość: | Rozmiar: 2.1 KiB  | 
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
class Glyph:
 | 
			
		||||
    w = 5  # width
 | 
			
		||||
    m = 8  # module
 | 
			
		||||
    m = 16  # module
 | 
			
		||||
    sw = 8 # stroke weight
 | 
			
		||||
    f = None # fill
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Plik binarny nie jest wyświetlany.
										
									
								
							| 
		 Po Szerokość: | Wysokość: | Rozmiar: 2.5 KiB  | 
| 
						 | 
				
			
			@ -19,7 +19,7 @@ def setup():
 | 
			
		|||
    project.append(LAB)
 | 
			
		||||
    a = silly.Glyph("a",
 | 
			
		||||
                    ((0, 4, 1), (4, 4, 1), (4, 0, 1),
 | 
			
		||||
                     (1, 0, 1), (0, 2, 1), (3.5, 2, 1), ),
 | 
			
		||||
                     (1, 0, 1), (0, 2, 1), (3.9, 2, 1), ),
 | 
			
		||||
                    (".012345:"))
 | 
			
		||||
    project.append(a)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,203 @@
 | 
			
		|||
(lp0
 | 
			
		||||
(ipoly
 | 
			
		||||
Poly
 | 
			
		||||
p1
 | 
			
		||||
(dp2
 | 
			
		||||
S'closed'
 | 
			
		||||
p3
 | 
			
		||||
I01
 | 
			
		||||
sS'lw'
 | 
			
		||||
p4
 | 
			
		||||
I1
 | 
			
		||||
sS'id'
 | 
			
		||||
p5
 | 
			
		||||
I0
 | 
			
		||||
sS'outer_pts'
 | 
			
		||||
p6
 | 
			
		||||
(lp7
 | 
			
		||||
(I-3
 | 
			
		||||
I-7
 | 
			
		||||
tp8
 | 
			
		||||
a(I-3
 | 
			
		||||
I-6
 | 
			
		||||
tp9
 | 
			
		||||
a(I-9
 | 
			
		||||
I-6
 | 
			
		||||
tp10
 | 
			
		||||
a(I-8
 | 
			
		||||
I-7
 | 
			
		||||
tp11
 | 
			
		||||
asS'holes'
 | 
			
		||||
p12
 | 
			
		||||
(lp13
 | 
			
		||||
(lp14
 | 
			
		||||
asba(ipoly
 | 
			
		||||
Poly
 | 
			
		||||
p15
 | 
			
		||||
(dp16
 | 
			
		||||
S'closed'
 | 
			
		||||
p17
 | 
			
		||||
I00
 | 
			
		||||
sS'lw'
 | 
			
		||||
p18
 | 
			
		||||
I5
 | 
			
		||||
sS'id'
 | 
			
		||||
p19
 | 
			
		||||
I1
 | 
			
		||||
sS'outer_pts'
 | 
			
		||||
p20
 | 
			
		||||
(lp21
 | 
			
		||||
(I6
 | 
			
		||||
I-3
 | 
			
		||||
tp22
 | 
			
		||||
a(I0
 | 
			
		||||
I-2
 | 
			
		||||
tp23
 | 
			
		||||
a(I0
 | 
			
		||||
I2
 | 
			
		||||
tp24
 | 
			
		||||
a(I6
 | 
			
		||||
I2
 | 
			
		||||
tp25
 | 
			
		||||
a(I6
 | 
			
		||||
I-7
 | 
			
		||||
tp26
 | 
			
		||||
a(I0
 | 
			
		||||
I-7
 | 
			
		||||
tp27
 | 
			
		||||
asS'holes'
 | 
			
		||||
p28
 | 
			
		||||
(lp29
 | 
			
		||||
(lp30
 | 
			
		||||
asba(ipoly
 | 
			
		||||
Poly
 | 
			
		||||
p31
 | 
			
		||||
(dp32
 | 
			
		||||
S'closed'
 | 
			
		||||
p33
 | 
			
		||||
I01
 | 
			
		||||
sS'lw'
 | 
			
		||||
p34
 | 
			
		||||
I1
 | 
			
		||||
sS'id'
 | 
			
		||||
p35
 | 
			
		||||
I0
 | 
			
		||||
sS'outer_pts'
 | 
			
		||||
p36
 | 
			
		||||
(lp37
 | 
			
		||||
(I-3
 | 
			
		||||
I-7
 | 
			
		||||
tp38
 | 
			
		||||
a(I-2
 | 
			
		||||
I-6
 | 
			
		||||
tp39
 | 
			
		||||
a(I-2
 | 
			
		||||
I-4
 | 
			
		||||
tp40
 | 
			
		||||
a(I-2
 | 
			
		||||
I2
 | 
			
		||||
tp41
 | 
			
		||||
a(I-3
 | 
			
		||||
I1
 | 
			
		||||
tp42
 | 
			
		||||
asS'holes'
 | 
			
		||||
p43
 | 
			
		||||
(lp44
 | 
			
		||||
(lp45
 | 
			
		||||
asba(ipoly
 | 
			
		||||
Poly
 | 
			
		||||
p46
 | 
			
		||||
(dp47
 | 
			
		||||
S'closed'
 | 
			
		||||
p48
 | 
			
		||||
I01
 | 
			
		||||
sS'lw'
 | 
			
		||||
p49
 | 
			
		||||
I1
 | 
			
		||||
sS'id'
 | 
			
		||||
p50
 | 
			
		||||
I0
 | 
			
		||||
sS'outer_pts'
 | 
			
		||||
p51
 | 
			
		||||
(lp52
 | 
			
		||||
(I-3
 | 
			
		||||
I-3
 | 
			
		||||
tp53
 | 
			
		||||
a(I-3
 | 
			
		||||
I-2
 | 
			
		||||
tp54
 | 
			
		||||
a(I-9
 | 
			
		||||
I-2
 | 
			
		||||
tp55
 | 
			
		||||
a(I-8
 | 
			
		||||
I-3
 | 
			
		||||
tp56
 | 
			
		||||
asS'holes'
 | 
			
		||||
p57
 | 
			
		||||
(lp58
 | 
			
		||||
(lp59
 | 
			
		||||
asba(ipoly
 | 
			
		||||
Poly
 | 
			
		||||
p60
 | 
			
		||||
(dp61
 | 
			
		||||
S'closed'
 | 
			
		||||
p62
 | 
			
		||||
I01
 | 
			
		||||
sS'lw'
 | 
			
		||||
p63
 | 
			
		||||
I1
 | 
			
		||||
sS'id'
 | 
			
		||||
p64
 | 
			
		||||
I0
 | 
			
		||||
sS'outer_pts'
 | 
			
		||||
p65
 | 
			
		||||
(lp66
 | 
			
		||||
(I-8
 | 
			
		||||
I2
 | 
			
		||||
tp67
 | 
			
		||||
a(I-9
 | 
			
		||||
I1
 | 
			
		||||
tp68
 | 
			
		||||
a(I-3
 | 
			
		||||
I1
 | 
			
		||||
tp69
 | 
			
		||||
a(I-4
 | 
			
		||||
I2
 | 
			
		||||
tp70
 | 
			
		||||
asS'holes'
 | 
			
		||||
p71
 | 
			
		||||
(lp72
 | 
			
		||||
(lp73
 | 
			
		||||
asba(ipoly
 | 
			
		||||
Poly
 | 
			
		||||
p74
 | 
			
		||||
(dp75
 | 
			
		||||
S'closed'
 | 
			
		||||
p76
 | 
			
		||||
I01
 | 
			
		||||
sS'lw'
 | 
			
		||||
p77
 | 
			
		||||
I1
 | 
			
		||||
sS'id'
 | 
			
		||||
p78
 | 
			
		||||
I0
 | 
			
		||||
sS'outer_pts'
 | 
			
		||||
p79
 | 
			
		||||
(lp80
 | 
			
		||||
(I-9
 | 
			
		||||
I1
 | 
			
		||||
tp81
 | 
			
		||||
a(I-9
 | 
			
		||||
I-2
 | 
			
		||||
tp82
 | 
			
		||||
a(I-8
 | 
			
		||||
I-2
 | 
			
		||||
tp83
 | 
			
		||||
a(I-8
 | 
			
		||||
I1
 | 
			
		||||
tp84
 | 
			
		||||
asS'holes'
 | 
			
		||||
p85
 | 
			
		||||
(lp86
 | 
			
		||||
(lp87
 | 
			
		||||
asba.
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,40 @@
 | 
			
		|||
"""
 | 
			
		||||
Alexandre B A Villares http://abav.lugaralgum.com - GPL v3 
 | 
			
		||||
 | 
			
		||||
A helper for the Processing gifAnimation library https://github.com/extrapixel/gif-animation/tree/3.0
 | 
			
		||||
Download from https://github.com/villares/processing-play/blob/master/export_GIF/unzip_and_move_to_libraries_GifAnimation.zip
 | 
			
		||||
This helper was inspired by an example by Art Simon https://github.com/APCSPrinciples/AnimatedGIF/
 | 
			
		||||
 | 
			
		||||
# add at the start of your sketch:
 | 
			
		||||
  add_library('gifAnimation')
 | 
			
		||||
  from gif_exporter import gif_export
 | 
			
		||||
# add at the end of draw():
 | 
			
		||||
  gif_export(GifMaker)
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
def gif_export(GifMaker,             # gets a reference to the library
 | 
			
		||||
               filename="exported",  # .gif will be added
 | 
			
		||||
               repeat=0,             # 0 makes it an "endless" animation
 | 
			
		||||
               quality=255,          # quality range 0 - 255
 | 
			
		||||
               delay=200,            # this is quick
 | 
			
		||||
               frames=0,             # 0 will stop on keyPressed or frameCount >= 100000
 | 
			
		||||
               finish=False):        # force stop
 | 
			
		||||
    global gifExporter
 | 
			
		||||
    try:
 | 
			
		||||
        gifExporter
 | 
			
		||||
    except NameError:
 | 
			
		||||
        gifExporter = GifMaker(this, filename + ".gif")
 | 
			
		||||
        gifExporter.setRepeat(repeat)
 | 
			
		||||
        gifExporter.setQuality(quality)
 | 
			
		||||
        gifExporter.setDelay(delay)
 | 
			
		||||
        
 | 
			
		||||
    gifExporter.addFrame()
 | 
			
		||||
 | 
			
		||||
    if frames == 0:
 | 
			
		||||
       if keyPressed and key == "e":
 | 
			
		||||
           finish = True
 | 
			
		||||
                
 | 
			
		||||
    if finish:
 | 
			
		||||
        gifExporter.finish()
 | 
			
		||||
        print("gif saved")
 | 
			
		||||
        exit()
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,135 @@
 | 
			
		|||
 | 
			
		||||
class Poly():
 | 
			
		||||
 | 
			
		||||
    selected = -1
 | 
			
		||||
    text_on = False
 | 
			
		||||
    selected_drag = -1
 | 
			
		||||
    drag_hole = -1
 | 
			
		||||
    drag_pt = -1
 | 
			
		||||
    id = 0
 | 
			
		||||
 | 
			
		||||
    def __init__(self, outer_pts, holes=None, closed=True, lw=1):
 | 
			
		||||
        self.outer_pts = outer_pts
 | 
			
		||||
        self.holes = holes if holes else [[]]
 | 
			
		||||
        self.closed = closed
 | 
			
		||||
        self.lw = lw
 | 
			
		||||
    
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def setup_grid(cls, cell_size, order, x_offset, y_offset):
 | 
			
		||||
        cls.cell_size = cell_size
 | 
			
		||||
        cls.order = order
 | 
			
		||||
        cls.x_offset, cls.y_offset = x_offset, y_offset
 | 
			
		||||
 | 
			
		||||
    def plot(self):
 | 
			
		||||
        for i, p in enumerate(Poly.polys):
 | 
			
		||||
            self.id = i if self == p else self.id
 | 
			
		||||
        pushStyle()
 | 
			
		||||
        strokeJoin(ROUND)
 | 
			
		||||
        strokeWeight(self.lw)
 | 
			
		||||
        if Poly.selected_drag == self.id:
 | 
			
		||||
            stroke(200, 0, 0)
 | 
			
		||||
        else:
 | 
			
		||||
            stroke(0)
 | 
			
		||||
        if len(self.outer_pts) >= 2:
 | 
			
		||||
            if self.closed:
 | 
			
		||||
                fill(100)
 | 
			
		||||
            else:
 | 
			
		||||
                noFill()
 | 
			
		||||
            beginShape()
 | 
			
		||||
            for x, y in self.outer_pts:
 | 
			
		||||
                sx = (x + Poly.x_offset) * Poly.cell_size
 | 
			
		||||
                sy = (y + Poly.y_offset) * Poly.cell_size
 | 
			
		||||
                vertex(sx, sy)
 | 
			
		||||
            for h in self.holes:
 | 
			
		||||
                beginContour()
 | 
			
		||||
                for x, y in h:
 | 
			
		||||
                    sx = (x + Poly.x_offset) * Poly.cell_size
 | 
			
		||||
                    sy = (y + Poly.y_offset) * Poly.cell_size
 | 
			
		||||
                    vertex(sx, sy)
 | 
			
		||||
                endContour()
 | 
			
		||||
            if self.closed:
 | 
			
		||||
                endShape(CLOSE)
 | 
			
		||||
            else:
 | 
			
		||||
                endShape()
 | 
			
		||||
        if Poly.text_on:    
 | 
			
		||||
            Poly.annotate_pts(self.id, self.outer_pts, color(200, 0, 0), 5)
 | 
			
		||||
            Poly.annotate_pts(self.id, self.holes[0], color(0, 0, 200), 5)
 | 
			
		||||
        popStyle()
 | 
			
		||||
 | 
			
		||||
    def remove_pt(self):
 | 
			
		||||
        snap = Poly.mouse_snap()
 | 
			
		||||
        if snap:
 | 
			
		||||
          for pt in self.outer_pts:
 | 
			
		||||
            if pt == snap:
 | 
			
		||||
                self.outer_pts.remove(pt)
 | 
			
		||||
                return True
 | 
			
		||||
            for h in self.holes:
 | 
			
		||||
                for pt in h:
 | 
			
		||||
                    if pt == snap:
 | 
			
		||||
                        h.remove(pt)
 | 
			
		||||
                        return True
 | 
			
		||||
 | 
			
		||||
    def set_drag(self): #, io, jo):
 | 
			
		||||
        snap = Poly.mouse_snap()
 | 
			
		||||
        if snap:
 | 
			
		||||
            for ipt, pt in enumerate(self.outer_pts):
 | 
			
		||||
                if pt == snap: #(io, jo):
 | 
			
		||||
                    Poly.drag_pt = ipt
 | 
			
		||||
                    return True
 | 
			
		||||
            for ih, h in enumerate(self.holes):
 | 
			
		||||
                for ipt, pt in enumerate(h):
 | 
			
		||||
                    if pt == snap: #(io, jo):
 | 
			
		||||
                        Poly.drag_hole = ih
 | 
			
		||||
                        Poly.drag_pt = ipt
 | 
			
		||||
                        return True
 | 
			
		||||
        return False
 | 
			
		||||
    
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def annotate_pts(cls, id, pts, c, scale_m=1):
 | 
			
		||||
            strokeWeight(5)
 | 
			
		||||
            textSize(12)
 | 
			
		||||
            fill(c)
 | 
			
		||||
            stroke(c)
 | 
			
		||||
            for i, j in pts:
 | 
			
		||||
                x = (i + cls.x_offset) * cls.cell_size
 | 
			
		||||
                y = (j + cls.y_offset) * cls.cell_size
 | 
			
		||||
                point(x, y)
 | 
			
		||||
                text(str(id)+":"+str((i * scale_m, j * scale_m)), x, y)
 | 
			
		||||
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def draw_grid(cls):
 | 
			
		||||
        stroke(128)
 | 
			
		||||
        noFill()
 | 
			
		||||
        for x in range(cls.order):
 | 
			
		||||
            for y in range(cls.order):
 | 
			
		||||
                rect(x * cls.cell_size, y * cls.cell_size,
 | 
			
		||||
                     cls.cell_size, cls.cell_size)
 | 
			
		||||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def clockwise_sort(xy_pairs):
 | 
			
		||||
        # https://stackoverflow.com/questions/51074984/sorting-according-to-clockwise-point-coordinates
 | 
			
		||||
        data_len = len(xy_pairs)
 | 
			
		||||
        if data_len > 2:
 | 
			
		||||
            x, y = zip(*xy_pairs)
 | 
			
		||||
        else:
 | 
			
		||||
            return xy_pairs
 | 
			
		||||
        centroid_x, centroid_y = sum(x) / data_len, sum(y) / data_len
 | 
			
		||||
        xy_sorted = sorted(xy_pairs,
 | 
			
		||||
                           key=lambda p: atan2((p[1] - centroid_y), (p[0] - centroid_x)))
 | 
			
		||||
        xy_sorted_xy = [
 | 
			
		||||
            coord for pair in list(zip(*xy_sorted)) for coord in pair]
 | 
			
		||||
        half_len = int(len(xy_sorted_xy) / 2)
 | 
			
		||||
        return list(zip(xy_sorted_xy[:half_len], xy_sorted_xy[half_len:]))
 | 
			
		||||
    
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def mouse_snap(cls):
 | 
			
		||||
        for i in range(Poly.order):
 | 
			
		||||
            x = i * Poly.cell_size
 | 
			
		||||
            for j in range(Poly.order):
 | 
			
		||||
                y = j * Poly.cell_size
 | 
			
		||||
                io, jo = i - Poly.x_offset, j - Poly.y_offset  # grid origin correction
 | 
			
		||||
                if dist(mouseX, mouseY, x, y) < Poly.cell_size / 2:
 | 
			
		||||
                    return (io, jo)
 | 
			
		||||
        return None
 | 
			
		||||
                
 | 
			
		||||
    
 | 
			
		||||
										
											Plik binarny nie jest wyświetlany.
										
									
								
							| 
		 Po Szerokość: | Wysokość: | Rozmiar: 3.7 KiB  | 
| 
						 | 
				
			
			@ -0,0 +1,126 @@
 | 
			
		|||
# Alexandre B A Villares - https://abav.lugaralgum.com/sketch-a-day
 | 
			
		||||
"""
 | 
			
		||||
A minimal poly editor
 | 
			
		||||
- Add points
 | 
			
		||||
"""
 | 
			
		||||
import pickle
 | 
			
		||||
from copy import deepcopy
 | 
			
		||||
from poly import Poly
 | 
			
		||||
# add_library('GifAnimation')
 | 
			
		||||
# from gif_exporter import gif_export
 | 
			
		||||
 | 
			
		||||
# f_pts = [map(lambda x: x / 5 - 12, pair) for pair in f_pts]
 | 
			
		||||
polys = [Poly([(-8, -7), (-1, 0), (1, -9)],
 | 
			
		||||
              holes=[[(-4, -4), (-6, -6), (-1, -7)], ]
 | 
			
		||||
              ),
 | 
			
		||||
         Poly([(0, 0), (1, 1), (1, 0)], lw=5, closed=False)
 | 
			
		||||
         ]
 | 
			
		||||
 | 
			
		||||
def setup():
 | 
			
		||||
    size(500, 500, P2D)
 | 
			
		||||
    CELL_SIZE = 15
 | 
			
		||||
    order = width // CELL_SIZE
 | 
			
		||||
    x_offset = y_offset = int(order // 2)
 | 
			
		||||
    Poly.setup_grid(CELL_SIZE, order, x_offset, y_offset)
 | 
			
		||||
    Poly.text_on = False
 | 
			
		||||
    Poly.polys = polys
 | 
			
		||||
    f = createFont("Fira Mono", 16)
 | 
			
		||||
    textFont(f)
 | 
			
		||||
 | 
			
		||||
def draw():
 | 
			
		||||
    background(230)
 | 
			
		||||
    # grade
 | 
			
		||||
    Poly.draw_grid()
 | 
			
		||||
    # polígonos
 | 
			
		||||
    for p in polys:
 | 
			
		||||
        p.plot()
 | 
			
		||||
 | 
			
		||||
def mousePressed():
 | 
			
		||||
    if keyPressed and keyCode == CONTROL:
 | 
			
		||||
        for p in polys:
 | 
			
		||||
            if p.remove_pt():  # io, jo):
 | 
			
		||||
                return
 | 
			
		||||
    else:
 | 
			
		||||
        for ip, p in enumerate(polys):
 | 
			
		||||
            if p.set_drag():  # io, jo):
 | 
			
		||||
                Poly.selected_drag = ip
 | 
			
		||||
                return
 | 
			
		||||
    Poly.selected_drag = -1 # click outside known vertices deselects 
 | 
			
		||||
 | 
			
		||||
def mouseDragged():
 | 
			
		||||
    if Poly.selected_drag >= 0 and not keyPressed:
 | 
			
		||||
        # a Poly point has been selected to be dragged
 | 
			
		||||
        # and no modifier key is pressed...
 | 
			
		||||
        if Poly.drag_hole == -1:  # if no hole was selected
 | 
			
		||||
            polys[Poly.selected_drag].outer_pts[Poly.drag_pt] = (
 | 
			
		||||
                int(mouseX / Poly.cell_size) - Poly.x_offset,
 | 
			
		||||
                int(mouseY / Poly.cell_size) - Poly.y_offset)
 | 
			
		||||
        else:
 | 
			
		||||
            polys[Poly.selected_drag].holes[Poly.drag_hole][Poly.drag_pt] = (
 | 
			
		||||
                int(mouseX / Poly.cell_size) - Poly.x_offset,
 | 
			
		||||
                int(mouseY / Poly.cell_size) - Poly.y_offset)
 | 
			
		||||
 | 
			
		||||
def mouseReleased():
 | 
			
		||||
    if Poly.selected_drag >= 0 and keyPressed and keyCode == SHIFT:
 | 
			
		||||
        # a Poly point has been selected to be dragged
 | 
			
		||||
        # and SHIFT key is pressed...
 | 
			
		||||
        if Poly.drag_hole == -1:  # if no hole wase selected
 | 
			
		||||
            polys[Poly.selected_drag].outer_pts.insert(
 | 
			
		||||
                Poly.drag_pt, (int(mouseX / Poly.cell_size) - Poly.x_offset,
 | 
			
		||||
                               int(mouseY / Poly.cell_size) - Poly.y_offset))
 | 
			
		||||
        else:
 | 
			
		||||
            polys[Poly.selected_drag].holes[Poly.drag_hole].insert(
 | 
			
		||||
                Poly.drag_pt, (int(mouseX / Poly.cell_size) - Poly.x_offset,
 | 
			
		||||
                               int(mouseY / Poly.cell_size) - Poly.y_offset))
 | 
			
		||||
 | 
			
		||||
    # Poly.selected_drag = -1  # No poly selected
 | 
			
		||||
    Poly.drag_hole = -1  # No hole selected
 | 
			
		||||
    Poly.drag_pt = -1  # No point selected
 | 
			
		||||
 | 
			
		||||
def keyPressed():
 | 
			
		||||
    if key == "=":
 | 
			
		||||
        Poly.selected_drag += 1
 | 
			
		||||
        if Poly.selected_drag >= len(polys):
 | 
			
		||||
            Poly.selected_drag = -1
 | 
			
		||||
    if key == "d" and Poly.selected_drag >=0:
 | 
			
		||||
        p = deepcopy(polys[Poly.selected_drag])
 | 
			
		||||
        for i, pt in enumerate(p.outer_pts):
 | 
			
		||||
            p.outer_pts[i] = (pt[0]+2, pt[1]+1)
 | 
			
		||||
        polys.append(p)
 | 
			
		||||
        
 | 
			
		||||
        
 | 
			
		||||
    if key == " " and Poly.selected_drag >=0:
 | 
			
		||||
            p = polys[Poly.selected_drag]
 | 
			
		||||
            p.outer_pts[:] = Poly.clockwise_sort(p.outer_pts)
 | 
			
		||||
            for h in p.holes:
 | 
			
		||||
                h[:] = Poly.clockwise_sort(h)[::-1]
 | 
			
		||||
    # if key == "g":
 | 
			
		||||
    #     gif_export(GifMaker, filename=SKETCH_NAME)
 | 
			
		||||
    if key == "p":
 | 
			
		||||
        saveFrame(SKETCH_NAME + ".png")
 | 
			
		||||
    if key == "t":
 | 
			
		||||
        Poly.text_on = not Poly.text_on
 | 
			
		||||
 | 
			
		||||
    global polys
 | 
			
		||||
    if key == "s":
 | 
			
		||||
        with open("data/project.data", "wb") as file_out:
 | 
			
		||||
            pickle.dump(polys, file_out)
 | 
			
		||||
        println("project saved")
 | 
			
		||||
 | 
			
		||||
    if key == "r":
 | 
			
		||||
        with open("data/project.data", "rb") as file_in:
 | 
			
		||||
            polys = pickle.load(file_in)
 | 
			
		||||
        println("project loaded")
 | 
			
		||||
 | 
			
		||||
def settings():
 | 
			
		||||
    from os import path
 | 
			
		||||
    global SKETCH_NAME
 | 
			
		||||
    SKETCH_NAME = path.basename(sketchPath())
 | 
			
		||||
    OUTPUT = ".png"
 | 
			
		||||
    println(
 | 
			
		||||
        """
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
[{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)]
 | 
			
		||||
""".format(SKETCH_NAME, OUTPUT)
 | 
			
		||||
    )
 | 
			
		||||
							
								
								
									
										15
									
								
								README.md
								
								
								
								
							
							
						
						
									
										15
									
								
								README.md
								
								
								
								
							| 
						 | 
				
			
			@ -22,7 +22,22 @@ Get updates from my sort-of-weekly newsletter: [[sketch-mail](https://villares.o
 | 
			
		|||
 | 
			
		||||
## 2019
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
[sketch_190608a](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190608a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
 | 
			
		||||
 | 
			
		||||
Back to the Poly Editor...
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
[sketch_190607a](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190607a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Some ideas for "Silly Type Framework"
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue