Created
May 26, 2020 15:06
-
-
Save loadix/509403c2a6b0e30f97290aa757296517 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* mask, ellipse, rects | |
* Example based on: Draw a Mask example Pt.2 | |
* 2017-08-22 Processing 3.3.5 | |
https://forum.processing.org/two/discussion/23886/masking-a-shape-with-another-shape | |
**/ | |
PGraphics sourceImage1; | |
PGraphics maskImage1; | |
PGraphics sourceImage2; | |
PGraphics maskImage2; | |
size(600, 600); //size of canvas | |
///////////Círculo 1//////////////// | |
sourceImage1 = createGraphics(600, 600); //size of drawing | |
sourceImage1.beginDraw(); | |
sourceImage1.fill(255); | |
sourceImage1.rectMode(CENTER); | |
sourceImage1.rect(300, 180, 300, 20); | |
sourceImage1.rect(300, 220, 300, 20); | |
sourceImage1.rect(300, 260, 300, 20); | |
sourceImage1.rect(300, 300, 300, 20); | |
sourceImage1.rect(300, 340, 300, 20); | |
sourceImage1.rect(300, 380, 300, 20); | |
sourceImage1.rect(300, 420, 300, 20); | |
sourceImage1.endDraw(); | |
// create mask1 | |
maskImage1 = createGraphics(600, 600); //size of mask | |
maskImage1.beginDraw(); | |
noStroke(); | |
maskImage1.ellipse(300, 300, 250, 250); | |
maskImage1.endDraw(); | |
// apply mask1 and then show mask1 | |
sourceImage1.mask(maskImage1); | |
image(sourceImage1, 0, 0);//1 | |
///////////Fin Círculo 1//////////////// | |
///////////Círculo 2//////////////// | |
sourceImage2 = createGraphics(600, 600); //size of drawing | |
sourceImage2.beginDraw(); | |
sourceImage2.fill(255); | |
sourceImage2.rectMode(CENTER); | |
sourceImage2.rect(300, 200, 300, 20); | |
sourceImage2.rect(300, 240, 300, 20); | |
sourceImage2.rect(300, 280, 300, 20); | |
sourceImage2.rect(300, 320, 300, 20); | |
sourceImage2.rect(300, 360, 300, 20); | |
sourceImage2.rect(300, 400, 300, 20); | |
sourceImage2.endDraw(); | |
// create mask2 | |
maskImage2 = createGraphics(600, 600); //size of mask | |
maskImage2.beginDraw(); | |
maskImage2.ellipse(300, 300, 200, 200); | |
maskImage2.endDraw(); | |
// apply mask2 and then show mask2 | |
sourceImage2.mask(maskImage2); | |
image(sourceImage2, 0, 0);//1 | |
///////////Fin Círculo 1//////////////// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment