Scaling a Container does not scale child graphics objects
See original GitHub issueI’ve noticed an issue in Pixi where upon scaling a Container, any primitive Graphics objects are not scaled, while other objects such as Sprite are scaled.
Here is the code that I use for scaling, just in case it’s useful:
scroll($event){
this.zoom($event.deltaY, $event.offsetX, $event.offsetY);
}
zoom(deltaY, offsetX, offsetY){
deltaY = (deltaY > 0) ? 1.1 : 0.9;
var worldPos = {x: (offsetX - this.stage.x) / this.stage.scale.x, y: (offsetY - this.stage.y)/this.stage.scale.y};
var newScale = {x: this.stage.scale.x * deltaY, y: this.stage.scale.y * deltaY};
var newScreenPos = {x: (worldPos.x ) * newScale.x + this.stage.x, y: (worldPos.y) * newScale.y + this.stage.y};
this.stage.x -= (newScreenPos.x - offsetX) ;
this.stage.y -= (newScreenPos.y - offsetY) ;
this.stage.scale.x = newScale.x;
this.stage.scale.y = newScale.y;
console.log(this.stage.children);
}
$event
is simply a browser event. When this code runs, all the children Sprite objects of stage
are scaled appropriately. However, primitive Graphics objects (in my case a bezier curve) are not scaled at all.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Scaling a Container does not scale child graphics objects #3600
I've noticed an issue in Pixi where upon scaling a Container, any primitive Graphics objects are not scaled, while other objects such as...
Read more >Scaling a container does not affect width of child
I've got a container(sprite) with children(sprites) added to it. When I scale the container, I would like to get the new width of...
Read more >Resize object and parent objects based on child dimensions
The red box is set to be 176x235 pixels and I want to resize it up to 768x1024 pixels and have the the...
Read more >Automatic scaling (Windows Forms .NET) - Microsoft Learn
The ScaleChildren property can be overridden to determine if their child controls should be scaled or not. The GetScaledBounds method can be ...
Read more >How to make an svg scale with its parent container
The reason why it is tricky to scale SVG is that it does not scale like the other image formats. SVG images have...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @KosGrillis
I’m looking at our examples page, and I can’t replicate what you are seeing? I’m looking at https://pixijs.github.io/examples/#/basics/graphics.js and adding
stage.scale.set(2);
on line 6. The stage is scaling as expected, including the primitive graphics.This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.