We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to scale this square using a scale(2); function to make the pink square fill the whole size (or at least twice the size).
Does anyone know how?
this is my current simple code
//CODE----------------------------
color pink = color(255, 102, 204);
int loc = 0;
void setup(){
size(300,300);
}
void draw(){
loadPixels();
for (int i = 0; i < width/2; i++) {
for(int j = 0; j < height/2; j++){
loc = i + (j*width);
pixels[loc] = pink;
}
}
updatePixels();
}
Answers
is there a reason why you are not using the
rect()
method for your square andpushMatrix()
/popMatrix()
for matrix tranformations like scaling and skewing and translating??The scale() function has no effect on pixels[], it is intended for shapes drawn in Processing like @Kobby wrote. For reference: http://www.processing.org/reference/scale_.html
If you still want to accomplish this using pixels[] then change the conditions in the for loop.
I'm using a kinect, and a silhouette of the user function is drawn using userMap() from SimpleOpenNI. The userMap is using these pixels array. So I'd like to resize my silhouette to be bigger than 640 x 480 which is what its capturing in thats all. so i guess it isnt possible huh. thanks for the info.
I think you could work the math of the loops as @asimes suggested kind of making a interpolation algorithm... I don't know how to do that. But, now that you explained the need, maybe a PGraphics approach can be enough. Some thing like:
cool. that PGraphics is just what I'm missing.
Perfect thanks _vk i'll try it out in a bit
Yes it works, I found another example code from here. uses the same concept
http://cs.marlboro.edu/courses/spring2013/dedhour/kinect.attachments/kinectBackgroundRemoval.pde
Thanks this worked for me! Here is my code using windows 7. Without using the opengl because that seemed to cause some lagg.