Jump to content

pixijs masking help


Recommended Posts


Need help on my project and I am pretty new on pixijs. I need to mask an image ( avatar ) with circle( like border-radius ) and make the image contained and behaves like a background contain or cover.

 // set player avatar
      this.maskC[x] = new PIXI.Graphics();
      this.maskC[x].beginFill(0, 1);
      this.maskC[x].drawCircle(0, 0, 50);
      this.maskC[x].width = this.profile_container[x].width * .2;
      this.maskC[x].height = this.maskC[x].width;
      this.maskC[x].renderable = true;
      const texture = PIXI.Texture.from(`${data[x].avatar}`);
      this.avatar[x] = new PIXI.Sprite(texture);
      this.avatar[x].mask = this.maskC[x];
      this.avatar[x].position.x = this.profile_container[x].width * .08;
      this.maskC[x].position.x = this.avatar[x].position.x + (this.avatar[x].position.x * .5);
      this.maskC[x].position.y = rank.position.y + (this.maskC[x].height/5);

Thanks in advance.

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.

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.


  • Recently Browsing   0 members

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