def Render(self, canvas, obj): if len(self.attributes) < 6: return width = 2 length = canvas.mm2px(float(self.Attribute(4))) if self.Attribute(5) == 'U': angle = 3 * math.pi / 2 text_angle = angle text_dx = -10 text_dy = -length / 2 elif self.Attribute(5) == 'D': angle = math.pi / 2 text_angle = 3 * math.pi / 2 text_dx = -10 text_dy = length / 2 elif self.Attribute(5) == 'R': angle = 0 text_angle = 0 text_dx = length / 2 text_dy = -10 else: angle = math.pi text_angle = 0 text_dx = -length / 2 text_dy = -10 start = Canvas.Point(canvas.xmm2px(float(self.Attribute(2))), canvas.ymm2px(-float(self.Attribute(3)))) end = Canvas.Point(canvas.xmm2px(start.x + length * math.cos(angle)), canvas.ymm2px(start.y + length * math.sin(angle))) line = Canvas.Line(start, end, width) canvas.Draw(line, ["Drawing"]) font = Canvas.Font( Canvas.Point(canvas.xmm2px(float(self.Attribute(6))), canvas.ymm2px(float(self.Attribute(7)))), 2) text = Canvas.Text(self.Attribute(1)) text.anchor_x = 'center' text.anchor_y = '' text.at = Canvas.Position(canvas.xmm2px(start.x + text_dx), canvas.ymm2px(start.y + text_dy), text_angle) canvas.SetFont(font) canvas.Draw(text, ["Label"]) circle = Canvas.Circle( start, Canvas.Point(canvas.xmm2px(start.x + 10), canvas.ymm2px(start.y)), 1, False) canvas.Draw(circle, ["Label"])
def Render(self, canvas, obj): if len(self.attributes) < 4: return font = Canvas.Font( Canvas.Point(canvas.xmm2px(float(self.Attribute(3))), canvas.ymm2px(float(self.Attribute(3)))), 2) text = Canvas.Text(self.Attribute(7)) if int(self.Attribute(0)) > 0: angle = 3 * math.pi / 2 else: angle = 0 text.anchor_x = 'center' text.anchor_y = 'center' text.at = Canvas.Position(canvas.xmm2px(float(self.Attribute(1))), canvas.ymm2px(-float(self.Attribute(2))), angle) canvas.SetFont(font) canvas.Draw(text, ["Label"])
def Render(self, canvas, obj): font = Canvas.Font() canvas.SetFont(font) super(KicadFont, self).Render(canvas, font)