Jump to content

How to drawPolygon twice for poor man shadow effect?


Alexander Farber
 Share

Recommended Posts

Good evening,

with pixi.js v3 I was using the following code to draw a shadow underneath a polygon (here full source code of Score.js):

this.filters = [ new PIXI.filters.DropShadowFilter() ];
this.filters[0].alpha = .2;

But with pixi.js v4 I can not use that filter anymore.

Here are the two polygons I need to draw, blue and red:

Screen Shot 2016-11-26 at 16.39.38.png

Instead of using drop shadow filer, I would like to draw the same polygon in translucent gray, offset by few pixels.

Could someone please help me, how to offset the polygon, I can not find anything in the pixi js docs.

Here my current code:

Score.POLY_1 = [
        new PIXI.Point(0, 0),
        new PIXI.Point(Score.WIDTH + 2, 0),
        new PIXI.Point(Score.WIDTH - 2, Score.HEIGHT / 2),
        new PIXI.Point(Score.WIDTH + 2, Score.HEIGHT),
        new PIXI.Point(0, Score.HEIGHT)
];

// How to draw grey POLY_1 offset by few pixels here?

this.bgGraphics.clear();
this.bgGraphics.beginFill(this.color, 1);
this.bgGraphics.drawPolygon(Score.POLY_1);
this.bgGraphics.endFill();


Regards
Alex

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...