module Webglimpse { export interface XyLinePainterOptions { color ? : Color ; blend ? : boolean ; thickness ? : number ; } /**
     * Simple xy line painter which displays static data
     */ export function newXyLinePainter ( axis , xCoords , yCoords , options ? ) { var thickness = ( hasval ( options ) && hasval ( options . thickness ) ? options . thickness : 4 ) ; var color = ( hasval ( options ) && hasval ( options . color ) ? options . color : black ) ; var blend = ( hasval ( options ) && hasval ( options . blend ) ? options . blend : false ) ; var program = new Program ( modelview_VERTSHADER , solid_FRAGSHADER ) ; var u_Color = new UniformColor ( program , 'u_Color' ) ; var u_modelViewMatrix = new UniformMatrix4f ( program , 'u_modelViewMatrix' ) ; var coordArray = [ ] ; for ( var i = 0 ; i < xCoords . length ; i ++ ) { coordArray [ 2 * i ] = xCoords [ i ] ; coordArray [ 2 * i + 1 ] = yCoords [ i ] ; } var coordFloatArray = new Float32Array ( coordArray ) ; var coordBuffer = newStaticBuffer ( coordFloatArray ) ; var dim = 2 ; var count = coordFloatArray . length / dim ; return function ( gl , viewport ) { if ( blend ) { gl . blendFuncSeparate ( GL . SRC_ALPHA , GL . ONE_MINUS_SRC_ALPHA , GL . ONE , GL . ONE_MINUS_SRC_ALPHA ) ; gl . enable ( GL . BLEND ) ; } program . use ( gl ) ; u_Color . setData ( gl , color ) ; u_modelViewMatrix . setData ( gl , glOrthoAxis ( axis ) ) ; gl . lineWidth ( thickness ) ; gl . enableVertexAttribArray ( 0 ) ; coordBuffer . bind ( gl , GL . ARRAY_BUFFER ) ; gl . vertexAttribPointer ( 0 , dim , GL . FLOAT , false , 0 , 0 ) ; gl . drawArrays ( GL . LINE_STRIP , 0 , count ) ; coordBuffer . unbind ( gl , GL . ARRAY_BUFFER ) ; program . endUse ( gl ) ; } ; } }