I'm trying to get my head around this text-based programming.. why can't it be like max where everything seems to be running side-by-side and living it's own happy life ;)
anyway - i have written a small sketch, trying to learn about OOP.
Whenever you press a key, some circles appear - but on my computer, it takes around 5 - 7 seconds from keyPressed() until I see the circles, and I don't seem to understand why - can you maybe give me a pointer?
(i use the java.util* but I guess this is still the forum, since it is native in processing?)
Sorry - i'm really new to processing. I have a problem. I want to place an image in front of a canvas that are routed to syphon.
Even though my picture is rendered as the very last thing, the canvas.line() is rendered in front of it.. I've tried moving the image using beginShape() and moving the vertex, but I can't seem to figure out how the vertex really works..
If you change the "public float strokecolor", you can see the lines changing colors, and my picture is behind them.
this is my code:
import codeanticode.syphon.*;
import oscP5.*;
import netP5.*;
//OSC
OscP5 oscP5;
NetAddress myBroadcastLocation;
float factor;
// syphon
PGraphics canvas;
SyphonServer server;
// Images
PImage scLogo;
// Variables
int n = 300;
int[] a = new int[n];
/*----------------------------CHANGE THIS ------------------ */
public float strokecolor = 255;
/*----------------------------!CHANGE THIS ------------------ */
void setup() {
size(800,800, P3D);
canvas = createGraphics(800, 800, P3D);
frameRate(50);
// Initialize OSC
oscP5 = new OscP5(this, 5001);
myBroadcastLocation = new NetAddress("127.0.0.1", 5000);
// Create syhpon server to send frames out.
server = new SyphonServer(this, "Processing Syphon");
// Load images
scLogo = loadImage("SCLOGO1.png");
}
void draw() {
canvas.beginDraw();
canvas.smooth();
canvas.background(127);
canvas.lights();
for(int i = 0; i < n; i++) { // tegn 500 streger
canvas.image(scLogo, 200, 200);
float x1 = 0;
float x2 = 0;
float y1 = 0;
float y2 = 0;
float transperancy = random(0, 200); // calculates an alpha value
float weight = random(0, 1);
x1 = random(50, width-50);
y1 = random(50, height-50);
x2 = random(50, width-50);
y2 = random(50, height-50);
canvas.stroke(strokecolor, transperancy);
canvas.strokeWeight(30);
canvas.line(x1, y1, 0, x2, y2, 0); // draws a line with the coordinates from the array