]> git.parisson.com Git - timeside.git/commitdiff
Change Grapher render() function to match documentation API, pass part of previous...
authorThomas Fillon <thomas@parisson.com>
Fri, 8 Nov 2013 17:20:09 +0000 (18:20 +0100)
committerThomas Fillon <thomas@parisson.com>
Fri, 8 Nov 2013 17:20:09 +0000 (18:20 +0100)
timeside/grapher/core.py
timeside/grapher/spectrogram_log.py
timeside/grapher/waveform_simple.py
timeside/grapher/waveform_transparent.py

index 822fa2170e3e39605aa119bfe9d3eba6a9bb19e7..e6de9adbf5feb27b516c098bef6e00a5d046da36 100644 (file)
@@ -144,6 +144,12 @@ class Grapher(Processor):
         self.pixel = self.image.load()
         self.draw = ImageDraw.Draw(self.image)
 
+    def render(self, output=None):
+        if output:
+            self.image.save(output)
+            return
+        return self.image
+
     def watermark(self, text, font=None, color=(255, 255, 255), opacity=.6, margin=(5,5)):
         self.image = im_watermark(text, text, color=color, opacity=opacity, margin=margin)
 
@@ -264,6 +270,7 @@ class Grapher(Processor):
                 self.previous_x, self.previous_y = x, y
 
 
+
 if __name__ == "__main__":
     import doctest
     doctest.testmod()
\ No newline at end of file
index dce40cc41cfecad25dd468da3c721c8725d3995f..37694b884cfce369bfbc0e13ed0980c1745625bb 100644 (file)
@@ -87,7 +87,9 @@ class SpectrogramLog(Grapher):
                     self.pixel_cursor += 1
         return frames, eod
 
-    def render(self, filename):
-        """ Apply last 2D transforms and write all pixels to the file. """
+    @interfacedoc
+    def post_process(self):
+        """ Apply last 2D transforms"""
         self.image.putdata(self.pixels)
-        self.image.transpose(Image.ROTATE_90).save(filename)
+        self.image.transpose(Image.ROTATE_90)
+
index 887babe7920a927d962a813bb8f51c2137dd2e4f..8856e93ddb0c237916c52876cfdd17d69b041d9a 100644 (file)
@@ -64,10 +64,8 @@ class Waveform(Grapher):
         return frames, eod
 
     @interfacedoc
-    def render(self, output):
-        if output:
-            a = 1
-            for x in range(self.image_width):
-                self.pixel[x, self.image_height/2] = tuple(map(lambda p: p+a, self.pixel[x, self.image_height/2]))
-            self.image.save(output)
-        return self.image
+    def post_process(self, output=None):
+        a = 1
+        for x in range(self.image_width):
+            self.pixel[x, self.image_height/2] = tuple(map(lambda p: p+a, self.pixel[x, self.image_height/2]))
+
index ee017c6f120ee95184c2a7b4cb28a9d12e51c58d..2c19f6ed5d9c9cbbd324038ae9f974e7ef072158 100644 (file)
@@ -63,12 +63,3 @@ class WaveformTransparent(Waveform):
                 self.draw_peaks_inverted(self.pixel_cursor, peaks(samples), self.line_color)
                 self.pixel_cursor += 1
         return frames, eod
-
-    @interfacedoc
-    def render(self, output):
-        if output:
-            a = 1
-            for x in range(self.image_width):
-                self.pixel[x, self.image_height/2] = tuple(map(lambda p: p+a, self.pixel[x, self.image_height/2]))
-            self.image.save(output)
-        return self.image