lei Posted May 9, 2019 Share Posted May 9, 2019 Hi, 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].endFill(); 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); this.avatar[x].addChild(this.maskC[x]); this.profile_container[x].addChild(this.avatar[x]); Thanks in advance. Any help I really appreciate it. Quote Link to comment Share on other sites More sharing options...
b10b Posted May 9, 2019 Share Posted May 9, 2019 First disable the line "this.avatar[x].mask = this.maskC[x];" and visually see where the mask is. Due to the addChild the mask's position will be relative to its parent (avatar) ... fixing this will be trivial once you can see it. As we don't know your exact expectation on alignment I won't suggest specifics. Quote Link to comment Share on other sites More sharing options...
lei Posted May 10, 2019 Author Share Posted May 10, 2019 Hi admins. we can't upload image with this error "/var/www/html/uploads/monthly_2019_05 could not be created." @admin 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.