placing an image in front of a canvas.draw();
in
Contributed Library Questions
•
11 months ago
Hi All,
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
}
canvas.image(scLogo, 200, 200);
canvas.endDraw();
image(canvas, 0, 0);
server.sendImage(canvas);
}
void oscEvent(OscMessage theOscMessage) {
strokecolor = theOscMessage.get(0).floatValue();
}
1