question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scaling a Container does not scale child graphics objects

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
themoonratcommented, Jan 17, 2017

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.

0reactions
lock[bot]commented, Feb 24, 2019

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.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found