vertex problems
              in 
             Programming Questions 
              •  
              1 year ago    
            
 
           
             Hello,
            
            
I'm still very new to Processing, so please forgive me for asking what I'm sure is a silly question.
            
I've been working on a sketch that takes the red, green and blue values from 16 points in an image. The 16 points are equally spaced throughout the image. I have then used the RGB values to form 16 XYZ vertex points. The idea is that I get a squiggly line on a blank canvas.
            
When I do the excercise long-hand, filling in the numerical values manually, everything is fine. But I've tried to create arrays for the RGB values, and now when the vertex draws I only get points - no squiggly line.
            
The mistake is probably simple, but I'm having difficulty finding it. If anyone can help, I'd be extremely grateful.
            
Thanks, Andy
            
            
            
            
            
            
            
PImage ethno;
            
float [] redValue = new float[16];
float [] greenValue = new float[16];
float [] blueValue = new float[16];
            
            
            
void setup() {
size(640,478, P3D);
ethno = loadImage("1-17_04_wed.JPG");
            
}
            
            
void draw() {
background (255);
stroke(0);
strokeWeight(5);
smooth();
//image(ethno, 0, 0);
            
            
for (int i =80; i<width; i+=160) {
for(int j= 60; j<height; j+= 120) {
            
color c = ethno.get (i,j);
            
float valueR = red(c);
//println("red = " + valueR);
            
float valueG = green(c);
//println("green = " + valueG);
            
float valueB = blue(c);
//println("blue = " + valueB);
            
for(int k =0; k < 16; k++) {
redValue[k] = valueR;
greenValue[k] = valueG;
blueValue[k] = valueB;
        
            
beginShape();
vertex(redValue[k], greenValue[k], blueValue[k]);
endShape(CLOSE);
}
}
}
}
            
 
           
 
            
           I'm still very new to Processing, so please forgive me for asking what I'm sure is a silly question.
I've been working on a sketch that takes the red, green and blue values from 16 points in an image. The 16 points are equally spaced throughout the image. I have then used the RGB values to form 16 XYZ vertex points. The idea is that I get a squiggly line on a blank canvas.
When I do the excercise long-hand, filling in the numerical values manually, everything is fine. But I've tried to create arrays for the RGB values, and now when the vertex draws I only get points - no squiggly line.
The mistake is probably simple, but I'm having difficulty finding it. If anyone can help, I'd be extremely grateful.
Thanks, Andy
PImage ethno;
float [] redValue = new float[16];
float [] greenValue = new float[16];
float [] blueValue = new float[16];
void setup() {
size(640,478, P3D);
ethno = loadImage("1-17_04_wed.JPG");
}
void draw() {
background (255);
stroke(0);
strokeWeight(5);
smooth();
//image(ethno, 0, 0);
for (int i =80; i<width; i+=160) {
for(int j= 60; j<height; j+= 120) {
color c = ethno.get (i,j);
float valueR = red(c);
//println("red = " + valueR);
float valueG = green(c);
//println("green = " + valueG);
float valueB = blue(c);
//println("blue = " + valueB);
for(int k =0; k < 16; k++) {
redValue[k] = valueR;
greenValue[k] = valueG;
blueValue[k] = valueB;
beginShape();
vertex(redValue[k], greenValue[k], blueValue[k]);
endShape(CLOSE);
}
}
}
}
 
              
              1  
            
 
            