Skip to content

Commit

Permalink
test gear
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinten Clause committed Aug 11, 2024
1 parent fc48674 commit b185893
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
3 changes: 2 additions & 1 deletion demos/navbutton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ gg.emit('color', { bg: 'navy', fill: 'white' });
gg.on('draw', ft({text: 'WIP: /js/draw/path.js'}).draw);

let navbutton = path({
url: new URL('../../img/nav.svg', import.meta.url),
url: new URL('../../img/gear.svg', import.meta.url),
//paths: ['M 0 0 L 1024 0 L 1024 1024 L 0 1024 Z'],
fills: ['red', 'orange','yellow'],
w: 100,
h: 100
});
Expand Down
27 changes: 27 additions & 0 deletions img/gear.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion js/draw/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default (options = {}) => {
let defaults = {
url: false,
paths: [],
fills: [],
x: 0,
y: 0,
w: 512,
Expand All @@ -16,7 +17,7 @@ export default (options = {}) => {
Object.assign(options, defaults);
options.draw = e => {
let { ctx } = e;
let { paths, x, y, w, h, a } = options;
let { paths, fills, x, y, w, h, a } = options;
let rad = a * Math.PI / 180;
let cx = w / ow;
let cy = h / oh;
Expand All @@ -35,6 +36,9 @@ export default (options = {}) => {
let np = new Path2D();
np.addPath(new Path2D(path), n);
p.addPath(np, m);
if (fills[i]) {
ctx.fillStyle = fills[i];
}
ctx.fill(p);
});
};
Expand Down

0 comments on commit b185893

Please sign in to comment.