You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I found a problem with the subdivide function. It makes a Shape shorter if it is not closed, or it fails on the last segment if it is.
Is it a problem in my code?
Line:13 versione = v0.8.16
Line:26 Line:
Line:27 Vertices base: 2 vs sub2: 3 vs sub16: 17
Line:28 Length base: = 800 vs sub2: 592.5925925925926 vs sub16: 792.0211683289233
Line:48 Left path:
Line:49 Vertices base: 4 vs sub: 11
Line:50 Length base: = 1200 vs sub: 1200
Line:69 Right path:
Line:70 Vertices base: 4 vs sub: 9
Line:71 Length base: = 1200 vs sub: 1096.2962962962963
Line:79 END
To Reproduce
I am not using Module, this is the code for the above image:
`
let two = new Two({
type: Two.Types.svg,
fullscreen: true,
autostart: true
});
two.appendTo(document.body);
console.log(`Version = ${Two.Version}`);
let baseLine = two.makeLine(100, 30, 900, 30);
let subLine2 = baseLine.clone(); //it is the same if I use makeLine again
subLine2.position.y += 10
subLine2.stroke = "#ff0000";
subLine2.subdivide(2);
two.add(subLine2);
let subLine16 = baseLine.clone(); //it is the same if I use makeLine again
subLine16.position.y += 20
subLine16.stroke = "#ff0000";
subLine16.subdivide(16);
two.add(subLine16);
console.log("Line:");
console.log(`Vertices base: ${baseLine.vertices.length} vs sub2: ${subLine2.vertices.length} vs sub16: ${subLine16.vertices.length}`);
console.log(`Length base: = ${baseLine.length} vs sub2: ${subLine2.length} vs sub16: ${subLine16.length}`);
var pos = subLine2.position;
for (let i = 0; i < subLine2.vertices.length; i++) {
let p = subLine2.vertices[i];
two.makeCircle(p.x + pos.x, p.y + pos.y, 2).fill = "#00ff00";
}
pos = subLine16.position;
for (let i = 0; i < subLine16.vertices.length; i++) {
let p = subLine16.vertices[i];
two.makeCircle(p.x + pos.x, p.y + pos.y, 2).fill = "#00ff00";
}
let basePath = two.makePath(100, 100, 500, 100, 500, 500, 100, 500);
let subPath = basePath.clone(); //it is the same if I use makePath again
subPath.noFill();
subPath.stroke = "#ff0000";
subPath.position.y += 20
subPath.position.x += 20
two.add(subPath);
subPath.subdivide(2);
console.log("Left path:");
console.log(`Vertices base: ${basePath.vertices.length} vs sub: ${subPath.vertices.length}`);
console.log(`Length base: = ${basePath.length} vs sub: ${subPath.length}`);
pos = subPath.position;
for (let i = 0; i < subPath.vertices.length; i++) {
let p = subPath.vertices[i];
//console.log(`V = ${p.x}`);
two.makeCircle(p.x + pos.x, p.y + pos.y, 2).fill = "#00ff00";
}
let basePath2 = basePath.clone();
basePath2.closed = false;
two.add(basePath2);
basePath2.position.x += 550;
let subPath2 = basePath2.clone(); //it is the same if I use makePath2 again
subPath2.noFill();
subPath2.stroke = "#ff0000";
subPath2.position.y += 20
subPath2.position.x += 20
two.add(subPath2);
subPath2.subdivide(2);
console.log("Right path:");
console.log(`Vertices base: ${basePath2.vertices.length} vs sub: ${subPath2.vertices.length}`);
console.log(`Length base: = ${basePath2.length} vs sub: ${subPath2.length}`);
pos = subPath2.position;
for (let i = 0; i < subPath2.vertices.length; i++) {
let p = subPath2.vertices[i];
//console.log(`V = ${p.x}`);
two.makeCircle(p.x + pos.x, p.y + pos.y, 2).fill = "#00ff00";
}
console.log("END");
`
Expected behavior
The subdivided shape is the same of the original
Screenshots
See above
Environment (please select one):
[X ] Code executes in browser (e.g: using script tag to load library)
Hi, I found a problem with the subdivide function. It makes a Shape shorter if it is not closed, or it fails on the last segment if it is.
Is it a problem in my code?
Line:13 versione = v0.8.16
Line:26 Line:
Line:27 Vertices base: 2 vs sub2: 3 vs sub16: 17
Line:28 Length base: = 800 vs sub2: 592.5925925925926 vs sub16: 792.0211683289233
Line:48 Left path:
Line:49 Vertices base: 4 vs sub: 11
Line:50 Length base: = 1200 vs sub: 1200
Line:69 Right path:
Line:70 Vertices base: 4 vs sub: 9
Line:71 Length base: = 1200 vs sub: 1096.2962962962963
Line:79 END
To Reproduce
I am not using Module, this is the code for the above image:
`
let two = new Two({
type: Two.Types.svg,
fullscreen: true,
autostart: true
});
`
Expected behavior
The subdivided shape is the same of the original
Screenshots
See above
Environment (please select one):
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: