From c44fd09cffe3a0677830fb2ba9a62e6a94469107 Mon Sep 17 00:00:00 2001 From: adammhaile Date: Sun, 19 Jun 2016 19:53:23 -0400 Subject: [PATCH] updated to setuptools, anti-aliasing for AnalogClock.py --- .gitignore | 2 + BiblioPixelAnimations/matrix/AnalogClock.py | 66 ++++++++++++++------- setup.py | 16 ++--- 3 files changed, 54 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index dab63ae..98dcba6 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,5 @@ target/ .remote-sync.json .remote-sync.json .remote-sync.json + +BiblioPixelAnimations.egg* diff --git a/BiblioPixelAnimations/matrix/AnalogClock.py b/BiblioPixelAnimations/matrix/AnalogClock.py index 20b654e..72f9ffc 100644 --- a/BiblioPixelAnimations/matrix/AnalogClock.py +++ b/BiblioPixelAnimations/matrix/AnalogClock.py @@ -1,71 +1,83 @@ from bibliopixel.animation import BaseMatrixAnim import bibliopixel.colors as colors from bibliopixel.util import pointOnCircle -import time, math +import time +import math + class AnalogClock(BaseMatrixAnim): - def __init__(self, led): + def __init__(self, led, aa=False): super(AnalogClock, self).__init__(led) self._centerX = (self._led.width - 1) / 2 self._centerY = (self._led.height - 1) / 2 + self.aa = aa - def step(self, amt = 1): + def step(self, amt=1): self._led.all_off() t = time.localtime() hrs = t.tm_hour % 12 - min = t.tm_min + mins = t.tm_min sec = t.tm_sec - p_hrs = pointOnCircle(self._centerX, self._centerY, int(self._centerX *0.7), hrs * 30) - p_min = pointOnCircle(self._centerX, self._centerY, self._centerX, min * 6) + p_hrs = pointOnCircle(self._centerX, self._centerY, int(self._centerX * 0.7), hrs * 30) + p_min = pointOnCircle(self._centerX, self._centerY, self._centerX, mins * 6) p_sec = pointOnCircle(self._centerX, self._centerY, self._centerX, sec * 6) - self._led.drawLine(self._centerX, self._centerY, p_hrs[0], p_hrs[1], (255, 0, 0)) - self._led.drawLine(self._centerX, self._centerY, p_min[0], p_min[1], (0, 255, 0)) - self._led.drawLine(self._centerX, self._centerY, p_sec[0], p_sec[1], (0, 0, 255)) + self._led.drawLine(self._centerX, self._centerY, p_hrs[0], p_hrs[1], (255, 0, 0), aa=self.aa) + self._led.drawLine(self._centerX, self._centerY, p_min[0], p_min[1], (0, 255, 0), aa=self.aa) + self._led.drawLine(self._centerX, self._centerY, p_sec[0], p_sec[1], (0, 0, 255), aa=self.aa) self._step = 0 + class RGBAnalogClock(BaseMatrixAnim): - def __init__(self, led): + def __init__(self, led, aa=False): super(RGBAnalogClock, self).__init__(led) self._centerX = (self._led.width - 1) / 2 self._centerY = (self._led.height - 1) / 2 + self.aa = aa - def step(self, amt = 1): + def step(self, amt=1): self._led.all_off() t = time.localtime() hrs = t.tm_hour % 12 - min = t.tm_min + mins = t.tm_min sec = t.tm_sec p_hrs = pointOnCircle(self._centerX, self._centerY, int(self._centerX * 0.7), hrs * 30) - p_min = pointOnCircle(self._centerX, self._centerY, self._centerX, min * 6) + p_min = pointOnCircle(self._centerX, self._centerY, self._centerX, mins * 6) p_sec = pointOnCircle(self._centerX, self._centerY, self._centerX, sec * 6) - c_hrs = colors.hue2rgb_rainbow(t.tm_hour * (256/24)) + c_hrs = colors.hue2rgb_rainbow(t.tm_hour * (256 / 24)) - c_min = colors.hue2rgb_rainbow(min * (256/60)) + c_min = colors.hue2rgb_rainbow(mins * (256 / 60)) - c_sec = colors.hue2rgb_rainbow(sec * (256/60)) + c_sec = colors.hue2rgb_rainbow(sec * (256 / 60)) - self._led.drawLine(self._centerX, self._centerY, p_hrs[0], p_hrs[1], c_hrs) - self._led.drawLine(self._centerX, self._centerY, p_min[0], p_min[1], c_min) - self._led.drawLine(self._centerX, self._centerY, p_sec[0], p_sec[1], c_sec) + self._led.drawLine(self._centerX, self._centerY, p_hrs[0], p_hrs[1], c_hrs, aa=self.aa) + self._led.drawLine(self._centerX, self._centerY, p_min[0], p_min[1], c_min, aa=self.aa) + self._led.drawLine(self._centerX, self._centerY, p_sec[0], p_sec[1], c_sec, aa=self.aa) self._step = 0 - MANIFEST = [ { "class": AnalogClock, "controller": "matrix", - "desc": "Displays analog clock with red, green, and blue hands.", + "desc": "Displays analog clock with red, green, and blue hands.", "display": "AnalogClock", "id": "AnalogClock", - "params": [], + "params": [ + { + "default": True, + "help": "", + "id": "aa", + "label": "AntiAlias", + "type": "bool" + } + ], "type": "animation" }, { @@ -74,7 +86,15 @@ def step(self, amt = 1): "desc": "Displays analog clock with hand colors based on their angle converted to a hue value.", "display": "RGBAnalogClock", "id": "RGBAnalogClock", - "params": [], + "params": [ + { + "default": True, + "help": "", + "id": "aa", + "label": "AntiAlias", + "type": "bool" + } + ], "type": "animation" } ] diff --git a/setup.py b/setup.py index 6dfc8d7..db5f826 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,19 @@ -from distutils.core import setup +from setuptools import setup import BiblioPixelAnimations import urllib2, json -_ver = "BAD_INSTALL" +import sys +_ver = "DEV" try: - head = urllib2.urlopen("https://api.github.com/repos/ManiacalLabs/BiblioPixelAnimations/git/refs/head").read() - head_data = json.loads(head) - if len(head_data) > 0: - _ver = head_data[0]["object"]["sha"] + if not 'develop' in sys.argv: + head = urllib2.urlopen("https://api.github.com/repos/ManiacalLabs/BiblioPixelAnimations/git/refs/head").read() + head_data = json.loads(head) + if len(head_data) > 0: + _ver = head_data[0]["object"]["sha"] except: pass -if not 'pip' in __file__: +if not 'pip' in __file__ and not 'develop' in sys.argv: print """ This installer MUST be run from pip! Please install using the following command: