Hello people,
Title sums it up really. I'm using toxilibs to draw a voronoi diagram and basically i want to use a texture on the triangle2D created by the voronoi diagram but trying to do so results in an error -
- texture() not available with this renderer.
This was without any renderer specified so i've tried P2D, JAVA2D, P3D and OPENGL but all without any luck. My guess is this is because of the toxilibssupport-library somehow so i've tried to bypass that by just getting the vectors from the triangle2D and use those on new vertices (processing native) but that didn't work either. I then tried searching the docs for any mention of textures and triangle2D but again without luck. By now i've ran out of clues or workarounds.
Thanks for any help on this.
FRid
Title sums it up really. I'm using toxilibs to draw a voronoi diagram and basically i want to use a texture on the triangle2D created by the voronoi diagram but trying to do so results in an error -
- texture() not available with this renderer.
This was without any renderer specified so i've tried P2D, JAVA2D, P3D and OPENGL but all without any luck. My guess is this is because of the toxilibssupport-library somehow so i've tried to bypass that by just getting the vectors from the triangle2D and use those on new vertices (processing native) but that didn't work either. I then tried searching the docs for any mention of textures and triangle2D but again without luck. By now i've ran out of clues or workarounds.
Thanks for any help on this.
FRid
- import processing.opengl.*;
import toxi.geom.mesh2d.*;
import toxi.processing.*;
import toxi.geom.*;
ToxiclibsSupport gfx;
Voronoi voronoi = new Voronoi();
PImage img;
int num = 25;
Vec2D[] punt = new Vec2D[num];
Vec2D[] direction = new Vec2D[num];
Vec2D[] loc = new Vec2D[num];
void setup() {
size(600, 600);
gfx = new ToxiclibsSupport(this);
img = loadImage("5.jpg");
for (int i = 0; i < num; i++) {
direction[i] = new Vec2D(random(0.5,1.5),random(0.5,1.5));
loc[i] = new Vec2D(random(0,width),random(0,height));
punt[i] = new Vec2D(loc[i]);
voronoi.addPoint(punt[i]);
}
}
void draw() {
background(0);
stroke(255);
strokeWeight(1);
noFill();
voronoi = null;
voronoi = new Voronoi();
for (int i = 0; i < num; i++) {
loc[i].x = (loc[i].x+direction[i].x) % width;
loc[i].y = (loc[i].y+direction[i].y) % height;
punt[i] = new Vec2D(loc[i]);
voronoi.addPoint(punt[i]);
}
fill(0, 0, 255, 100);
noStroke();
for (Vec2D c : voronoi.getSites()) {
ellipse(c.x, c.y, 5, 5);
}
stroke(0, 0, 255, 50);
beginShape(TRIANGLES);
//texture(img); //Uncommenting this gives me "texture() is not available with this renderer"
for (Triangle2D t : voronoi.getTriangles()) {
stroke(255,255,255,30);
strokeWeight(1);
//gfx.triangle(t, false);
gfx.vertex(t.a);
gfx.vertex(t.b);
gfx.vertex(t.c);
stroke(255,0,0);
strokeWeight(5);
//gfx.point(t.a);
//gfx.point(t.b);
//gfx.point(t.c); - //println(t.a); Prints x/y-values but can't seem to use them on anything else but the gfx/toxi-stuff
}
endShape();
}
1