All pastes #573227 Raw Edit

Slither4k

public xml v1 · immutable
·published 2007-06-18 01:36 UTC
rendered paste body
<?xml version="1.0" encoding="utf-8"?><widget minimumVersion="4.0">	<settings>		<setting name="debug" value="on"/>		<setting name="allowCustomObjectAttributes" value="true"/>	</settings>	<window id="mainWindow">		<canvas id="canvas" width="500" height="500"/>	</window>	<timer interval="1.25" onTimerFired="updateSnake();"/>	<action trigger="onLoad">		<![CDATA[			var canvas = widget.getElementById( "mainWindow" ).getElementById( "canvas" ).getContext( "2d" );			// Store x and y coords in one.			function Point( x, y ) {				this.x = x;				this.y = y;			}										// Allows me to redraw a portion of the background, not redraw the whole thing.			canvas.drawRect = function ( x, y, width, height, style ) {				canvas.clearRect( x, y, width, height );				canvas.fillStyle = "rgba( 0, 128, 128, 0.2 )";				canvas.fillRect( x, y, width, height );				if( style ) {					canvas.strokeRect( x, y, width, height );				}			};			canvas.drawSquare = function ( x, y ) {				// Clear the area, then draw colored square.				canvas.clearRect( x, y, 10, 10 );				canvas.fillStyle = "rgba( 210, 105, 30, .5 )";				canvas.fillRect( x, y, 10, 10 );				canvas.fillStyle = "rgb( 0, 0, 0 )";				// Change location back to start.				canvas.moveTo( x, y );			}			canvas.drawSegment = function ( x, y, orientation ) {				canvas.drawSquare( x, y );				if( orientation ) {					canvas.lineTo( x, y + 10 );					canvas.moveTo( x + 10, y );					canvas.lineTo( x + 10, y + 10 );									} else {					canvas.lineTo( x + 10, y );					canvas.moveTo( x, y + 10 );					canvas.lineTo( x + 10, y + 10 );				}				// Draw it.				canvas.stroke();			};			canvas.drawCorner = function( x, y, type ) {				canvas.drawSquare( x, y );				//canvas.join = "bevel";				if(type !== undefined || type !== null || type !== "") {					switch ( type ) {						case "leftDown":							canvas.lineTo( x + 10, y );							canvas.lineTo( x + 10, y + 10 );							break;						case "rightDown":							canvas.moveTo( x, y + 10 );							canvas.lineTo( x, y );							canvas.lineTo( x + 10, y );							break;						case "leftUp":							canvas.moveTo( x, y + 10 );							canvas.lineTo( x + 10, y + 10 );							canvas.lineTo( x + 10, y );							break;						case "rightUp":							canvas.lineTo( x, y + 10 );							canvas.lineTo( x + 10, y + 10 );					}				}				// Draw it.				canvas.stroke();			};			canvas.drawEnd = function ( x, y, type ) {				canvas.drawSquare( x, y );				if(type !== undefined || type !== null || type !== "") {					switch ( type ) {						case "left":														break;						case "right":														break;						case "top":														break;						case "bottom":												}				}				// Draw it.				canvas.stroke();			}			canvas.drawApple = function ( x, y ) {				// Draw outer circle				canvas.fillStyle = "rgba( 255, 0, 0, 0.4 )";				canvas.beginPath();				canvas.arc( x + 5, y + 5, 5, 0, Math.PI*2, true );				canvas.clip();				canvas.fillRect( x, y, 10, 10 );				// Clear inner circle.				canvas.arc( x + 5, y + 5, 4, 0, Math.PI*2, true );				canvas.clip();				canvas.clearRect( x, y, 10, 10 );				// Draw inner circle.				canvas.fillStyle = "rgba( 255, 0, 0, 0.2 )";				canvas.beginPath();				canvas.arc( x + 5, y + 5, 4, 0, Math.PI*2, true );				canvas.clip();				canvas.fillRect( x, y, 10, 10 );			};			var direction;			canvas.drawRect( 0, 0, 500, 500, true);			canvas.drawSegment( 50, 50, false );			//canvas.drawSegment( 70, 50, true );			canvas.drawApple( 85, 50 );			canvas.drawCorner( 70, 50, "rightUp" );		]]>	</action></widget>