sta-ger Posted August 22, 2016 Share Posted August 22, 2016 Hi! I'm wondering is it posible in PIXI to erase some area of Graphics object? Something similar to canvas clearRect() method. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 22, 2016 Share Posted August 22, 2016 Not graphics, but someone did implementation for clearing sprite (only for rectangles), its on typescript class ClearRect extends Container { constructor ( fromX: number, fromY: number, private w: number, private h: number ) { super(); this.position.x = fromX; this.position.y = fromY; } _renderWebGL(renderer: PIXI.WebGLRenderer){ let gl = (renderer.gl as WebGLRenderingContext); let wt = this.worldTransform; gl.enable(gl.SCISSOR_TEST); // set the scissor rectangle. gl.scissor(wt.tx, wt.ty, wt.a * this.w, wt.d * this.h); // clear gl.clear(gl.COLOR_BUFFER_BIT); gl.disable(gl.SCISSOR_TEST); }; _renderCanvas(renderer: PIXI.CanvasRenderer){ let wt = this.worldTransform; renderer.context.clearRect(wt.tx, wt.ty, wt.a * this.w, wt.d * this.h); }; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.