INNER CODE UNIT · Python
fill
varunsalian/debrify · dev/launch_animations/generate_recreations.py:25
def fill(c, opacity=100): return {'ty': 'fl', 'c': prop(rgb(c)), 'o': prop(opacity), 'r': 1}
def ellipse(r): return {'ty': 'el', 'd': 1, 'p': prop([0, 0]), 's': prop([r*2, r*2])}
def rect(w, h, center=(0, 0)): return {'ty': 'rc', 'd': 1, 'p': prop(list(center)), 's': prop([w, h]), 'r': prop(0)}
class OutlinePen(BasePen):
def __init__(self, glyphs=None, scale=1):
super().__init__(glyphs)
self.scale = scale
self.paths = []
def point(self, p): return [round(p[0]*self.scale, 4), round(-p[1]*self.scale, 4)]
def _moveTo(self, p):
self.v, self.ins, self.outs = [self.point(p)], [[0, 0]], [[0, 0]]
def _lineTo(self, p):
self.v.append(self.point(p)); self.ins.append([0, 0]); self.outs.append([0, 0])
def _curveToOne(self, a, b, end):
a, b, end = self.point(a), self.point(b), self.point(end)
self.outs[-1] = [a[i]-self.v[-1][i] for i in (0, 1)]
self.v.append(end); self.ins.append([b[i]-end[i] for i in (0, 1)]); self.outs.append([0, 0])