Hey so i am trying to magnify a 5x5 area around the mouse cursour and then draw that area in a rect.
Basicaly i want to get the surround pixels at mouse x and mouse Y .
put those pixels into an array?
use that array to draw a rect i think
what i am struggling with the most is putting this in code, it does’nt seem to click for me.
i’ve stopped and started so many times. so my code is not alot. ive tried to breck it down by understanding i can get one pixel using get()
Please please any help or advice would be amzing its due tomorrow or just a different approch you recommend would be amazing
void setup(){
size(640 , 360);
Picture=loadImage("London.jpg");
}
void draw(){
image(Picture,0,0);
//for(int y = 0; y < height; y++){ // coloum
// for(int x = 0; x < width; x++){ // row
//}
//}
color a = Picture.get(mouseX,mouseY);
fill(a);
rect(0, 0, 100, 100);
}
hey so for this task its not actually making an image bigger its more to do with getting the pixels at that point(the mouse cursor) storeing that data or the colours of those pixels and just drawing that in a different part of the sketch. Though that is a good soloution if that was my task : ) thanks for the reply
this will help show what i mean
if i was to continue doing it this way i would have to do it 25 times as i am trying the get the 5x5 area at the mouse Cursor hopefully that explains it better
hopfully that makes sense
PImage london;
void setup(){
size(640,360);
london = loadImage("London.jpg");
}
void draw(){
image(london,0,0);
// getting the pixels
color a = get(mouseX,mouseY);
color b = get(mouseX+1,mouseY);
color c = get(mouseX+2, mouseY);
color d = get(mouseX-1, mouseY);
translate(40,40);
noStroke();
fill(a);
rect(0,0,30,30);
fill(b);
rect(30,0,30,30);
fill(c);
rect(60,0,30,30);
fill(d);
rect(-30,0,30,30);
}
[px, py] is the top left corner of the colour grid. This grid contains 25 squares each one being pw pixels in size. So px, py and pw controls where and how big the colour swatch area is. Try changing the values and you will see what I mean.
The statement PImage part = get(mouseX - 2, mouseY - 2, 5, 5);
captures a 5x5 grid round the mouse position annd returns it as a PImage object.
The PImage object contains an array of integers (one per pixel) holding the pixel colour data. The next line loads this array so we can examine them. The final line colours = part.pixels;
provides a handy identifier which we can use latter for using the colour data.