# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See <http://www.gnu.org/licenses/gpl.html> for details.
#
"""
Description
===========
A simple drawing interface for Python that wraps PIL and aggdraw.
For slightly more information, see http://blog.brianhouse.net/post/6836163797
Requirements
============
Python 2.6+
PIL http://www.pythonware.com/products/pil/
aggdraw http://effbot.org/zone/aggdraw-index.htm (for 64-bit systems (eg OSX), use https://bitbucket.org/2degrees/aggdraw-64bits/src)
Using
=====
See the __main__ function below for a quick example.
Note on colors:
Colors are specified as a tuple of R, G, B, A values in the default mode and H, S, V, A if hsv was indicated in the class constructor. Alpha is optional.
If ints are used, 0-255 is assumed, whereas floats imply a 0-1 scale. Values can be mixed.
'stroke' refers to the lines/borders of a shape, with the supplied 'thickness'. To draw shapes without borders, set thickness to 0 and specify a fill.
Also, note that, unlike Processing or Canvas, this is not a state machine -- values must be specified with every command.
Todo
====
Polygons / polylines
Rotated shapes
Mouse events:
cv.NamedWindow("radar")
def on_mouse(event, x, y, flags, param):
if event == cv.CV_EVENT_LBUTTONUP:
print("click: %s,%s" % (x, y))
if event == cv.CV_EVENT_MOUSEMOVE:
print("move: %s,%s" % (x, y))
cv.SetMouseCallback("radar", on_mouse)
Keyboard events:
key = cv.WaitKey(1)
"""
import aggdraw, colorsys, math, time
from PIL import Image, ImageFilter, ImageOps, ImageDraw, ImageFont