Canvas Orbital Trails v2
How do I make an canvas orbital trails v2?
Click and drag anywhere on the screen to create new trails. This is v2 of my original Canvas Orbital Trails.. What is a canvas orbital trails v2? How do you make a canvas orbital trails v2? This script and codes were developed by Jack Rugile on 11 August 2022, Thursday.
Canvas Orbital Trails v2 - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Canvas Orbital Trails v2</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ body { background: #000;
}
canvas { display: block;
}
#gui { left: 0; position: fixed; top: 0;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div id="gui"></div>
<!--
Canvas Orbital Trails v2
------------------------
Click and drag anywhere on the screen to create new trails.
--> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.5/dat.gui.min.js'></script>
<script src='https://rawgithub.com/soulwire/sketch.js/master/js/sketch.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Canvas Orbital Trails v2 - Script Codes CSS Codes
body { background: #000;
}
canvas { display: block;
}
#gui { left: 0; position: fixed; top: 0;
}
Canvas Orbital Trails v2 - Script Codes JS Codes
var sketch = Sketch.create(), center = { x: sketch.width / 2, y: sketch.height / 2 }, orbs = [], dt = 1, opt = { total: 0, count: 100, spacing: 2, speed: 65, scale: 1, jitterRadius: 0, jitterHue: 0, clearAlpha: 10, toggleOrbitals: true, orbitalAlpha: 100, toggleLight: true, lightAlpha: 5, clear: function(){ sketch.clearRect( 0, 0, sketch.width, sketch.height ), orbs.length = 0; } };
var Orb = function( x, y ){ var dx = ( x / opt.scale ) - ( center.x / opt.scale ), dy = ( y / opt.scale ) - ( center.y / opt.scale ); this.angle = atan2( dy, dx ); this.lastAngle = this.angle; this.radius = sqrt( dx * dx + dy * dy ); this.size = ( this.radius / 300 ) + 1; this.speed = ( random( 1, 10 ) / 300000 ) * ( this.radius ) + 0.015;
};
Orb.prototype.update = function(){ this.lastAngle = this.angle; this.angle += this.speed * ( opt.speed / 50 ) * dt; this.x = this.radius * cos( this.angle ); this.y = this.radius * sin( this.angle );
};
Orb.prototype.render = function(){ if(opt.toggleOrbitals){ var radius = ( opt.jitterRadius === 0 ) ? this.radius : this.radius + random( -opt.jitterRadius, opt.jitterRadius ); radius = ( opt.jitterRadius != 0 && radius < 0 ) ? 0.001 : radius; sketch.strokeStyle = 'hsla( ' + ( ( this.angle + 90 ) / ( PI / 180 ) + random( -opt.jitterHue, opt.jitterHue ) ) + ', 100%, 50%, ' + ( opt.orbitalAlpha / 100 ) + ' )'; sketch.lineWidth = this.size; sketch.beginPath(); if(opt.speed >= 0){ sketch.arc( 0, 0, radius, this.lastAngle, this.angle + 0.001, false ); } else { sketch.arc( 0, 0, radius, this.angle, this.lastAngle + 0.001, false ); }; sketch.stroke(); sketch.closePath(); }; if(opt.toggleLight){ sketch.lineWidth = .5; sketch.strokeStyle = 'hsla( ' + ( ( this.angle + 90 ) / ( PI / 180 ) + random( -opt.jitterHue, opt.jitterHue ) ) + ', 100%, 70%, ' + ( opt.lightAlpha / 100 ) + ' )'; sketch.beginPath(); sketch.moveTo( 0, 0 ); sketch.lineTo( this.x, this.y ); sketch.stroke(); };
};
var createOrb = function( config ){ var x = ( config && config.x ) ? config.x : sketch.mouse.x, y = ( config && config.y ) ? config.y : sketch.mouse.y; orbs.push( new Orb( x, y ) );
};
var turnOnMove = function(){ sketch.mousemove = createOrb;
};
var turnOffMove = function(){ sketch.mousemove = null;
};
sketch.mousedown = function(){ createOrb(); turnOnMove();
};
sketch.mouseup = turnOffMove;
sketch.resize = function(){ center.x = sketch.width / 2; center.y = sketch.height / 2; sketch.lineCap = 'round';
};
sketch.setup = function(){ while( opt.count-- ){ createOrb( { x: random( sketch.width / 2 - 300, sketch.width / 2 + 300 ), y: random( sketch.height / 2 - 300, sketch.height / 2 + 300 ) } ); };
};
sketch.clear = function(){ sketch.globalCompositeOperation = 'destination-out'; sketch.fillStyle = 'rgba( 0, 0, 0 , ' + ( opt.clearAlpha / 100 ) + ' )'; sketch.fillRect( 0, 0, sketch.width, sketch.height ); sketch.globalCompositeOperation = 'lighter';
};
sketch.update = function(){ dt = ( sketch.dt < 0.1 ) ? 0.1 : sketch.dt / 16; dt = ( dt > 5 ) ? 5 : dt; var i = orbs.length; opt.total = i; while( i-- ){ orbs[i].update(); }
};
sketch.draw = function(){ sketch.save(); sketch.translate( center.x, center.y ); sketch.scale( opt.scale, opt.scale ); var i = orbs.length; while( i-- ){ orbs[i].render(); } sketch.restore();
};
gui = new dat.GUI( { autoPlace: false } )
gui.add( opt, 'total' ).name( 'Total Orbitals' ).listen();
gui.add( opt, 'speed' ).min( -300 ).max( 300 ).step( 1 ).name( 'Speed' );
gui.add( opt, 'scale' ).min( 0.5 ).max( 5 ).step( 0.001 ).name( 'Scale' );
gui.add( opt, 'jitterRadius' ).min( 0 ).max( 5 ).step( 0.001 ).name( 'Radius Jitter' );
gui.add( opt, 'jitterHue' ).min( 0 ).max( 90 ).step( 1 ).name( 'Hue Jitter' );
gui.add( opt, 'clearAlpha' ).min( 0 ).max( 100 ).step( 1 ).name( 'Clear Alpha' );
gui.add( opt, 'toggleOrbitals' ).name( 'Toggle Orbitals' )
gui.add( opt, 'orbitalAlpha' ).min( 0 ).max( 100 ).step( 1 ).name( 'Orbital Alpha' );
gui.add( opt, 'toggleLight' ).name( 'Toggle Light' );
gui.add( opt, 'lightAlpha' ).min( 0 ).max( 100 ).step( 1 ).name( 'Light Alpha' );
gui.add( opt, 'clear' ).name( 'Clear' );
customContainer = document.getElementById( 'gui' );
customContainer.appendChild(gui.domElement);
document.onselectstart = function(){ return false;
};
Developer | Jack Rugile |
Username | jackrugile |
Uploaded | August 11, 2022 |
Rating | 4.5 |
Size | 3,421 Kb |
Views | 22,264 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Canvas Swarming Bugs | 4,599 Kb |
Canvas Simple Circle Loader | 2,946 Kb |
Abstract Canvas Visualization | 3,459 Kb |
Glowing Pulse Form | 2,542 Kb |
Canvas Waterfall | 3,324 Kb |
SpacePi js13k | 19,847 Kb |
Snake Game - CSS Renderer | 7,412 Kb |
Fade and Blur on Hover Data Table | 3,399 Kb |
Rainbow Loader | 2,022 Kb |
Bubble Sketch.js Test | 3,437 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Video Player Custom Controls | EleftheriaBatsou | 3,665 Kb |
Wave Lines | Mikehobizal | 4,023 Kb |
Personal Logo Animation | Lloydwheeler | 3,795 Kb |
03 - CSS Variables | Run-time | 2,682 Kb |
Loading animation | Codeams | 2,408 Kb |
Wrap_Test | Mscfourn | 7,503 Kb |
700 Synapses Per Second | Silentkrange | 2,138 Kb |
Minimal Material Design Form Input | Koenigsegg1 | 3,076 Kb |
Hamburger Menu Animation | Salmanraza | 2,580 Kb |
A Pen by Paul Sullivan | Pwsm50 | 2,349 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!