Code: Select all
createMask() {
// Fill the entire artboard with black
this.maskGraphics.clear()
this.maskGraphics.moveTo(0, 0)
this.maskGraphics.lineTo(this.artboardWidth, 0)
this.maskGraphics.lineTo(this.artboardWidth, this.artboardHeight)
this.maskGraphics.lineTo(0, this.artboardHeight)
this.maskGraphics.closePath()
this.maskGraphics.fill(hexToRGBA('#000000', 0.5))
// Create the polygon hole
const poly = new Graphics()
poly.moveTo(this.data.coords[0].x, this.data.coords[0].y)
for (let i = 1; i < this.data.coords.length; i++) {
poly.lineTo(this.data.coords[i].x, this.data.coords[i].y)
}
poly.closePath()
poly.fill('#ffffff')
poly.blendMode = 'erase'
// Add the polygon hole to the mask
this.maskGraphics.addChild(poly)
// Setup masked container
this.maskedPolyContainer.addChild(this.maskGraphics)
this.maskedPolyContainer.mask = poly
// Add to main container
this.container.addChild(this.maskedPolyContainer)
}
Ich habe es mit blendMode = 'erase' versucht, aber dadurch wird alles unter dem Polygon gelöscht. Ich kann kein aktuelles Beispiel mit 8.x zum Implementieren von Rendergruppen sehen.
Irgendwelche Tipps, wie man das angeht?
Mobile version