Skip to content

Commit

Permalink
tweaks to particle emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
mgasner committed Dec 2, 2017
1 parent 9fa038b commit 1b3c90e
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,24 @@
</canvas>
<div style="z-index: 1; position:relative;">
<center>
<h1 id="maninbusinesssuitlevitating" onmouseover="activate();">🕴</h1>
<h1 id="maninbusinesssuitlevitating">🕴</h1>
<h2>1f574, LLC</h2>
Contract product and engineering management.<br />
<a href="mailto:[email protected]">[email protected]</a>
</center>
</div>
</div>
<script type="text/javascript">

var canvas;
var context;
var proton;
var renderer;
var emitter;
var stats;

setTimeout(activate, 2000);

function resizeCanvas(){
const canvas = document.getElementById("canvas");
if (canvas.width < window.innerWidth)
Expand All @@ -30,15 +40,13 @@ <h2>1f574, LLC</h2>
{
canvas.height = window.innerHeight;
}
if (emitter) {
const box = document.getElementById('maninbusinesssuitlevitating').getBoundingClientRect();
emitter.p.x = box.left + box.width / 2;
emitter.p.y = box.top + box.height / 2;
}
}

var canvas;
var context;
var proton;
var renderer;
var emitter;
var stats;

function activate() {
canvas = document.getElementById("canvas");
canvas.width = window.innerWidth;
Expand All @@ -60,20 +68,20 @@ <h2>1f574, LLC</h2>
function createProton(image) {
proton = new Proton;
emitter = new Proton.Emitter();
emitter.rate = new Proton.Rate(new Proton.Span(1, 10), new Proton.Span(.5, 2));
emitter.rate = new Proton.Rate(new Proton.Span(2, 10), new Proton.Span(2, 4));
emitter.addInitialize(new Proton.ImageTarget(image));
emitter.addInitialize(new Proton.Mass(1));
emitter.addInitialize(new Proton.Life(2, 4));
emitter.addInitialize(new Proton.Mass(new Proton.Span(1, 30)));
emitter.addInitialize(new Proton.Life(2, 6));
emitter.addInitialize(new Proton.V(new Proton.Span(0.5, 1.5), new Proton.Span(0, 360), 'polar'));
emitter.addBehaviour(new Proton.Alpha(1, [.7, 1]));
emitter.addBehaviour(new Proton.Scale(1, 0));
emitter.addBehaviour(new Proton.Alpha(1, [1, 1], Infinity, Proton.easeInSine));
emitter.addBehaviour(new Proton.Scale(new Proton.Span(1, 1.5), 0));
emitter.addBehaviour(new Proton.Color('random', 'random', Infinity, Proton.easeInSine));
const box = document.getElementById('maninbusinesssuitlevitating').getBoundingClientRect();
emitter.p.x = box.left + box.width / 2;
emitter.p.y = box.top + box.height / 2;
emitter.addBehaviour(new Proton.Attraction(new Proton.Vector2D(emitter.p.x, emitter.p.y), 1));
emitter.emit();
proton.addEmitter(emitter);

renderer = new Proton.Renderer('canvas', proton, canvas);
renderer.start();
}
Expand Down

0 comments on commit 1b3c90e

Please sign in to comment.