-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Open
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.0.5
Web browser and version
Chrome, Firefox
Operating system
Windows
Steps to reproduce this
Steps:
- use textToContours at Chrome and Firefox.
- Centering is successful in Chrome.
- Centering is failure in Firefox.
Snippet:
async function setup() {
createCanvas(400, 400);
font = await loadFont('https://inaridarkfox4231.github.io/assets/KosugiMaru-Regular.ttf');
textAlign(CENTER,CENTER);
textSize(280);
const contours = font.textToContours('海', width/2, height/2, { sampleFactor: 0.5 });
background(220);
const ctx = drawingContext;
ctx.fillStyle = "blue";
drawContours(contours, ctx);
}
function drawContours(contours, ctx){
ctx.beginPath();
for(const contour of contours){
for(let k=0; k<contour.length; k++){
if(k===0){
ctx.moveTo(contour[0].x, contour[0].y);
}else{
ctx.lineTo(contour[k].x, contour[k].y);
}
}
ctx.lineTo(contour[0].x, contour[0].y);
}
ctx.closePath();
ctx.fill();
}
Microsoft Edge

Firefox
