def __init__(self, trafo = None, radius1 = 0, radius2 = 0, properties = None, duplicate = None): RectangularPrimitive.__init__(self, trafo, properties = properties, duplicate = duplicate) if duplicate is not None: self.radius1 = duplicate.radius1 self.radius2 = duplicate.radius2 else: self.radius1 = radius1 self.radius2 = radius2
def __init__(self, trafo = None, radius1 = 0, radius2 = 0, properties = None, duplicate = None): if trafo is not None and trafo.m11==trafo.m21==trafo.m12==trafo.m22==0: trafo=Trafo(1,0,0,-1,trafo.v1,trafo.v2) RectangularPrimitive.__init__(self, trafo, properties = properties, duplicate = duplicate) if duplicate is not None: self.radius1 = duplicate.radius1 self.radius2 = duplicate.radius2 else: self.radius1 = radius1 self.radius2 = radius2
def __init__(self, trafo = None, start_angle = 0.0, end_angle = 0.0, arc_type = ArcPieSlice, properties = None, duplicate = None): if duplicate is not None: self.start_angle = duplicate.start_angle self.end_angle = duplicate.end_angle self.arc_type = duplicate.arc_type else: self.start_angle = start_angle self.end_angle = end_angle self.arc_type = arc_type RectangularPrimitive.__init__(self, trafo, properties = properties, duplicate = duplicate) self.normalize()
def __init__(self, trafo = None, text = '', halign = ALIGN_LEFT, valign = ALIGN_BASE, properties = None, duplicate = None): CommonText.__init__(self, text, duplicate) RectangularPrimitive.__init__(self, trafo, properties = properties, duplicate = duplicate) if duplicate != None: self.halign = duplicate.halign self.valign = duplicate.valign self.atrafo = duplicate.atrafo else: self.halign = halign self.valign = valign if properties is None: self.properties = PropertyStack(base=FactoryTextStyle()) self.cache = {}
def __init__( self, trafo=None, start_angle=0.0, end_angle=0.0, arc_type=ArcPieSlice, properties=None, duplicate=None ): if trafo is not None and trafo.m11 == trafo.m21 == trafo.m12 == trafo.m22 == 0: trafo = Trafo(1, 0, 0, -1, trafo.v1, trafo.v2) if duplicate is not None: self.start_angle = duplicate.start_angle self.end_angle = duplicate.end_angle self.arc_type = duplicate.arc_type else: self.start_angle = start_angle self.end_angle = end_angle self.arc_type = arc_type RectangularPrimitive.__init__(self, trafo, properties=properties, duplicate=duplicate) self.normalize()
def DrawShape(self, device, rect=None, clip=0): RectangularPrimitive.DrawShape(self, device) base_trafo = self.trafo(self.atrafo) base_trafo = base_trafo(Scale(self.properties.font_size)) paths = self.properties.font.GetPaths(self.text, self.properties) obj = PolyBezier(paths, self.properties.Duplicate()) obj.Transform(base_trafo) device.MultiBezier(obj.paths, rect, clip)
def __init__(self, trafo=None, text='', halign=const.ALIGN_LEFT, valign=const.ALIGN_BASE, properties=None, duplicate=None): CommonText.__init__(self, text, duplicate) RectangularPrimitive.__init__(self, trafo, properties=properties, duplicate=duplicate) if duplicate != None: self.halign = duplicate.halign self.valign = duplicate.valign self.atrafo = duplicate.atrafo else: self.halign = halign self.valign = valign if properties is None: self.properties = PropertyStack(base=FactoryTextStyle()) self.properties.align = self.halign self.properties.valign = self.valign self.cache = {}
def SaveToFile(self, file): RectangularPrimitive.SaveToFile(self, file) file.SimpleText(self.text, self.trafo, self.properties.align, self.properties.valign, self.properties.chargap, self.properties.wordgap, self.properties.linegap)
def DrawShape(self, device, rect=None, clip=0): RectangularPrimitive.DrawShape(self, device) base_trafo = self.trafo(self.atrafo) if self.curves_cache is None: a = self.properties paths = a.font.get_paths(self.text, a) self.curves_cache = self.convert_paths(paths) paths = self.duplicate_paths(self.curves_cache) obj = PolyBezier(paths, self.properties.Duplicate()) obj.Transform(base_trafo) device.MultiBezier(obj.paths, rect, clip)
def DrawShape(self, device, rect=None, clip=0): #for b in self.AsBezier().GetObjects(): # b.DrawShape(device,rect,clip) #return RectangularPrimitive.DrawShape(self, device) # Workaround for a bug in my Xserver. #text = split(self.text, '\n')[0] device.DrawText(self.text, self.trafo(self.atrafo), clip, cache=self.cache)
def __init__(self, trafo=None, start_angle=0.0, end_angle=0.0, arc_type=ArcPieSlice, properties=None, duplicate=None): if trafo is not None and trafo.m11 == trafo.m21 == trafo.m12 == trafo.m22 == 0: trafo = Trafo(1, 0, 0, -1, trafo.v1, trafo.v2) if duplicate is not None: self.start_angle = duplicate.start_angle self.end_angle = duplicate.end_angle self.arc_type = duplicate.arc_type else: self.start_angle = start_angle self.end_angle = end_angle self.arc_type = arc_type RectangularPrimitive.__init__(self, trafo, properties=properties, duplicate=duplicate) self.normalize()
def Blend(self, other, p, q): blended = RectangularPrimitive.Blend(self, other, p, q) if self.start_angle != self.end_angle \ or other.start_angle != other.end_angle: blended.start_angle = p * self.start_angle + q * other.start_angle blended.end_angle = p * self.end_angle + q * other.end_angle if self.start_angle == self.end_angle: blended.arc_type = other.arc_type elif other.start_angle == other.end_angle: blended.arc_type = self.arc_type else: if self.arc_type == other.arc_type: blended.arc_type = self.arc_type # The rest of the arc type blends is quite arbitrary # XXX: are these rules acceptable? Maybe we should blend # the ellipses as bezier curves if the arc types differ elif self.arc_type == ArcArc or other.arc_type == ArcArc: blended.arc_type = ArcArc elif self.arc_type == ArcChord or other.arc_type == ArcChord: blended.arc_type = ArcChord else: blended.arc_type = ArcPieSlice return blended
def Disconnect(self): self.cache = {} RectangularPrimitive.Disconnect(self)
def Blend(self, other, p, q): result = RectangularPrimitive.Blend(self, other, p, q) result.radius1 = p * self.radius1 + q * other.radius1 result.radius2 = p * self.radius2 + q * other.radius2 return result
def SaveToFile(self, file): RectangularPrimitive.SaveToFile(self, file) file.SimpleText(self.text, self.trafo, self.halign, self.valign)