Skip to content

Commit 436c19a

Browse files
author
Justin Deoliveira
committed
Merge pull request #24 from jericks/issue10
Add opacity, rotation, stroke properties. Add the ability to have no fi...
2 parents ada1d71 + be284b5 commit 436c19a

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

geoscript/style/shape.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@ class Shape(Symbolizer):
2020
"star", "cross", and "x".
2121
"""
2222

23-
def __init__(self, color=None, size=6, type='circle'):
23+
def __init__(self, color=None, size=6, type='circle', opacity=1.0, rotation=0):
2424
Symbolizer.__init__(self)
2525
self.color = Color(color) if color else None
2626
self.size = Expression(size)
2727
self.type = type
28+
self.opacity = Expression(opacity)
29+
self.rotation = Expression(rotation)
30+
self._stroke = None
31+
32+
def stroke(self, color="#000000", width=1, dash=None, cap=None, join=None):
33+
self._stroke = Stroke(color, width, dash, cap, join)
34+
return self
2835

2936
def _prepare(self, rule):
3037
syms = util.symbolizers(rule, PointSymbolizer)
@@ -35,15 +42,22 @@ def _apply(self, sym):
3542
Symbolizer._apply(self, sym)
3643
g = util.graphic(sym)
3744
g.setSize(self.size.expr)
45+
if self.rotation != None and self.rotation.expr != None:
46+
g.setRotation(self.rotation.expr)
3847
g.graphicalSymbols().clear()
3948
g.graphicalSymbols().add(self._mark())
4049

4150
def _mark(self):
4251
f = self.factory
4352
mark = f.createMark()
44-
45-
mark.setStroke(Stroke(self.color)._stroke())
46-
mark.setFill(Fill(self.color)._fill())
53+
if self._stroke != None:
54+
mark.setStroke(self._stroke._stroke())
55+
else:
56+
mark.setStroke(Stroke(self.color)._stroke())
57+
if self.color != None and self.color.expr != None:
58+
mark.setFill(Fill(self.color, self.opacity)._fill())
59+
else:
60+
mark.setFill(None)
4761
mark.setWellKnownName(self.type)
4862

4963
return mark

0 commit comments

Comments
 (0)