Brendan Howell avatar Brendan Howell committed cce2f72

Fixes #6

Comments (0)

Files changed (2)

         self.font_map = pangocairo.cairo_font_map_get_default()
         self.families = self.font_map.list_families()
-    def setBackground(self, red, green, blue):
-        self.ctx.set_source_rgba(blue/255.0, green/255.0, red/255.0, 1)
+    def setBackground(self, red, green=None, blue=None):
+        if not(green):
+            self.ctx.set_source_rgba(red/255.0, red/255.0, red/255.0, 1)
+        else:
+            self.ctx.set_source_rgba(red/255.0, blue/255.0, green/255.0, 1)
-    def setStroke(self, red, green, blue, alpha=255, width=1):
+    def setStroke(self, red, green=None, blue=None, alpha=255, width=1):
         self.setStrokeColor(red, green, blue, alpha)
-    def setStrokeColor(self, red, green, blue, alpha=255):
-        self.stroke_color = (red/255.0, green/255.0, blue/255.0, alpha/255.0)
+    def setStrokeColor(self, red, green=None, blue=None, alpha=255):
+        #assume greyscale if only 1 parameter is specified
+        if not(green):
+            self.stroke_color = (red/255.0, red/255.0, red/255.0, alpha/255.0)
+        else:
+            self.stroke_color = (red/255.0, green/255.0, blue/255.0, alpha/255.0)
     def setStrokeWidth(self, width):
         self.stroke_width = width
-    def setFillColor(self, red, green, blue, alpha=255):
-        self.fill_color = (red/255.0, green/255.0, blue/255.0, alpha/255.0)
+    def setFillColor(self, red, green=None, blue=None, alpha=255):
+        #assume greyscale if only 1 parameter is specified, assume you want fill
+        if not(green):
+            self.fill_color = (red/255.0, red/255.0, red/255.0, alpha/255.0)
+        else:
+            self.fill_color = (red/255.0, green/255.0, blue/255.0, alpha/255.0)
+        self.fill = True
     def setFillState(self, fill):
         self.fill = fill
-    #TODO: finish this
+    #TODO: finish and test PDF output
     def renderToPDF(self, fileName):
     	self.surface = cairo.PDFSurface(fileName, self.sdl_surface.get_width(), self.sdl_surface.get_height())
 def setBackground(red, green, blue):
     drawing.setBackground(red, green, blue)
-def setStroke(red, green, blue, alpha=255, width=1):
+def setStroke(red, green=None, blue=None, alpha=255, width=1):
     drawing.setStroke(red, green, blue, alpha, width)
-def setStrokeColor(red, green, blue, alpha=255):
+def setStrokeColor(red, green=None, blue=None, alpha=255):
     drawing.setStrokeColor(red, green, blue, alpha)
 def setStrokeWidth(width):
-def setFillColor(red, green, blue, alpha=255):
+def setFillColor(red, green=None, blue=None, alpha=255):
     drawing.setFillColor(red, green, blue, alpha)
 def setFillState(fillState):
+def setFillOn():
+    drawing.setFillOn()
+def setFillOff():
+    drawing.setFillOff()
 def screenGrab(fileName):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.