Skip to content

Commit 274c7f6

Browse files
committed
Update demo subject-domain API
1 parent a65922f commit 274c7f6

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

JavaScript/1-HTTP/api/render.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = async name => {
99
const svg = [];
1010
svg.push('<svg viewBox="-20 -20 40 40" xmlns="http://www.w3.org/2000/svg">');
1111
svg.push('<polygon points="');
12-
svg.push(points.map(point => `${point.x},${point.y}`).join(' '));
12+
svg.push(points.map(({ x, y }) => `${x},${y}`).join(' '));
1313
svg.push('" /></svg>');
1414
return svg.join('');
1515
};

JavaScript/1-HTTP/api/resize.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const resize = (point, k) => {
2+
let { x, y } = point;
3+
x *= k;
4+
y *= k;
5+
point.x = x;
6+
point.y = y;
7+
};
8+
9+
module.exports = async (name, k) => {
10+
const shape = memory.get(name);
11+
if (!shape) return 'Shape is not found';
12+
for (const key in shape) {
13+
const point = shape[key];
14+
resize(point, k);
15+
}
16+
return 'Shape rotated';
17+
};

0 commit comments

Comments
 (0)