Welcome to Whirls’ documentation!¶
A fullscreen program that displays an animated, twisting tessellation of whirls. Click to show or hide a panel of sliders to adjust the whirls. Press Esc to exit.
What is a Whirl?¶
Begin with an arbitrary polygon. Construct a nested polygon by joining points that are a fractional distance along each edge. Repeat this process ad infinitum.
The vertices of the whirl form a logarithmic spiral, and they approximate a pursuit curve. The center of the spiral is the centroid of the polygon.
If the constructed polygon’s vertices lie on midpoints of the base polygon, then it’s called a midpoint polygon. If the constructed polygon has an even number of sides, then it’s called a derived polygon.
Dependencies¶
This program was developed against:
 Python 3.5
 NumPy 1.10
 SciPy 0.17
 Matplotlib 1.5
 Pygame 1.9
 PGU 0.18
Older versions may or may not work.
Installation¶
These are minimal instructions to install and run this program on Windows 64 bit, including all dependencies. These instructions will not interfere with any other installed versions of Python and do not affect your PATH environment variable.
Download WinPython64bit3.5.1.3.exe and install to C:\py\WinPython64bit3.5.1.3
Download pygame1.9.2a0cp35nonewin_amd64.whl and pgu0.18.zip.
Open Command Prompt and run the following:
C:\py\WinPython64bit3.5.1.3\python3.5.1.amd64\python m pip install C:\Users\<user>\Downloads\pygame1.9.2a0cp35nonewin_amd64.whl C:\py\WinPython64bit3.5.1.3\python3.5.1.amd64\python m pip install C:\Users\<user>\Downloads\pgu0.18.zip C:\py\WinPython64bit3.5.1.3\python3.5.1.amd64\python m pip install whirls C:\py\WinPython64bit3.5.1.3\python3.5.1.amd64\python m whirls
Troubleshooting¶
DLL load failed¶
ImportError: DLL load failed: The specified module could not be found.
If you installed Pygame for Python 3.5 from the link provided, then you need to install the Microsoft Visual C++ 2015 Redistributable.
SyntaxError¶
If you get an error like this:
File "C:\py\WinPython32bit3.5.1.3\python3.5.1\lib\sitepackages\pgu\gui\container.py", line 57
except StyleError,e:
^
SyntaxError: invalid syntax
Then change that line to read:
except StyleError as e:
That file does not belong to this project.
API Reference¶
A fullscreen program that displays an animated, twisting tessellation of whirls.

class
whirls.
App
(title: str, inner_point_count: int, inner_border: int, window_size: typing.Tuple.__getitem__()=None) → None[source]¶ Encapsulate the window, main loop, and events.

__init__
(title: str, inner_point_count: int, inner_border: int, window_size: typing.Tuple.__getitem__()=None) → None[source]¶ Create a new App.
Parameters:  title – The title of the window.
 inner_point_count – The number of points to generate, not including the four corners.
 inner_border – The minimum gap (in pixels) between the inner points and the edge of the screen.
 window_size – If defined, this is the pixel width and height of the contents of the window. If None, the app is run in fullscreen mode.


class
whirls.
Painter
(screen_size: typing.Tuple.__getitem__(), slider_gui: 'SliderGui', inner_point_count: int, inner_border: int, outer_border: int) → None[source]¶ Encapsulate calculating and drawing the tessellation.

__init__
(screen_size: typing.Tuple.__getitem__(), slider_gui: 'SliderGui', inner_point_count: int, inner_border: int, outer_border: int) → None[source]¶ Create a new Painter.
Parameters:  screen_size – The pixel width and height of the tessellation.
 slider_gui – The GUI containing the sliders
 inner_point_count – The number of points to generate, not including the four corners.
 inner_border – The minimum gap (in pixels) between the inner points and the edge of the screen.
 outer_border – The gap (in pixels) between the points in the four corners and the edge of the screen.

partial_draw
= None¶ If True, only a limited number of lines will be drawn each frame.

lines
= None¶ The number of lines that were drawn in the last frame.


class
whirls.
FloatHSlider
(value: float, float_min: float, float_max: float, size: float, **kwargs) → None[source]¶ A horizontal slider that supports floatingpoint values.

__init__
(value: float, float_min: float, float_max: float, size: float, **kwargs) → None[source]¶ Create a new FloatHSlider.
The minimum and maximum values will be exactly as specified, but, due to the internal representation, the initial value will be approximate.
Parameters:  value – The approximate initial position of the slider.
 float_min – The minimum value of the slider.
 float_max – The minimum value of the slider.
 size – The length of the slider bar in pixels.

slider
= None¶ The GUI widget that should be added to the view. Do not use the ‘value’ property of this object.

value
¶ The value that the slider is set to.


whirls.
interp
(value: float, from_min: float, from_max: float, to_min: float, to_max: float) → float[source]¶ Linear interpolation from a source range to a destination range.
Maps the source range to the destination range, and returns the corresponding value. If the value is between from_min and from_max, then the returned value is between to_min and to_max. If the value is equal to from_min, then the returned value is equal to to_min. Likewise, if the value is equal to from_max, then the returned value is equal to to_max. If the value is not between from_min and from_max, then the returned value is not between to_min and to_max. From_max may be less than from_min and to_max may be less than to_min. from_min may not equal from_max.
Parameters:  value – The value to interpolate.
 from_min – A value that maps to to_min.
 from_max – A value that maps to to_max.
 to_min – A value that maps from from_min.
 to_max – A value that maps from from_max.
Returns: The corresponding value.

whirls.
translate
(points: numpy.ndarray, size: numpy.ndarray, border: int) → numpy.ndarray[source]¶ Return the points translated to the area within the border within the target rectangle.
Parameters:  points – An array of points whose coordinates are in the range [0, 1).
 size – The width and height of the target rectangle.
 border – The border within the target rectangle.
Returns: The translated points.

whirls.
convolve
(polygon: numpy.ndarray, factor: float) → numpy.ndarray[source]¶ Return a new polygon whose vertices are between the adjacent vertices of the given polygon.
Parameters:  polygon – An array of points.
 factor – Where the new vertices should be placed. If 0, the convolved polygon will be identical to the given polygon. If 0.5, the vertices of the convolved polygon will be halfway between the adjacent vertices of the given polygon.
Returns: The convolved polygon.