def makeAnimatiom(): vMasterFont = Font(FONT_PATH) axes = vMasterFont.axes for sequence in getProofSequences(): for location in getLocations( axes, sequence): # Expand into a sequence of locations. newPage(W, H) fill(1) rect(0, 0, W, H) save() textColor = 0 for gIndex, glyph in enumerate(TEXT): # Only works by glyph name. drawGlyphPath(vMasterFont.ttFont, glyph, S * 40 + S * gIndex * 6 * 9, S * 22, location=location, s=S * 0.04, fillColor=textColor) # TODO To be extended PageBot #drawGlyphPaths(vMasterFont, TEXT, x=S*40 + S*gIndex*6*9, y=S*22, location=location, fontSize=S*0.04, fillColor=textColor) restore() fill(0) fontSize(24) text('%s %s' % (location['changed1'][0], location['changed2'][0]), (100, 20))
def makeAnimatiom(): vMasterFont = Font(FONT_PATH) axes = vMasterFont.axes print axes.keys() axisStates = {} for axisName, (minValue, defaultValue, maxValue) in axes.items(): axisStates[axisName] = newAxisState(axisName, minValue, defaultValue, maxValue) c1, c2, c3 = [1, 0.1, 0, 0.7], [0, 1, 0, 0.7], [0, 0, 1, 0.7] for n in range(0, FRAMES, STEP): newPage(W, H) fill(1) rect(0, 0, W, H) textColor = 0 """ for cIndex, c in enumerate((c1, c2, c3)): if cIndex == 0: c[0] = (1.5+openV[cIndex][0]/2)/2 #c[1] = (1+lineV[cIndex][0]/16)/2 #c[2] = (1+wghtV[cIndex][0]/16)/2 elif cIndex == 1: #c[0] = (1+rndoV[cIndex][0]/8)/2 c[1] = (1.2+rndiV[cIndex][0]/2)/2 #c[2] = (1+sqroV[cIndex][0]/8)/2 else: #c[0] = (1+rndoV[cIndex][0]/16)/2 #c[1] = (1+wghtV[cIndex][0]/16)/2 c[2] = (1.5+wghtV[cIndex][0]/2)/2 """ location = getNextLocation(axisStates) for gIndex, glyph in enumerate(TEXT): # Only works by glyph name. drawGlyphPath(vMasterFont.ttFont, glyph, S*40 + S*gIndex*6*9, S*22, location=location, s=S*0.04, fillColor=textColor)
def makeAnimatiom(): axes = vMasterFont.axes print 'Variable A X E S' for axisName, (minValue, defaultValue, maxValue) in vMasterFont.axes.items(): print axisName, 'minValue', minValue, 'defaultValue', defaultValue, 'maxValue', maxValue location = getDefaultLocation(axes) if TERMINAL_VALUES_S[TerminalValue] != 'None': location[TERMINALS[TerminalShape]] = TERMINAL_VALUES[TerminalValue] if SKELETON_VALUES[SkeletonValue] != 'None': location[SKELETONS[SkeletonShape]] = SKELETON_VALUES[SkeletonValue] if BLEND_VALUES[BlendValue] != 'None': location[BLENDS[BlendShape]] = BLEND_VALUES[BlendValue] location['wmx2'] = WEIGHT_VALUES[WeightValue-2] #for sequence in getProofSequences(): # for location in getLocations(axes, sequence): # Expand into a sequence of locations. # newPage(W, H) fill(1) rect(0, 0, W, H) save() textColor = 0 for gIndex, glyph in enumerate(TEXT): # Only works by glyph name. drawGlyphPath(vMasterFont.ttFont, glyph, S*40 + S*gIndex*6*9, S*22, location=location, s=S*0.04, fillColor=textColor) drawGlyphPath(vMasterFont.ttFont, glyph, S*40 + S*gIndex*6*9, S*22, location=location, s=S*0.04, fillColor=textColor) # TODO To be extended PageBot #drawGlyphPaths(vMasterFont, TEXT, x=S*40 + S*gIndex*6*9, y=S*22, location=location, fontSize=S*0.04, fillColor=textColor) restore() fill(0) fontSize(24)
def draw(self, view, origin): c = self.doc.context p = pointOffset(self.oPoint, origin) p = self._applyScale(view, p) px, py, _ = self._applyAlignment(p) # Ignore z-axis for now. fillColor = self.style.get('fill') if fillColor is not None: c.fill(fillColor) c.stroke((0.8, 0.8, 0.8), 0.5) c.rect(px, py, self.w, self.h) if len(self.dimensions) == 1: raise ValueError('Not supporting 1 axis now') if len(self.dimensions) > 2: raise ValueError('Not supporting >2 axis now') axisNames = sorted(self.dimensions.keys()) axisX = axisNames[0] sizeX = self.dimensions[axisX] axisY = axisNames[1] sizeY = self.dimensions[axisY] stepX = self.w / (sizeX+1) stepY = self.h / (sizeY+1) """Add more parametric layout behavior here.""" RANGE = 1000 for indexX in range(sizeX+1): for indexY in range(sizeY+1): ox = 30 oy = 25 ppx = ox + px + indexX * stepX ppy = oy + py + indexY * stepY self.location[axisX] = indexX * RANGE / sizeX self.location[axisY] = indexY * RANGE / sizeY glyphPathScale = self.fontSize/self.font.info.unitsPerEm drawGlyphPath(c, self.font.ttFont, self.glyphNames[0], ppx, ppy, self.location, s=glyphPathScale, fillColor=(0, 0, 0)) bs = c.newString('%s %d\n%s %d' % (axisX, indexX * RANGE / sizeX, axisY, indexY * RANGE / sizeY), fontSize=6, fill=0) w, h = bs.size() c.text(bs, ppx - stepX/4, ppy - 16) # Bit of hack, we need the width of the glyph here. bs = c.newString('Other axes: %s' % self.location, fontSize=6, fill=0) w, h = bs.size() c.text(bs, px, py - 16)
def makeAnimatiom(): vMasterFont = Font(FONT_PATH) axes = vMasterFont.axes for sequence in getProofSequences(): for location in getLocations( axes, sequence): # Expand into a sequence of locations. newPage(W, H) fill(1) rect(0, 0, W, H) textColor = 0 for gIndex, glyph in enumerate(TEXT): # Only works by glyph name. drawGlyphPath(vMasterFont.ttFont, glyph, S * 40 + S * gIndex * 6 * 9, S * 22, location=location, s=S * 0.04, fillColor=textColor)