Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Piskvor/41df1f68b44b43100552126c76e2f609 to your computer and use it in GitHub Desktop.
Save Piskvor/41df1f68b44b43100552126c76e2f609 to your computer and use it in GitHub Desktop.
Go to https://lines.chromeexperiments.com/drag/, start the experience and run this code in the console - or install it as a userscript.
// ==UserScript==
// @name Animate the Lines WebGL experiment automatically
// @namespace https://gist.github.com/spite/90e3dbf8e117660f6788a5748ae06cad
// @version 0.2
// @description Automatically drags the mouse, leading to a pleasant effect
// @author spite, userscripted by Piskvor
// @match https://lines.chromeexperiments.com/drag/
// @grant none
// @updateURL https://gist.github.com/Piskvor/41df1f68b44b43100552126c76e2f609/raw/experiments_lines_drag.user.js
// ==/UserScript==
window.setTimeout(function() {
// Your code here...
document.getElementById( 'loading' ).style.display = 'none';
var speed = 0.001; // changes the rate of rotation
var distance = 4; // changes the distance the point travels
function _update() {
bAmDrawing = true;
lastMouseX = 0; lastMouseY = 0;
var a = speed * performance.now();
var x = distance * Math.cos( a );
var y = distance * Math.sin( a );
stage.mousemove( { data: { global : { x: x, y: y } } } );
}
function _animate() {
_update();
setTimeout( _animate, 1000 );
}
_animate();
}, 5000); // we should wait for the loader to actually finish, but this hack is quite sufficient for a toy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment