Package pySVG :: Module stylehelper
[hide private]
[frames] | no frames]

Source Code for Module pySVG.stylehelper

  1  """ 
  2  module for all attributes related to styling 
  3  """ 
  4  """ 
  5  Not supported as of yet. 
  6   
  7      * Interactivity properties: 
  8            o 'pointer-events' 
  9      * Multimedia properties: 
 10            o 'audio-level' 
 11  * Other properties for visual media: 
 12            o 'display' 
 13            o 'visibility' 
 14  Also testing is needed for all attributes ! 
 15  working: 
 16   
 17  #toto gradient stuff must be seperated i think members for stopcolor etc here are idiotic 
 18   
 19  """ 
20 -class StyleHelper:
21 """ Helper Class to create a style_dict for those not familiar with svg attribute names. 22 """
23 - def __init__(self):
24 self.style_dict={}
25 26 27 # tested below
28 - def setFontFamily(self, fontfamily):
29 self.style_dict["font-family"]=fontfamily
30
31 - def setFontSize(self, fontsize):
32 self.style_dict["font-size"]=fontsize
33
34 - def setFontStyle(self,fontstyle):
35 self.style_dict["font-style"]=fontstyle
36
37 - def setFontWeight(self,fontweight):
38 self.style_dict["font-weight"]=fontweight
39 40 #tested
41 - def setFilling(self, fill):
42 self.style_dict["fill"]=fill
43
44 - def setFillOpacity(self,fillopacity):
45 self.style_dict["fill-opacity"]=fillopacity
46
47 - def setFillRule(self,fillrule):
48 self.style_dict["fill-rule"]=fillrule
49
50 - def setStrokeWidth(self,strokewidth):
51 self.style_dict["stroke-width"]=strokewidth
52 - def setStroke(self,stroke):
53 self.style_dict["stroke"]=stroke
54 55 #untested below
56 - def setStrokeDashArray(self,strokedasharray):
57 self.style_dict["stroke-dasharray"]=strokedasharray
58 - def setStrokeDashOffset(self,strokedashoffset):
59 self.style_dict["stroke-dashoffset"]=strokedashoffset
60 - def setStrokeLineCap(self,strikelinecap):
61 self.style_dict["stroke-linecap"]=strikelinecap
62 - def setStrokeLineJoin(self,strokelinejoin):
63 self.style_dict["stroke-linejoin"]=strokelinejoin
64 - def setStrokeMiterLimit(self,strokemiterlimit):
65 self.style_dict["stroke-miterlimit"]=strokemiterlimit
66 - def setStrokeOpacity(self,strokeopacity):
67 self.style_dict["stroke-opacity"]=strokeopacity
68 69 70 #is used to provide a potential indirect value (currentColor) for the 'fill', 'stroke', 'stop-color' properties.
71 - def setCurrentColor(self, color):
72 self.style_dict["color"]=color
73 74 75 # Gradient properties:
76 - def setStopColor(self, stopcolor):
77 self.style_dict["stop-color"]=stopcolor
78
79 - def setStopOpacity(self, stopopacity):
80 self.style_dict["stop-opacity"]=stopopacity
81 82 #rendering properties
83 - def setColorRendering(self, colorrendering):
84 self.style_dict["color-rendering"]=colorrendering
85
86 - def setImageRendering(self, imagerendering):
87 self.style_dict["image-rendering"]=imagerendering
88
89 - def setShapeRendering(self, shaperendering):
90 self.style_dict["shape-rendering"]=shaperendering
91
92 - def setTextRendering(self, textrendering):
93 self.style_dict["text-rendering"]=textrendering
94
95 - def setSolidColor(self,solidcolor):
96 self.style_dict["solid-color"]=solidcolor
97
98 - def setSolidOpacity(self, solidopacity):
99 self.style_dict["solid-opacity"]=solidopacity
100 101 #Viewport properties
102 - def setVectorEffect(self, vectoreffect):
103 self.style_dict["vector-effect"]=vectoreffect
104
105 - def setViewPortFill(self, viewportfill):
106 self.style_dict["viewport-fill"]=viewportfill
107 108
109 - def setViewPortOpacity(self, viewportfillopacity):
110 self.style_dict["viewport-fill_opacity"]=viewportfillopacity
111 112 # Text properties
113 - def setDisplayAlign(self,displayalign):
114 self.style_dict["display-align"]=displayalign
115
116 - def setLineIncrement(self, lineincrement):
117 self.style_dict["line-increment"]=lineincrement
118
119 - def setTextAnchor(self, textanchor):
120 self.style_dict["text-anchor"]=textanchor
121
122 - def getStyleDict(self):
123 return self.style_dict
124