Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and

Monday, 13 June 2011

Nautilus shape in pyprocessing (using

Here is example another of my vanilla processing sketches translated to pyprocessing. In this case to save the image I used the script (included with pyprocessing) from jEdit. Get my jEdit macro and commando files here. See screenshot here. I've just found a simple way to do it by using pyglet calls directly in your sketch in the draw loop:-
did the trick for me.

from pyprocessing import *
from math import sin, cos, tan, exp, pi  
A = 0.8
B = 1.4
pvect = []

def getX(theta):
    return A * cos(theta)*exp(theta/tan(B))

def getY(theta):
    return A * sin(theta)*exp(theta/tan(B))  

def setup():
    size(400, 400)
    translate(width/2, height/3)
    rotate(0.75 * pi)
    for i in range(0, 41):
        x = getX(i*A)
        y = getY(i*A)
        pvect.append(PVector(x, y))
    for z in range(8, len(pvect)):
        tmp0 = pvect[z]
        tmp1 = pvect[z - 1]
        tmp2 = pvect[z - 8]
        tmp3 = pvect[z - 7]
        x0 = tmp0.x
        y0 = tmp0.y
        x1 = tmp1.x # we would have negative increments otherwise
        y1 = tmp1.y   
        x2= tmp2.x
        y2 = tmp2.y
        x3= tmp3.x # we would have negative increments otherwise
        y3 = tmp3.y 
        curve( x0, y0, x1, y1, x2, y2, x3, y3) # draw the radial lines

    stroke(255, 0, 0)
    beginShape() # begin spiral 'shell' shape
    for v in range(0, len(pvect)):
        tmp = pvect[v]
        curveVertex(tmp.x, tmp.y) # successive calls to curveVertex a variation on curve?  

No comments:

Post a Comment


Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby- and processing-3.2.2