rjw57
Posts: 33
Joined: Wed Sep 07, 2011 1:21 pm
Contact: Website

Re: Announcement: plot85 graphics library

Mon Sep 12, 2011 10:53 am

Since there seemed to be some interest last time I posted about this, I've made my little Python hack available on https://github.com/rjw57/plot85

The idea is that it provides an immediate gratification, implicit global state graphics framework which is comparable in ability to that of the venerable BASIC V. (Or, I suppose, that of the Apple ][ - http://www.folklore.org/StoryV.....g_Born.txt)

I've tried to make it easy to do things very little code and, with very little in the way of magic runes, someone can get something pretty on the screen and re-create that little flush of excitement at making the computer draw something for you.

I'd very much welcome some help with this. Fleshing out the support for more graphics primitives (especially triangle drawing, otherwise the name is a little silly) would be appreciated, as would writing some good docstrings or making some more pretty examples.

Those of you with long memories and good archives might want to fish out an old copy of Acorn User and look to Jan Vibe for inspiration :).

Screenshots below and, for reference, here is the spiral code. It's purposefully simple: it just requires that someone understand variable assignment, for loops and can transcribe a formula.

from pi.graphics import *

(w, h) = screen_size()

# The starting corners of the squares

x1 = 0
y1 = 0

x2 = w-1
y2 = 0

x3 = w-1
y3 = h-1

x4 = 0
y4 = h-1

twist = 0.05

for i in range(0, 200):
# Draw the current square
line(x1, y1, x2, y2)
line(x2, y2, x3, y3)
line(x3, y3, x4, y4)
line(x4, y4, x1, y1)

# Work out the new co-ordinates
new_x1 = twist * x2 + (1 - twist) * x1
new_y1 = twist * y2 + (1 - twist) * y1
new_x2 = twist * x3 + (1 - twist) * x2
new_y2 = twist * y3 + (1 - twist) * y2
new_x3 = twist * x4 + (1 - twist) * x3
new_y3 = twist * y4 + (1 - twist) * y3
new_x4 = twist * x1 + (1 - twist) * x4
new_y4 = twist * y1 + (1 - twist) * y4

# Make use of the new co-ordinates
x1 = new_x1
y1 = new_y1
x2 = new_x2
y2 = new_y2
x3 = new_x3
y3 = new_y3
x4 = new_x4
y4 = new_y4

save_screen("tunnel")


rjw57
Posts: 33
Joined: Wed Sep 07, 2011 1:21 pm
Contact: Website

Re: Announcement: plot85 graphics library

Mon Sep 12, 2011 10:56 am

... oh, addendum: I know this is very similar to the Processing framework's aim, but I find that Python is a better language than Java in terms of learning. YMMV and you're welcome to disagree of course!

darkcity
Posts: 66
Joined: Wed Aug 03, 2011 3:01 pm
Contact: Website

Re: Announcement: plot85 graphics library

Mon May 08, 2017 8:55 pm

This looks very nice. Did you see the 2007 interview with Jan Vibes?

http://www.drobe.co.uk/article.php?id=2 ... ode=2&hlt=

Return to “Other projects”