diff --git a/examples/testcanvas.py b/examples/testcanvas.py index b8acbc26e..0f29dde44 100644 --- a/examples/testcanvas.py +++ b/examples/testcanvas.py @@ -2,28 +2,10 @@ from kivy.app import App from kivy.uix.widget import Widget from kivy.core.image import Image from kivy.graphics import * - +from kivy.uix.svg import SVG class TestApp(App): def build(self): - a = Widget() - tex = Image('examples/kivy.jpg').texture - tex2 = Image('examples/test.png').texture - with a.canvas: - - #Color(1,1,1,1) - #Ellipse(pos=(300,100), size=(200,100), texture=tex2) - Color(1,0,0,1) - Rectangle() - - #LineWidth(10) - #PathStart(300,300) - #PathLineTo(200,200) - #PathLineTo(300,200) - #PathLineTo(300,400) - #PathLineTo(200,250) - #PathLineTo(100,300) - #PathLineTo(150,250) - #PathStroke() - return a - + s = SVG() + s.source = 'examples/svg/test.svg' + return s TestApp().run() diff --git a/kivy/c_ext/graphics.pyx b/kivy/c_ext/graphics.pyx index 7a913498c..1ca703cc6 100644 --- a/kivy/c_ext/graphics.pyx +++ b/kivy/c_ext/graphics.pyx @@ -1076,8 +1076,15 @@ cdef class Path(VertexDataInstruction): cdef int add_point(self, float x, float y): cdef int idx cdef vertex v = vertex2f(x,y) + for p in self. points: + if abs(p.x-x) < 0.001 and abs(p.y-y) < 0.001: + Logger("PATH: ignoring point(x,y)...already in list") + return 0 + self.point_buffer.add(&v, &idx, 1) self.points.append(Point(x,y)) + + return idx cdef build_stroke(self): @@ -1112,10 +1119,10 @@ cdef class Path(VertexDataInstruction): dy = sw/2.0 * dy/ns #create quad, with cornerss pull off the line by the normal - v[0] = vertex8f(x0-dy, y0+dx, 0,0, -dy, dx, -1.0,-1.0); - v[1] = vertex8f(x0+dy, y0-dx, 0,0, dy,-dx, 1.0, 1.0); - v[2] = vertex8f(x1+dy, y1-dx, 0,0, dy,-dx, 1.0, 1.0); - v[3] = vertex8f(x1-dy, y1+dx, 0,0, -dy, dx, -1.0,-1.0); + v[0] = vertex8f(x0, y0, 0,0, -dy, dx, -1.0,-1.0); + v[1] = vertex8f(x0, y0, 0,0, dy,-dx, 1.0, 1.0); + v[2] = vertex8f(x1, y1, 0,0, dy,-dx, 1.0, 1.0); + v[3] = vertex8f(x1, y1, 0,0, -dy, dx, -1.0,-1.0); #add vertices to vertex buffer, get vbo indices self.v_buffer.add(v, idx, 4) @@ -1197,6 +1204,7 @@ cdef class PathInstruction(GraphicInstruction): self.path = _active_path + cdef class PathStart(PathInstruction): '''Starts a new path at position x,y. Will raise an Excpetion, if called while another path is already started. @@ -1208,13 +1216,13 @@ cdef class PathStart(PathInstruction): y position ''' cdef int index - def __init__(self, float x, float y): + def __init__(self): global _active_path PathInstruction.__init__(self) if _active_path != None: raise Exception("Can't start a new path while another one is being constructed") _active_path = self.path = Path() - self.index = self.path.add_point(x, y) + #self.index = self.path.add_point(x, y) cdef class PathLineTo(PathInstruction): @@ -1261,3 +1269,10 @@ cdef class PathStroke(PathInstruction): cdef class PathEnd(PathStroke): pass + + + + + + + diff --git a/kivy/data/style.kv b/kivy/data/style.kv index e2d331808..25cca6e53 100644 --- a/kivy/data/style.kv +++ b/kivy/data/style.kv @@ -13,6 +13,10 @@ Color: rgb: (1, 1, 1) Rectangle: + +241f47f5:w +27-3018-110810-m8-08-00-des-iow + texture: self.texture size: self.texture_size pos: root.center[0] - self.texture_size[0] / 2., root.center[1] - self.texture_size[1] / 2.