xxxxxxxxxx
43
function setup() {
let w = mmToPixel(100); //100mm
let h = mmToPixel(100); //100mm
createCanvas(w,h,SVG);
let s = mmToPixel(80);
rectMode(CENTER);
noStroke();
fill(25);
rect(width/2,height/2,s,s);
noLoop();
}
function mousePressed() {
save();
}
//convert mm to pixel
//Inkscape = 96dpi
//Adobe = 72dpi
function mmToPixel(mm,dpi = 96) {
let inch = mm / 25.4;
let px = inch * dpi;
return px;
}
//convert mm to device pixel
//Inkscape = 96dpi
//Adobe = 72dpi
function mmToDisplayPixel(mm, dpi = 96) {
let inch = mm / 25.4;
let px = inch * dpi * window.devicePixelRatio / pixedDensity();
//let px = inch * adobeDPI;
return px;
}