diff options
author | Saivan <savian@me.com> | 2018-05-26 00:01:33 +1000 |
---|---|---|
committer | Saivan <savian@me.com> | 2018-05-26 00:01:33 +1000 |
commit | cbf1359e0ab469e1137450192b7d612501c4bb5c (patch) | |
tree | 9c16890a36184cf02b86a2a6c948065e83ecc226 /dirty.html | |
parent | 69869d25c4b8fb4cd0f428ead4112ebb14dd2fb4 (diff) | |
download | svg.js-cbf1359e0ab469e1137450192b7d612501c4bb5c.tar.gz svg.js-cbf1359e0ab469e1137450192b7d612501c4bb5c.zip |
Fixed all of the low hanging problems so declarative works
Diffstat (limited to 'dirty.html')
-rw-r--r-- | dirty.html | 57 |
1 files changed, 29 insertions, 28 deletions
@@ -75,37 +75,38 @@ function getColor(t) { // } // } -var randPoint = (x = 50, y = 50) => [ - Math.random() * 100 - 50 + x, - Math.random() * 100 - 50 + y -] - -var poly = SVG('<polygon>').plot([ - randPoint(), - randPoint(), - randPoint(), - randPoint(), - randPoint() -]).attr({fill: 'none', stroke: 'black'}).addTo('svg') -var polyAni = poly.animate(SVG.PID(null, 0)) - -SVG.on(document, 'click', function (e) { - polyAni.plot([ - randPoint(e.pageX-50, e.pageY-50), - randPoint(e.pageX+50, e.pageY-50), - randPoint(e.pageX+50, e.pageY), - randPoint(e.pageX+50, e.pageY+50), - randPoint(e.pageX-50, e.pageY+50) - ]) -}) -/* -var mover = SVG('rect').clone().show() -var anim = mover.animate(SVG.PID()).move(500, 500) +// var randPoint = (x = 50, y = 50) => [ +// Math.random() * 100 - 50 + x, +// Math.random() * 100 - 50 + y +// ] +// +// var poly = SVG('<polygon>').plot([ +// randPoint(), +// randPoint(), +// randPoint(), +// randPoint(), +// randPoint() +// ]).attr({fill: 'none', stroke: 'black'}).addTo('svg') +// var polyAni = poly.animate(new SVG.PID(null, 0)) +// +// SVG.on(document, 'click', function (e) { +// polyAni.plot([ +// randPoint(e.pageX-50, e.pageY-50), +// randPoint(e.pageX+50, e.pageY-50), +// randPoint(e.pageX+50, e.pageY), +// randPoint(e.pageX+50, e.pageY+50), +// randPoint(e.pageX-50, e.pageY+50) +// ]) +// }) + +var mover = SVG('<ellipse>').size(50, 50).center(100, 100).addTo('svg') +var anim = mover.animate(SVG.PID(null, null, null, false)).move(500, 500) SVG.on(document, 'mousemove', function (e) { //mover.animate(SVG.PID()).move(e.pageX, e.pageY) - anim.move(e.pageX, e.pageY) -})*/ + var p = mover.point(e.pageX, e.pageY) + anim.center(p.x, p.y) +}) </script> |