Daily graphic 2

Tue 17 March 2015
By stu

Todays daily graphic I'm getting familiar with grids (in shoebot), Vector maths from the planar library .. this started from the grid example from shoebot / nodebox.

Shoebot Code Below the fold

``` {: .brush:python} """ Grid of arrows that point towards the mouse pointer.

Uses planar library for Vec2, angles. """

Based on grid->colorgrid example from shoebot

This is also basically a remake / rip / inspired

one of the examples made in the LGM 2014 workshop

if that was you let me know so I can add it to

shoebot :)

import random

from planar import Vec2, Affine

size(625, 625)

Create a color Grid.

This example also shows of the HSB color mode that allows

you to select colors more naturally, by specifying a hue,

saturation and brightness.


def draw(): random.seed(0) # Set some initial values. You can and should play around with these. h = 0 s = 0.5 b = 0.9 a = .5

# Size is the size of one grid square.
size = 50

# Create a grid with 10 rows and 10 columns. The width of the columns
# and the height of the rows is defined in the 'size' variable.
for x, y in grid(WIDTH / size, HEIGHT / size, size, size):
    # Using the translate command, we can give the grid some margin.

    # Increase the hue while choosing a random saturation.
    # Try experimenting here, like decreasing the brightness while
    # changing the alpha value etc.
    pos=Vec2(x-MOUSEX, y-(MOUSEY - size))

    # Set this to be the current fill color.
    fill(h, s, b, a)

    # Draw a angle that is one and a half times larger than the
    arrow(x, y, size*1.5)