summaryrefslogtreecommitdiff
path: root/src/editorui.py
diff options
context:
space:
mode:
authorColin Noga <Tempus@Spectrum-Song.local>2011-11-17 08:28:06 -0600
committerColin Noga <Tempus@Spectrum-Song.local>2011-11-17 08:28:06 -0600
commitfbbcc2155643c791f6d455d0bac290761e809b7c (patch)
tree0d62a27b562748a4a39321965d0fa69834309934 /src/editorui.py
parent68e66b16255ea2603bd323083e3b5b43280caff1 (diff)
downloadkoopatlas-fbbcc2155643c791f6d455d0bac290761e809b7c.tar.gz
koopatlas-fbbcc2155643c791f6d455d0bac290761e809b7c.zip
Prototyped some path shit
Diffstat (limited to 'src/editorui.py')
-rw-r--r--src/editorui.py86
1 files changed, 84 insertions, 2 deletions
diff --git a/src/editorui.py b/src/editorui.py
index 6b0815c..b7d691a 100644
--- a/src/editorui.py
+++ b/src/editorui.py
@@ -248,7 +248,6 @@ class KPEditorObject(KPEditorItem):
del obj
-
class KPEditorDoodad(QtGui.QGraphicsPixmapItem):
def __init__(self, doodad, layer):
QtGui.QGraphicsPixmapItem.__init__(self)
@@ -496,6 +495,90 @@ class KPEditorDoodad(QtGui.QGraphicsPixmapItem):
del doodad
+class KPEditorNode(QtGui.QGraphicsPixmapItem):
+ def __init__(self, node, layer):
+ QtGui.QGraphicsPixmapItem.__init__(self)
+ self.setFlags(
+ self.ItemSendsGeometryChanges |
+ self.ItemIsSelectable |
+ self.ItemIsMovable
+ )
+
+class KPEditorPathSegment(QtGui.QGraphicsPathItem):
+ def __init__(self, node, layer):
+ QtGui.QGraphicsPathItem.__init__(self)
+ self.setFlags(
+ self.ItemSendsGeometryChanges |
+ self.ItemIsSelectable |
+ self.ItemIsMovable
+ )
+
+ self.path = QtGui.QPainterPath()
+ self.brush = None
+ self.pen = None
+
+ self.rotation = 0
+
+
+ def makeStraight(self, start, end):
+
+ self.path.moveTo(start)
+ self.path.addPolygon(QtGui.QPolygon([QtCore.QPointF(start.x(), start.y()-5.0),
+ QtCore.QPointF(end.x(), end.y()-5.0),
+ QtCore.QPointF(end.x(), end.y()+5.0),
+ QtCore.QPointF(start.x(), start.y()+5.0),
+ QtCore.QPointF(start.x(), start.y()-5.0)]
+
+
+ graduate = QtGui.QRadialGradiant(QtCore.QPointF((end.x()/2)-(start.x()/2), (end.y()/2)-(start.y()/2) + 16), (end.x()/2)-(start.x()/2),
+ graduate.setColorA(QColor(200, 210, 240))
+ graduate.setColorB(QColor(150, 160, 190))
+
+ self.brush = QtGui.QBrush(graduate)
+
+ self.pen = QtGui.QPen(QColor(120, 130, 160))
+ self.pen.setWidth(4)
+ self.pen.setCapStyle(Qt.RoundCap)
+ self.pen.setJoinStyle(Qt.RoundJoin)
+
+
+
+ def makeArc(self, start, end):
+
+ self.path.moveTo(start)
+ self.path.addEllipse(start.x(), start.y(), end.x()-start.x(), end.y()-start.y())
+
+ r = QtGui.QPainterPath()
+ r.addEllipse(start.x(), start.y()-4, end.x()-start.x(), end.y()-start.y()-16)
+
+ self.path.subtracted(r)
+
+
+ graduate = QtGui.QRadialGradiant(QtCore.QPointF((end.x()/2)-(start.x()/2), (end.y()/2)-(start.y()/2) + 16), (end.x()/2)-(start.x()/2),
+ graduate.setColorA(QColor(200, 210, 240))
+ graduate.setColorB(QColor(150, 160, 190))
+
+ self.brush = QtGui.QBrush(graduate)
+
+ self.pen = QtGui.QPen(QColor(120, 130, 160))
+ self.pen.setWidth(4)
+ self.pen.setCapStyle(Qt.RoundCap)
+ self.pen.setJoinStyle(Qt.RoundJoin)
+
+
+ sX = start.x()
+ sY = start.y()
+
+ eX = end.x()
+ eY = end.y()
+
+ dy = eY - sY
+ dx = eX - sX
+ rads = math.atan2(dy, dx)
+
+ self.rotate = math.degrees(rads)
+
+
class KPMapScene(QtGui.QGraphicsScene):
@@ -616,7 +699,6 @@ class KPMapScene(QtGui.QGraphicsScene):
item.setFlag(flag, value)
-
class KPEditorWidget(QtGui.QGraphicsView):
def __init__(self, scene, parent=None):
QtGui.QGraphicsView.__init__(self, scene, parent)