예제 #1
0
 def bezier_curve_to(self, cp1x, cp1y, cp2x, cp2y, x, y, draw_context,
                     *args, **kwargs):
     point1, point2, point3, point4 = (PointF(*draw_context.last_point),
                                       PointF(cp1x,
                                              cp1y), PointF(cp2x, cp2y),
                                       PointF(x, y))
     draw_context.current_path.AddBezier(point1, point2, point3, point4)
     draw_context.last_point = (x, y)
예제 #2
0
파일: canvas.py 프로젝트: rmansfeld/toga
 def write_text(self, text, x, y, font, draw_context, *args, **kwargs):
     width, height = font.measure(text)
     origin = PointF(x, y - height)
     font_family = win_font_family(font.family)
     font_style = win_font_style(font.weight, font.style, font_family)
     draw_context.current_path.AddString(text, font_family, font_style,
                                         float(height), origin,
                                         StringFormat())
예제 #3
0
 def write_text(self, text, x, y, font, draw_context, *args, **kwargs):
     full_height = 0
     font_family = win_font_family(font.family)
     font_style = win_font_style(font.weight, font.style, font_family)
     for line in text.splitlines():
         _, height = self.measure_text(line, font)
         origin = PointF(x, y + full_height - height)
         draw_context.current_path.AddString(line, font_family, font_style,
                                             float(height), origin,
                                             StringFormat())
         full_height += height
예제 #4
0
 def write_text(self, text, x, y, font, draw_context, *args, **kwargs):
     width, height = font.measure(text)
     origin = PointF(x, y - height)
     if draw_context.current_path is not None:
         font_family = win_font_family(font.family)
         font_style = win_font_style(font.weight, font.style, font_family)
         draw_context.current_path.AddString(
             text, font_family, font_style, float(height), origin, StringFormat()
         )
     else:
         brush = self.create_brush(
             color=kwargs.get("stroke_color", None),
         )
         draw_context.graphics.DrawString(
             text, font._impl.native, brush, origin
         )
예제 #5
0
 def quadratic_curve_to(self, cpx, cpy, x, y, draw_context, *args,
                        **kwargs):
     point1, point2, point3 = PointF(*draw_context.last_point), PointF(
         cpx, cpy), PointF(x, y)
     draw_context.current_path.AddCurve([point1, point2, point3])
     draw_context.last_point = (x, y)