Skip to content

Instantly share code, notes, and snippets.

@mrdoob
Created February 21, 2012 18:20
Show Gist options
  • Save mrdoob/1877952 to your computer and use it in GitHub Desktop.
Save mrdoob/1877952 to your computer and use it in GitHub Desktop.
Single Lane Superhighway - Landscape
var svg = document.createElementNS( 'http://www.w3.org/2000/svg', 'svg' );
svg.setAttribute( 'width', 1000 );
svg.setAttribute( 'height', 200 );
document.body.appendChild( svg );
var path = document.createElementNS( 'http://www.w3.org/2000/svg', 'path' );
path.setAttribute( 'style', 'stroke: black; stroke-width: 1px; fill: none;' );
svg.appendChild( path );
var drawing = 'M 0 ' + ( Math.cos( position ) * 50 + 100 ) + ' ';
for ( var i = 0, l = 1000; i <= l; i += 20 ) {
drawing += 'L' + i + ' ' + ( Math.cos( ( i / 2000 ) * 10 ) * 50 + 100 ) + ' ';
}
path.setAttribute( 'd', drawing );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment