Draw the image in the calculated scale. Since we need to use the image by scale transform, all other measure (position, lineWidth) are scaled back to their original proportions. If stroke is defined, then use that to draw a frame around the image. Note that the (sx,
(self, view, origin=ORIGIN, **kwargs)
| 118 | return alpha |
| 119 | |
| 120 | def build(self, view, origin=ORIGIN, **kwargs): |
| 121 | """Draw the image in the calculated scale. Since we need to use the |
| 122 | image by scale transform, all other measure (position, lineWidth) are |
| 123 | scaled back to their original proportions. |
| 124 | |
| 125 | If stroke is defined, then use that to draw a frame around the image. |
| 126 | Note that the (sx, sy) is already scaled to fit the padding position |
| 127 | and size.""" |
| 128 | p = pointOffset(self.origin, origin) |
| 129 | p = self._applyScale(view, p) |
| 130 | px, py, _ = p = self._applyAlignment(p) # Ignore z-axis for now. |
| 131 | |
| 132 | self._applyRotation(view, p) |
| 133 | |
| 134 | if self.path is None or \ |
| 135 | not os.path.exists(self.path) or \ |
| 136 | not self.iw or not self.ih: |
| 137 | # TODO: Also show error, in case the image does not exist, to |
| 138 | # differ from empty box. |
| 139 | print('Cannot display image %s' % self) |
| 140 | _, _, pb, pl = self.padding |
| 141 | self.context.stroke(0.5, 0.5) |
| 142 | self.context.fill(0.8) |
| 143 | self.context.rect(px+pl, py+pb, self.pw, self.ph) |
| 144 | else: |
| 145 | #sx = self.w / self.iw |
| 146 | #sy = self.h / self.ih |
| 147 | #self.context.scale(sx.rv, sy.rv) |
| 148 | |
| 149 | if self.imo is not None: |
| 150 | self.imo.image(self.path, (0, 0), alpha=self._getAlpha()) |
| 151 | self.context.image(self.imo, p=(px, py), w=self.w, h=self.h, |
| 152 | alpha=self._getAlpha()) |
| 153 | else: |
| 154 | self.context.image(self.path, p=(px, py), w=self.w, h=self.h, |
| 155 | alpha=self._getAlpha()) |
| 156 | # TODO: Draw optional (transparent) forground color? |
| 157 | |
| 158 | self.buildChildElements(view, p, **kwargs) |
| 159 | |
| 160 | self._restoreRotation(view, p) |
| 161 | |
| 162 | self._restoreScale(view) |
| 163 | view.drawElementInfo(self, origin) |
| 164 | |
| 165 | if __name__ == '__main__': |
| 166 | import doctest |
nothing calls this directly
no test coverage detected