Comments (2)
Thanks for the report! Conceptually this makes sense since we are tinkering with the drawing dimensions behind the scenes. In reviewing the documentation for isPointInPath, it looks like it can sometimes take arguments that are not just x and y. Do you happen to be using any of those arguments? fillRule
or path
?
This fix might entail overriding isPointInPath
and explicitly handling the argument cases with some type checking, etc... Because we only want to inflate the x / y arguments, not the possible Path2D
or fillRule
.
The quickest path to a fix would likely be writing a few simplified failing tests that emulate your use case here.
from hidpi-canvas-polyfill.
Hi,
Thank you for your quick reply.
As for your question about the fillRule or path arguments, I did not use any of them.
Unfortunately, I have never written tests and don't know how to use them.
Here is a simplified example of what I'm trying to achieve (I use d3.js):
HTML:
<canvas id="test-canvas" width="310" height="310" style="background-color:transparent; border-radius:50%; border:1px solid orange;" />
JS:
var testCanvas = d3.select("#test-canvas"),
testCtx = testCanvas.node().getContext("2d");
testCanvas.on("touchstart", function (e) {
var mouse = d3.mouse(this);
var isInPath = false,
isInPath2 = false,
mouseX = mouse[0],
mouseY = mouse[1];
var cx = testCanvas.node().getBoundingClientRect().width / 2;
var cy = testCanvas.node().getBoundingClientRect().height / 2;
testCtx.strokeStyle = "black";
//outer circle
testCtx.save();
testCtx.translate(cx, cy);
testCtx.beginPath();
testCtx.arc(0, 0, 145, 0, Math.PI * 2, false);
testCtx.stroke();
testCtx.closePath();
testCtx.restore();
isInPath = testCtx.isPointInPath(mouseX, mouseY);
//inner circle
testCtx.save();
testCtx.translate(cx, cy);
testCtx.beginPath();
testCtx.arc(0, 0, 75, 0, Math.PI * 2, false);
testCtx.stroke();
testCtx.closePath();
testCtx.restore();
isInPath2 = testCtx.isPointInPath(mouseX, mouseY);
if(isInPath && !isInPath2){
d3.event.preventDefault();
console.log('should rotate');
}
});
Thank you for your help
from hidpi-canvas-polyfill.
Related Issues (20)
- Do nothing if pixel ratio is 1 HOT 3
- Stroke lineWidth bug HOT 3
- Resizing issue HOT 5
- Safari console error HOT 4
- How to tell if polyfill has been used? HOT 1
- How do you resize the canvas? HOT 6
- Subsequent calls to `canvas.getContext('2d')` results in exponential growth of width and height HOT 6
- is there something wrong when drawImage? HOT 1
- It seem that there is no processing for drawImage HOT 5
- problem on idevice iphone ipad HOT 2
- ios10 has bug #17 HOT 1
- Successive calls to getContext('2d') keeps scaling up the canvas HOT 2
- Privacy Badger by EFF, Library not working with extension enabled!
- support enable/disable
- Add default implementation for drawImage HOT 2
- Support webpack and similar web bundlers HOT 2
- iPad issues
- Android devices fps is too slow now.
- There is no mechanism for resize handling. HOT 2
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 hidpi-canvas-polyfill.