Sign in to follow this  

Masking black SVG image to create a color

Recommended Posts

Hi guys,

I think I have problem how masking in PIXIjs works.

I have this image of black horse Flat_racing_clipart.svg

And I would like to use masking in order to give it the color.

Here is my code so far:

const app = new PIXI.Application({backgroundColor: 0xFFFFFF})


PIXI.loader.add('assets/horse.png').load(() => {
  const horse_sprite = new PIXI.Sprite(PIXI.loader.resources['assets/horse.png'].texture)
  const horse_mask = new PIXI.Graphics()
  horse_square.drawRect(0, 0, 130, 130)
  horse_mask.mask = horse // I can see the horse and the square if I comment this out

It's not working, I can't see anything, not a horse nor the square.


Share this post

Link to post
Share on other sites

Masking works both by alpha and red channel. For black color, red channel is 0. 

How to solve it, 3 ways:

1. Make your horse white.

2. Make your horse white AND use "tint" attribute instead of using it as a mask for a square. Its significantly faster.

3. hard, rebuild pixi so it accepts masks of any color:




Share this post

Link to post
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.

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.