magnifying glass
in
Programming Questions
•
4 months ago
Hi,
i try to visualize a magnifying glass.
With this part i get the lens of the magnifying glass:
i try to visualize a magnifying glass.
With this part i get the lens of the magnifying glass:
- public PImage lensOver(float radius, int feather) {
temp = parent.get((int) this.x,(int) this.y, (int) radius * 2, (int) radius * 2);
lenseImage = parent.createImage(temp.width, temp.height, PConstants.ARGB);
lenseImage.loadPixels();
for (int y = 0; y < lenseImage.height; y++) {
for (int x = 0; x < lenseImage.width; x++) {
int index = y + x * lenseImage.width;
float d = PApplet.dist(x, y, radius, radius);
if (d > radius) {
lenseImage.pixels[index] = 0;
} else if (d >= radius - feather) {
int c = temp.pixels[index];
int r = (c >> 16) & 0xff;
int g = (c >> 8) & 0xff;
int b = (c) & 0xff;
c = parent.color(r, g, b, PApplet.map(d, radius, radius, 255, 0));
lenseImage.pixels[index] = c;
} else {
lenseImage.pixels[index] = temp.pixels[index];
}
}
}
lenseImage.updatePixels();
return lenseImage;
}
now i get the lens:
- PImage lenseImage = lensOver(radius, feather);
now how can i scale the image behind the lens without scaling the lens?
1