-
-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request make resolution dynamic #37
Comments
Hi @EloB, Using Here are my findings: Scaling the It's better and more performant to scale a complete canvas using css instead of the internal resolution property. The resolution property is nice to have it sharp for retina displays, although you could resize the contents of the PIXI elements at once, perhaps it's a better practise to just simply scale the stage object: You can also use the Pass You can use the <Stage>
<Provider>
{ app => (
<MyComponent resolution={app.renderer.resolution} />
)}
</Provider>
</Stage> Handle resolution changes Right now the function onResolutionChange() {
renderer.resolution = resolution
renderer.rootRenderTarget.resolution = resolution
renderer.plugins.interaction.destroy()
renderer.plugins.interaction = new PIXI.interaction.InteractionManager(renderer)
renderer.resize(this.width, this.height)
} Would love to hear your thoughts on this. |
That's why I said it was an ugly hack 😃
That will only scale the bitmap? So it might look blurry? The I seems like Pixi always multiplies with the I know that The first app I built then I passed around a context consumer into each component and multiplied all values myself. The code looked really ugly and can't be any reconciliation optimization at all. Another idea might be to use const App = ({ children, resolution }) => (
<Stage width={1920 * resolution} height={1080 * resolution}>
<ResolutionContext.Provider value={resolution}>
<Container scale={resolution}>
{children}
</Container>
</ResolutionContext.Provider>
</Stage>
);
That solution doesn't trigger on
Haven’t tried it but looks good to me 😃 |
Yes you're right, I'm afraid using CSS might blur the canvas if you're scaling it up.
Yes it's true that the resolution is internally used to multiply it with the component dimensions, but using the resolution property for scaling things up/down doesn't feel right to me. 😉 SolutionIdeally the If you'd like you can create a PR and see if we can come up with a good solution? |
I can agree that |
Feel free to create a PR and collaborate on it together 😉 |
I'm closing this issue, again feel free to create a PR with a solution and we'll work on it together and merge it in this codebase. 😃 |
When I have some time I will try todo something :) |
Working with
resolution
really fits React. You can define components and set their sizes and let theresolution
do it's magic.Preferred solution would be to set the Stage to the desired dimension with static values (best practice to use the same dimension as the design files to be able to copy values) for instance
1920x1080
and useresolution
to scale each object and canvas. On rare occasions you need theresolution
so it would be good if it's being passed as acontext
.Example
This is just an ugly hack with
key
.http://jsbin.com/heyonevonu/1/edit?js,output
Using this plugin. You gain a lot of easy performance! :)
https://babeljs.io/docs/en/next/babel-plugin-transform-react-constant-elements.html
The text was updated successfully, but these errors were encountered: