# Is masking available for vector shapes, outside of PImage.mask()?

**URL:** <https://discourse.processing.org/t/is-masking-available-for-vector-shapes-outside-of-pimage-mask/24320>\
**Category:** Libraries\
**Created:** [October 4, 2020, 12:59am UTC](https://discourse.processing.org/t/is-masking-available-for-vector-shapes-outside-of-pimage-mask/24320 "2020-10-04T00:59:21Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [October 4, 2020, 8:09pm UTC](https://discourse.processing.org/t/is-masking-available-for-vector-shapes-outside-of-pimage-mask/24320/3 "2020-10-04T20:09:27Z")

</div>

That’s a great question!

You could install from the IDE the Geomerative library that can do SVG and “RShape” clipping and intersections. (RShape is a vector object for the lib).

```auto
import geomerative.*;

RShape shp1;
RShape shp2;
RShape shp3;
RShape cursorShape;

void setup()
{
  size(400, 400);
  smooth();

  RG.init(this);

  shp1 = RG.loadShape("Toucan.svg");
  shp2 = RShape.createStar(0, 0, 100.0, 80.0, 20);

  shp1.centerIn(g);
}

void draw()
{
  background(255);    
  translate(width/2,height/2);

  cursorShape = new RShape(shp2);
  cursorShape.translate(mouseX - width/2, mouseY - height/2);
  
  // Only intersection() does not work for shapes with more than one path
  shp3 = RG.intersection( shp1, cursorShape );
  
  strokeWeight( 3 );

  if(mousePressed){
    fill( 0 , 220 , 0 , 30 );
    stroke( 0 , 120 , 0 );
    RG.shape(shp1);

    fill( 220 , 0 , 0 , 30 );
    stroke( 120 , 0 , 0 );
    RG.shape(cursorShape);
  }
  else{
    fill( 220 );
    stroke( 120 );
    RG.shape(shp3);
  }
}

```

 ![geomerative](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/ec7e3065167aad27ad229cdfd9c2bfa88ed59777.gif)

I _really_ wish there would be a simpler way. I have found some poly clipping libraries I thought I could adapt, but they are horribly broken ☹ (watch me crash here [Boolean operation in polygons](https://discourse.processing.org/t/boolean-operation-in-polygons/23439))

---

_[View the full topic](https://discourse.processing.org/t/is-masking-available-for-vector-shapes-outside-of-pimage-mask/24320)._
