processing

Processing: Image with rounded corners


I'm drawing a section of an image, however I'd like to apply rounded corners to it. I can't find any way of doing this.

In the draw() method:

img_section = img.get(gaze_x, gaze_y, gaze_size_x, gaze_size_y);
image(img_section, gaze_x, gaze_y);

Solution

  • You could copy the image and then manually set the corner pixels using the set() function.

    You could just draw a rounded rectangle around the image- if the image will be placed on a background with a single color, just draw a rounded rectangle with the same color as the image.

    Or you could come up with an image mask and draw that on top of your image.