mirror of
https://github.com/dyne/FreeJ.git
synced 2026-06-16 12:59:33 +02:00
new experimental support for processing scripts
a -p flag is added on commandline to run .pde scripts directly it makes use of the included processing.js glue a new scripts/processing directory is added with some examples to experiment with so far only a few processing scripts work
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
// simple loader of a processing script
|
||||
|
||||
include("processing.js");
|
||||
|
||||
scr = new Screen("sdl");
|
||||
if (!scr.is_initialized()) {
|
||||
scr.init(800,600);
|
||||
add_screen(scr);
|
||||
}
|
||||
|
||||
script = read_file("/home/jaromil/devel/freej/scripts/javascript/examples/ventaglio.pjs");
|
||||
//script = read_file("/home/jaromil/devel/freej/scripts/javascript/examples/simple.processing");
|
||||
//script = read_file("/home/jaromil/devel/freej/scripts/javascript/examples/recursion.pjs");
|
||||
//script = read_file("/home/jaromil/devel/freej/scripts/javascript/examples/sinewave.pjs");
|
||||
//script = read_file("/home/jaromil/devel/freej/scripts/javascript/examples/colorwheel.pjs");
|
||||
//script = read_file("/home/jaromil/devel/freej/scripts/javascript/examples/setupdraw.pjs");
|
||||
|
||||
|
||||
Processing(script);
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
// All Examples Written by Casey Reas and Ben Fry
|
||||
// unless otherwise stated.
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
noStroke();
|
||||
smooth();
|
||||
drawCircle(100, 100, 80, 8);
|
||||
}
|
||||
|
||||
void drawCircle(float x, float y, int radius, int level)
|
||||
{
|
||||
float tt = 126 * level/6.0;
|
||||
fill(tt, 153);
|
||||
ellipse(x, y, radius*2, radius*2);
|
||||
if(level > 1) {
|
||||
level = level - 1;
|
||||
int num = int(random(2, 6));
|
||||
for(int i=0; i<num; i++) {
|
||||
float a = random(0, TWO_PI);
|
||||
float nx = x + cos(a) * 6.0 * level;
|
||||
float ny = y + sin(a) * 6.0 * level;
|
||||
drawCircle(nx, ny, radius/2, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
// All Examples Written by Casey Reas and Ben Fry
|
||||
// unless otherwise stated.
|
||||
// The statements in the setup() function
|
||||
// execute once when the program begins
|
||||
void setup()
|
||||
{
|
||||
size(200, 200); // Size should be the first statement
|
||||
stroke(255); // Set line drawing color to white
|
||||
frameRate(30);
|
||||
}
|
||||
|
||||
float y = 100;
|
||||
|
||||
// The statements in draw() are executed until the
|
||||
// program is stopped. Each statement is executed in
|
||||
// sequence and after the last line is read, the first
|
||||
// line is executed again.
|
||||
void draw()
|
||||
{
|
||||
background(0); // Set the background to black
|
||||
y = y - 1;
|
||||
if (y < 0) { y = height; }
|
||||
line(0, y, width, y);
|
||||
echo("y = " + y);
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
// All Examples Written by Casey Reas and Ben Fry
|
||||
// unless otherwise stated.
|
||||
int xspacing = 8; // How far apart should each horizontal location be spaced
|
||||
int w; // Width of entire wave
|
||||
|
||||
float theta = 0.0; // Start angle at 0
|
||||
float amplitude = 75.0; // Height of wave
|
||||
float period = 500.0; // How many pixels before the wave repeats
|
||||
float dx; // Value for incrementing X, to be calculated as a function of period and xspacing
|
||||
float[] yvalues; // Using an array to store height values for the wave (not entirely necessary)
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
frameRate(30);
|
||||
colorMode(RGB,255,255,255,100);
|
||||
smooth();
|
||||
w = width+16;
|
||||
dx = (TWO_PI / period) * xspacing;
|
||||
yvalues = new float[w/xspacing];
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
calcWave();
|
||||
renderWave();
|
||||
|
||||
}
|
||||
|
||||
void calcWave() {
|
||||
// Increment theta (try different values for 'angular velocity' here
|
||||
theta += 0.02;
|
||||
|
||||
// For every x value, calculate a y value with sine function
|
||||
float x = theta;
|
||||
for (int i = 0; i < yvalues.length; i++) {
|
||||
yvalues[i] = sin(x)*amplitude;
|
||||
x+=dx;
|
||||
}
|
||||
}
|
||||
|
||||
void renderWave() {
|
||||
// A simple way to draw the wave with an ellipse at each location
|
||||
for (int x = 0; x < yvalues.length; x++) {
|
||||
noStroke();
|
||||
fill(255,50);
|
||||
ellipseMode(CENTER);
|
||||
ellipse(x*xspacing,width/2+yvalues[x],16,16);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
|
||||
int W = 400;
|
||||
int H = 300;
|
||||
int cycle = 0;
|
||||
int count = 0;
|
||||
void setup() {
|
||||
size(W,H);
|
||||
background(0);
|
||||
smooth();
|
||||
};
|
||||
void draw(){
|
||||
if(cycle > 5) {
|
||||
cycle = 0;
|
||||
stroke(floor(random(255)),
|
||||
floor(random(255)),
|
||||
floor(random(255)), 60 );
|
||||
};
|
||||
if(count > 799) {
|
||||
count = 0;
|
||||
};
|
||||
for (int i = 0; i < 100; i++) {
|
||||
float r = random(2);
|
||||
strokeWeight(r);
|
||||
float offset = r * count;
|
||||
line(i-20, H, i+offset, 0);
|
||||
}
|
||||
cycle++;
|
||||
count+=5;
|
||||
}
|
||||
Reference in New Issue
Block a user