From 61d4b0ccdb28c39c6f6a900a462ec6c102f572a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Tue, 5 Nov 2013 00:03:13 +0100 Subject: [PATCH] use inverse average color for progress line --- pysstv/examples/gimp-plugin.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pysstv/examples/gimp-plugin.py b/pysstv/examples/gimp-plugin.py index 98336db..519ee4f 100755 --- a/pysstv/examples/gimp-plugin.py +++ b/pysstv/examples/gimp-plugin.py @@ -77,6 +77,13 @@ class ProgressCanvas(Canvas): height *= 2 if (width, height) != image.size: image = image.resize((width, height)) + pixels = image.load() + RED, GREEN, BLUE = range(3) + self.colors = ['#{0:02x}{1:02x}{2:02x}'.format( + 255 - sum(pixels[x, y][RED] for x in xrange(width)) / width, + 255 - sum(pixels[x, y][GREEN] for x in xrange(width)) / width, + 255 - sum(pixels[x, y][BLUE] for x in xrange(width)) / width) + for y in xrange(height)] Canvas.__init__(self, master, width=width, height=height) self.tk_img = ImageTk.PhotoImage(image) self.update_image() @@ -85,7 +92,7 @@ class ProgressCanvas(Canvas): image = self.tk_img self.create_image(0, 0, anchor=NW, image=image) if line is not None: - self.create_line(0, line, image.width(), line, fill="#FFFF00") + self.create_line(0, line, image.width(), line, fill=self.colors[line]) def transmit_current_image(image, drawable, mode, vox, fskid):