Skip to content

Commit 2c89712

Browse files
authored
Merge pull request #208 from zenozeng/svg-element-event-listener
fix: SVGElement event listener
2 parents 0d8d1ec + 7149566 commit 2c89712

File tree

8 files changed

+41
-18
lines changed

8 files changed

+41
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v1.3.1
2+
3+
- fix(SVGCanvasElement): addEventListener, fixes https://github.com/zenozeng/p5.js-svg/issues/202, fixes https://github.com/zenozeng/p5.js-svg/issues/196
4+
15
## v1.3.0
26

37
- feat: loadPixels() for https://github.com/zenozeng/p5.js-svg/issues/203

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ and manipulating existing SVG file without rasterization.
99
Add this line in your projects index.html :
1010

1111
```html
12-
<script src="https://unpkg.com/[email protected].0"></script>
12+
<script src="https://unpkg.com/[email protected].1"></script>
1313
```
1414

15-
(p5.js-svg v1.2.x is compatible with p5.js v1.4.1)
15+
(p5.js-svg v1.3.x is compatible with p5.js v1.4.1)
1616

1717
Open your sketch.js and edit it:
1818

examples/examples/click.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
let value = 0;
2+
3+
function draw() {
4+
fill(value);
5+
rect(25, 25, 50, 50);
6+
}
7+
8+
function mouseClicked() {
9+
if (value === 0) {
10+
value = 255;
11+
} else {
12+
value = 0;
13+
}
14+
}

examples/examples/drop.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function setup() {
2+
let canvas = createCanvas(windowWidth, windowHeight, SVG);
3+
canvas.drop(() => {
4+
console.log('ondrop')
5+
})
6+
}

examples/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<!doctype html>
22
<head>
33
<meta charset="UTF-8">
4-
<script src="https://unpkg.com/p5@1.3.1/lib/p5.js"></script>
5-
<script src="https://unpkg.com/p5.js-svg@1.0.7"></script>
4+
<script src="https://unpkg.com/p5@1.4.1/lib/p5.js"></script>
5+
<script src="../dist/p5.svg.js"></script>
66
<script src="https://unpkg.com/[email protected]/dist/abcjs-basic-min.js"></script>
77
<script src="lib/rainbow.js"></script>
88
<link rel="stylesheet" type="text/css" href="lib/rainbow.css">
99
<link rel="stylesheet" type="text/css" href="styles.css">
1010
</head>
1111
<body>
12-
<h1>Examples for p5.SVG 1.0.7</h1>
12+
<h1>Examples for p5.SVG</h1>
1313
<ul>
1414
<li><a href="#basic">Basic 2D Shapes in SVG</a></li>
1515
<li><a href="#filters">Basic P5 Filters in SVG</a></li>

examples/lib/demo.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ var route = function() {
2525
Rainbow.color(code, 'javascript', function(code) {
2626
elt.innerHTML = code;
2727
});
28-
var functions = ['setup', 'draw', 'mouseClicked', 'mousePressed', 'preload'];
28+
var functions = ['setup', 'draw', 'mousePressed', 'preload', 'mouseClicked'];
2929
functions.forEach((fn) => window[fn] = null); // reset
3030
var patch = functions.map((fn) => `window.${fn} = typeof ${fn} === 'undefined' ? null : ${fn};`).join('\n');
31-
console.log(patch);
3231
eval(code + patch);
3332
new p5(null, document.getElementById("canvas")); // global init p5
3433
};

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "p5.js-svg",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"main": "./src/index.js",
55
"scripts": {
66
"start": "python3 -m http.server 3000",
@@ -29,7 +29,7 @@
2929
"mocha": "^9.2.0",
3030
"puppeteer": "^13.1.3",
3131
"rollup": "^2.45.2",
32-
"svgcanvas": "^2.2.0"
32+
"svgcanvas": "^2.2.1"
3333
},
3434
"directories": {
3535
"test": "test"

0 commit comments

Comments
 (0)