1 function BouncingSvgParticle(stage)
3 BouncingParticle.call(this, stage);
6 BouncingSvgParticle.prototype = Object.create(BouncingParticle.prototype);
7 BouncingSvgParticle.prototype.constructor = BouncingParticle;
9 BouncingSvgParticle.prototype._applyClipping = function(stage)
11 if (stage.clip != "star")
14 stage.ensureClipStarIsCreated();
15 this.element.setAttribute("clip-path", "url(#star-clip)");
18 BouncingSvgParticle.prototype._move = function()
20 var transform = "translate(" + this._position.x + ", " + this._position.y + ")";
21 if (this._shape != "circle")
22 transform += this._rotater.rotate(this._size.center);
23 this.element.setAttribute("transform", transform);
26 BouncingSvgParticle.prototype.animate = function(timeDelta)
28 BouncingParticle.prototype.animate.call(this, timeDelta);
32 function BouncingSvgParticlesStage(element, options)
34 BouncingParticlesStage.call(this, element, options);
37 BouncingSvgParticlesStage.prototype = Object.create(BouncingParticlesStage.prototype);
38 BouncingSvgParticlesStage.prototype.constructor = BouncingSvgParticlesStage;
40 BouncingSvgParticlesStage.prototype._createDefs = function()
42 return DocumentExtension.createSvgElement("defs", {}, {}, this.element);
45 BouncingSvgParticlesStage.prototype._ensureDefsIsCreated = function()
47 return this.element.querySelector("defs") || this._createDefs();
50 BouncingSvgParticlesStage.prototype._createClipStar = function()
52 var attrs = { id: "star-clip", clipPathUnits: "objectBoundingBox" };
53 var clipPath = DocumentExtension.createSvgElement("clipPath", attrs, {}, this._ensureDefsIsCreated());
55 attrs = { d: "M.50,0L.38,.38L0,.38L.30,.60L.18,1L.50,.75L.82,1L.70,.60L1,.38L.62,.38z" };
56 DocumentExtension.createSvgElement("path", attrs, {}, clipPath);
60 BouncingSvgParticlesStage.prototype.ensureClipStarIsCreated = function()
62 return this.element.querySelector("#star-clip") || this._createClipStar();
65 BouncingSvgParticlesStage.prototype.particleWillBeRemoved = function(particle)
67 particle.element.remove();