Jump to content

PIXI Mask with transparency lines


di_lix
 Share

Recommended Posts

Hi guys!
I'm trying to create PIXI mask with transparency at the top and at the bottom of rectangle. To make transparency I draw 10 lines with different alpha at the top, then draw a rectangle and 10 lines at  the bottom. But the problem is that mask is created  without transparency. It just makes 10 lines without alpha.  How to achieve a transparency effect without using png sprite? Just PIXI.Graphics. Thank you!

Here is my code:

var mask = new PIXI.Graphics(),
    x = 0,
    y1 = 200,
    y2 = 600,
    width = 1000,
    alpha = 0.1,
    steps = 10,
    i;

//first block of 10 lines 
for (i = 0; i < steps; i++) {
    mask.moveTo(0, y1 + i);
    mask.lineStyle(1, "0xffffff", alpha);
    mask.lineTo(width, y1 + i);
    alpha += 0.1;
}

//Rectangle
mask.beginFill("0xffffff");
mask.drawRect(x, y1 + steps, width, 390);
mask.endFill();
alpha = 1;


//second block of 10 lines 
for (i = 0; i < steps; i++) {
    mask.moveTo(0, y2 + i);
    mask.lineStyle(1, "0xffffff", alpha);
    mask.lineTo(width, y2 + i);
    alpha -= 0.1;
}

 

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...