def dstyle(self, name=''): if not name: raise SketchLoadError(_("unnamed style")) style = self.style.AsDynamicStyle() style.SetName(name) self.style_dict[name] = style self.style = Style()
def __init__(self, file, filename, match): GenericLoader.__init__(self, file, filename, match) self.file = file self.curstyle = Style() self.verbosity = 0 self.gdiobjects = [] self.dcstack = [] self.curpoint = Point(0, 0)
def use_style(self, name=''): if not name: raise SketchLoadError(_("unnamed style")) if not self.style.IsEmpty(): self.prop_stack.load_AddStyle(self.style) self.style = Style() style = self.style_dict[name] self.prop_stack.load_AddStyle(style)
def get_prop_stack(self): stack = self.prop_stack if not self.style.IsEmpty(): stack.load_AddStyle(self.style) stack.condense() if self.base_style is not None: self.prop_stack = PropertyStack(base =self.base_style.Duplicate()) else: self.prop_stack = PropertyStack() self.style = Style() return stack
def __init__(self, file, filename, match): LoaderWithComposites.__init__(self) self.file = file self.filename = filename self.match = match self.style = Style() if self.base_style is not None: self.prop_stack = PropertyStack(base=self.base_style.Duplicate()) else: self.prop_stack = PropertyStack() self.messages = {}
elp_radius = 2.5 elp_startx = 0 elp_starty = 0 elp.trafo = Trafo(elp_radius, 0, 0, elp_radius, elp_startx, elp_starty) elpbz = elp.AsBezier() elpbz_nl = elpbz.Paths()[0].NodeList() # as list of Point(x,y) elpbz_tnl = [] # as list of tuples (x,y) for tpnt in elpbz_nl: elpbz_tnl.append( (tpnt.x, tpnt.y) ) tarrw1 = Arrow(elpbz_tnl, closed=1) #_nl or _tnl - all the same here; ellipse sends four points, which in Arrow are AppendBezier (AppendLine only for two points -- but still it looks like a diamond.. ).. # the difference is in tarrw1.Paths()[0].arc_lengths() vs elpbz.Paths()[0].arc_lengths() tarrw1.path = elpbz.Paths()[0] # and this FINALLY makes the arrow a circle! tarrw2 = Arrow(arpath2, closed=1) global tbase_style tbase_style = Style() tbase_style.fill_pattern = EmptyPattern tbase_style.fill_transform = 1 tbase_style.line_pattern = SolidPattern(StandardColors.red) tbase_style.line_width = 2.0 tbase_style.line_join = const.JoinMiter tbase_style.line_cap = const.CapButt tbase_style.line_dashes = () tbase_style.line_arrow1 = tarrw1 tbase_style.line_arrow2 = tarrw2 tbase_style.font = None tbase_style.font_size = 12.0 # from create_spiral.py from Sketch import CreatePath
import struct import operator import copy import types from Sketch import _, Trafo, Scale, Translation, Point, Polar, CreatePath, \ CreateRGBColor, SolidPattern, EmptyPattern, LinearGradient, \ MultiGradient, Style, const, StandardColors, GridLayer, GetFont, \ HatchingPattern from Sketch.warn import INTERNAL, warn_tb from Sketch.load import GenericLoader, SketchLoadError import Sketch.Graphics.font from Sketch.Graphics import text basestyle = Style() basestyle.fill_pattern = EmptyPattern basestyle.fill_transform = 1 basestyle.line_pattern = EmptyPattern basestyle.line_width = 1.0 basestyle.line_join = const.JoinMiter basestyle.line_cap = const.CapButt basestyle.line_dashes = () basestyle.line_arrow1 = None basestyle.line_arrow2 = None basestyle.font = None basestyle.font_size = 12.0 CGM_ID = { 0x0020: 'BEGMF', 0x0040: 'ENDMF',