svg-arc-corners
Version:
SVG arc path with rounded corners
42 lines (28 loc) • 2.48 kB
JavaScript
var tap = require('tap');
var cornerArc = require('../lib/');
tap.test('r 100 0-45 50 10', function(t) {
t.equals(cornerArc([0, 0], 100, 0, 45, 50, 10),
"M 5.5109105961630896e-15 -90 A 10 10 0 0 1 9.983341664682808 -99.50041652780259 A 100 100 0 0 1 63.29813066769583 -77.41670784769464 A 10 10 0 0 1 63.63961030678928 -63.63961030678927 L 42.42640687119285 -42.426406871192846 A 10 10 0 0 1 27.6265646093427 -41.674607711240824 A 50 50 0 0 0 9.933466539753063 -49.00332889206208 A 10 10 0 0 1 3.67394039744206e-15 -60 Z");
t.end();
});
tap.test('r 100 0-5 50 10', function(t) {
t.equals(cornerArc([0, 0], 100, 0, 5, 50, 10),
'M 5.989645753117198e-15 -97.81833843500709 A 2.1816615649929116 2.1816615649929116 0 0 1 2.181488503456116 -99.97620270799091 A 100 100 0 0 1 6.540312923014305 -99.78589232386035 A 2.1816615649929116 2.1816615649929116 0 0 1 8.52542994064484 -97.44611012509807 L 4.547931471503882 -51.98309458866376 A 2.1816615649929116 2.1816615649929116 0 0 1 2.1809693682668003 -49.95241107909289 A 50 50 0 0 0 2.1809693682668003 -49.95241107909289 A 2.1816615649929116 2.1816615649929116 0 0 1 3.195205240487952e-15 -52.181661564992915 Z');
t.end();
});
tap.test('r 100 0-360 50 10', function(t) {
t.equals(cornerArc([0, 0], 100, 0, 360, 50, 10),
"M -100 0 A 100 100 0 1 0 100 0 A 100 100 0 1 0 -100 0 M -50 0 A 50 50 0 1 0 50 0 A 50 50 0 1 0 -50 0 Z");
t.end();
});
tap.test('r 100 0-90 50 0', function(t) {
t.equals(cornerArc([0, 0], 100, 0, 90, 50, 0),
"M 6.123233995736766e-15 -100 A 0 0 0 0 1 6.123233995736766e-15 -100 A 100 100 0 0 1 100 0 A 0 0 0 0 1 100 0 L 50 0 A 0 0 0 0 1 50 0 A 50 50 0 0 0 3.061616997868383e-15 -50 A 0 0 0 0 1 3.061616997868383e-15 -50 Z");
t.end();
});
tap.test('r 100 0-5 50 0 return points', function(t) {
t.deepEquals(cornerArc([0, 0], 100, 0, 5, 50, 10, true),
["M", 5.989645753117198e-15, -97.81833843500709, "A", 2.1816615649929116, 2.1816615649929116, 0, 0, 1, 2.181488503456116, -99.97620270799091, "A", 100, 100, 0, 0, 1, 6.540312923014305, -99.78589232386035, "A", 2.1816615649929116, 2.1816615649929116, 0, 0, 1, 8.52542994064484, -97.44611012509807, "L", 4.547931471503882, -51.98309458866376, "A", 2.1816615649929116, 2.1816615649929116, 0, 0, 1, 2.1809693682668003, -49.95241107909289, "A", 50, 50, 0, 0, 0, 2.1809693682668003, -49.95241107909289, "A", 2.1816615649929116, 2.1816615649929116, 0, 0, 1, 3.195205240487952e-15, -52.181661564992915, "Z"]
);
t.end();
});