Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinten committed Aug 9, 2024
1 parent dc164d6 commit 6a146ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions demos/navbutton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ let navbutton = path({
url: new URL('../../img/nav.svg', import.meta.url)
});

let targetW = 100;

gg.on('draw', (e) => {
let { ctx } = e;
let { vc } = gg.last('resize');
ctx.restore();
ctx.save();
let scale = targetW / navbutton.w * vc;
ctx.scale(scale, scale);
gg.emit('color', { fill: 'tomato' });
navbutton.draw(e);
});
6 changes: 5 additions & 1 deletion js/draw/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import svg from '../svg.js';
export default (options = {}) => {
let defaults = {
url: false,
paths: []
paths: [],
w: 0,
h: 0
};
Object.assign(defaults, options);
Object.assign(options, defaults);
Expand All @@ -26,6 +28,8 @@ export default (options = {}) => {
el.querySelectorAll('path').forEach((path) => {
options.paths.push(path.getAttribute('d'));
});
options.w = Number(el.querySelector('svg').getAttribute('width').replace('px', '')) || 0;
options.h = Number(el.querySelector('svg').getAttribute('height').replace('px', '')) || 0;
}
});
return options;
Expand Down

0 comments on commit 6a146ba

Please sign in to comment.