(self, view, origin)
| 54 | self.location = copy(location) |
| 55 | |
| 56 | def draw(self, view, origin): |
| 57 | c = self.doc.context |
| 58 | p = pointOffset(self.origin, origin) |
| 59 | p = self._applyScale(view, p) |
| 60 | px, py, _ = self._applyAlignment(p) # Ignore z-axis for now. |
| 61 | |
| 62 | fillColor = self.style.get('fill') |
| 63 | if fillColor is not None: |
| 64 | c.fill(fillColor) |
| 65 | else: |
| 66 | c.fill(None) |
| 67 | c.stroke((0.8, 0.8, 0.8), 0.5) |
| 68 | c.rect(px, py, self.w, self.h) |
| 69 | if len(self.dimensions) == 1: |
| 70 | raise ValueError('Not supporting 1 axis now') |
| 71 | if len(self.dimensions) > 2: |
| 72 | raise ValueError('Not supporting >2 axis now') |
| 73 | |
| 74 | axisNames = sorted(self.dimensions.keys()) |
| 75 | axisX = axisNames[0] |
| 76 | sizeX = self.dimensions[axisX] |
| 77 | axisY = axisNames[1] |
| 78 | sizeY = self.dimensions[axisY] |
| 79 | stepX = self.w / (sizeX+1) |
| 80 | stepY = self.h / (sizeY+1) |
| 81 | |
| 82 | # TODO: Add more parametric layout behavior here. |
| 83 | RANGE = 1000 |
| 84 | for indexX in range(sizeX+1): |
| 85 | for indexY in range(sizeY+1): |
| 86 | ox = 30 |
| 87 | oy = 25 |
| 88 | ppx = ox + px + indexX * stepX |
| 89 | ppy = oy + py + indexY * stepY |
| 90 | self.location[axisX] = indexX * RANGE / sizeX |
| 91 | self.location[axisY] = indexY * RANGE / sizeY |
| 92 | glyphPathScale = self.fontSize/self.font.info.unitsPerEm |
| 93 | |
| 94 | c.drawGlyphPath(self.font.ttFont, self.glyphNames[0], ppx, ppy, self.location, s=glyphPathScale, fillColor=(0, 0, 0)) |
| 95 | |
| 96 | fs = c.newString('%s %d\n%s %d' % (axisX, indexX * RANGE / sizeX, axisY, indexY * RANGE / sizeY), fontSize=6, fill=blackColor) |
| 97 | w, h = fs.size() |
| 98 | c.text(fs, ppx - stepX/4, ppy - 16) # Bit of hack, we need the width of the glyph here. |
| 99 | fs = c.newString('Other axes: %s' % self.location, fontSize=6, fill=blackColor) |
| 100 | w, h = fs.size() |
| 101 | c.text(fs, px, py - 16) |
| 102 | |
| 103 | if __name__ == '__main__': |
| 104 | import doctest |
nothing calls this directly
no test coverage detected