Comments (6)
I believe changing the pixel density will also have similar effects, so I'm updating the title of the issue to include that too.
from p5.js.
Good catch! @wong-justin do you want to take a look at this?
from p5.js.
Yes I'll have a look. Thanks @davepagurek for catching it
from p5.js.
Currently, we create a new filter shader graphic if one does not yet exist here, matching the main canvas's size and density:
p5.js/src/webgl/p5.RendererGL.js
Lines 982 to 998 in 3d62084
However, once it has been made, we never check if it needs to be resized. I think to fix this, we can add an else
branch to that if
, and inside it, check if the width/height and pixel density still match, and if not, call this.filterGraphicsLayer.resizeCanvas(this.width, this.height)
and this.filterGraphicsLayer.pixelDensity(this.pixelDensity())
.
from p5.js.
if (!this.filterGraphicsLayer) {
// the real _pInst is buried when this is a secondary p5.Graphics
const pInst = this._pInst instanceof p5.Graphics ? this._pInst._pInst : this._pInst;
// create secondary layer
this.filterGraphicsLayer = new p5.Graphics(
this.width,
this.height,
constants.WEBGL,
pInst
);
// geometries/borders on this layer should always be invisible
this.filterGraphicsLayer.noStroke();
} else {
// Check if dimensions or pixel density need to be resized
if (
this.filterGraphicsLayer.width !== this.width ||
this.filterGraphicsLayer.height !== this.height ||
this.filterGraphicsLayer.pixelDensity() !== this.pixelDensity()
) {
// Resize the graphics layer
this.filterGraphicsLayer.resizeCanvas(this.width, this.height);
this.filterGraphicsLayer.pixelDensity(this.pixelDensity());
}
}
do you think this looks good. I think we can have the else
and if
merged into one and using else if
. what do you think?
from p5.js.
Thanks, @Gaurav-1306, that looks good!
I think we can have the else and if merged into one and using else if.
Agreed, that works!
from p5.js.
Related Issues (20)
- Fix broken link in documentation_style_guide.md
- Should setCamera() also call resetMatrix()? HOT 6
- Suggestion of a function to get screen coordinates HOT 5
- get() and/or pixelDensity() lag since v1.8.0 HOT 1
- background with alpha unexpected behavior HOT 1
- Current status of maintenance tasks, package audits, tracking tech debt, etc HOT 2
- On Latest Version of Safari SetUniform Doesn't Update in Draw Function HOT 3
- cam.ortho() on framebuffer cameras and no args uses the size from the main canvas
- Should `createCamera` still auto-set itself as the default camera? HOT 1
- inconsistent parameter handling HOT 2
- Possible bug with trigonometry functions HOT 2
- getting wrong language in the console. HOT 4
- Hit detection on 2D Shapes HOT 1
- Docker implementation HOT 3
- Broken link to dev_notes.md in the documentation HOT 1
- "point" class documentation text misprint HOT 8
- p5.Vector reflect() unexpectedly modifies surface normal argument HOT 2
- [p5.js 2.0 RFC Proposal]: Pruning
- orbitControl() customizability HOT 2
- clearDepth() example broken
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p5.js.