Comments (1)
package
{
import flash.display.Shape;
import starling.display.Sprite;
import starling.display.graphicsEx.ShapeEx;
/**
* ...
* Simple class to draw numbers (useful for profiling)
*/
public class DebugNumbers extends Sprite
{
protected var _shapeEx:ShapeEx;
public var _characterHeight:Number = 20;
public var _characterWidth:Number = 10;
public var _lineWidth:Number = 2;
public var _lineColor:Number = 0xFFFFFF;
public function DebugNumbers()
{
_shapeEx = new ShapeEx();
addChild(_shapeEx);
}
public function drawNumber(value:uint) : void
{
var valueString:String = "" + value;
var xPos:Number = x;
_shapeEx.graphics.clear();
_shapeEx.graphics.lineStyle(_lineWidth, _lineColor, 1.0);
for ( var i:int = 0; i < valueString.length; i++)
{
var currentChar:String = valueString.charAt(i);
if ( currentChar == "0" )
xPos += draw_0(xPos);
else if (currentChar == "1" )
xPos += draw_1(xPos);
else if (currentChar == "2" )
xPos += draw_2(xPos);
else if (currentChar == "3" )
xPos += draw_3(xPos);
else if (currentChar == "4" )
xPos += draw_4(xPos);
else if (currentChar == "5" )
xPos += draw_5(xPos);
else if (currentChar == "6" )
xPos += draw_6(xPos);
else if (currentChar == "7" )
xPos += draw_7(xPos);
else if (currentChar == "8" )
xPos += draw_8(xPos);
else if (currentChar == "9" )
xPos += draw_9(xPos);
}
}
protected function draw_0(xpos:Number) : Number
{
_shapeEx.graphics.drawEllipse(xpos + _characterWidth * 0.5, _characterHeight * 0.5, _characterWidth, _characterHeight);
return _characterWidth + _lineWidth;
}
protected function draw_1(xpos:Number) : Number
{
_shapeEx.graphics.moveTo(xpos + _characterWidth * 0.5, 0);
_shapeEx.graphics.lineTo(xpos + _characterWidth * 0.5, _characterHeight);
return _characterWidth + _lineWidth;
}
protected function draw_2(xpos:Number) : Number
{
_shapeEx.graphics.moveTo(xpos , _characterHeight * 0.2 );
_shapeEx.graphics.curveTo(xpos + _characterWidth * 0.5, -_characterHeight * 0.2, xpos + _characterWidth, _characterHeight * 0.2);
_shapeEx.graphics.lineTo(xpos , _characterHeight);
_shapeEx.graphics.lineTo(xpos + _characterWidth, _characterHeight);
return _characterWidth + _lineWidth;
}
protected function draw_3(xpos:Number) : Number
{
_shapeEx.graphics.moveTo(xpos , _characterHeight * 0.2 );
_shapeEx.graphics.curveTo(xpos + _characterWidth * 0.5, -_characterHeight * 0.2, xpos + _characterWidth, _characterHeight * 0.2);
_shapeEx.graphics.lineTo(xpos + _characterWidth * 0.5, _characterHeight * 0.5);
_shapeEx.graphics.lineTo(xpos + _characterWidth , _characterHeight * 0.8);
_shapeEx.graphics.curveTo(xpos + _characterWidth * 0.5, _characterHeight * 1.2, xpos , _characterHeight * 0.8);
return _characterWidth + _lineWidth;
}
protected function draw_4(xpos:Number) : Number
{
_shapeEx.graphics.moveTo(xpos + _characterWidth * 0.8 , 0);
_shapeEx.graphics.lineTo(xpos + _characterWidth * 0.8 , _characterHeight);
_shapeEx.graphics.moveTo(xpos + _characterWidth * 0.2 , 0);
_shapeEx.graphics.lineTo(xpos + _characterWidth * 0.2 , _characterHeight * 0.4);
_shapeEx.graphics.lineTo(xpos + _characterWidth , _characterHeight * 0.4);
return _characterWidth + _lineWidth;
}
protected function draw_5(xpos:Number) : Number
{
_shapeEx.graphics.moveTo(xpos + _characterWidth , 0 );
_shapeEx.graphics.lineTo(xpos , 0);
_shapeEx.graphics.lineTo(xpos , _characterHeight * 0.4);
_shapeEx.graphics.curveTo(xpos + _characterWidth * 2.0, _characterHeight * 0.75, xpos , _characterHeight);
return _characterWidth + _lineWidth;
}
protected function draw_6(xpos:Number) : Number
{
_shapeEx.graphics.moveTo(xpos + _characterWidth * 0.8 , 0);
_shapeEx.graphics.lineTo(xpos , _characterHeight * 0.65);
_shapeEx.graphics.drawEllipse(xpos + _characterWidth * 0.5 , _characterHeight * 0.75, _characterWidth, _characterHeight*0.5);
return _characterWidth + _lineWidth;
}
protected function draw_7(xpos:Number) : Number
{
_shapeEx.graphics.moveTo(xpos , 0);
_shapeEx.graphics.lineTo(xpos + _characterWidth , 0);
_shapeEx.graphics.lineTo(xpos + 0.5 * _characterWidth , _characterHeight);
return _characterWidth + _lineWidth;
}
protected function draw_8(xpos:Number) : Number
{
_shapeEx.graphics.drawEllipse(xpos + _characterWidth * 0.5, _characterHeight * 0.25, _characterWidth * .8, _characterHeight * 0.4);
_shapeEx.graphics.drawEllipse(xpos + _characterWidth * 0.5 , _characterHeight * 0.75, _characterWidth, _characterHeight*0.5);
return _characterWidth + _lineWidth;
}
protected function draw_9(xpos:Number) : Number
{
_shapeEx.graphics.drawEllipse(xpos + _characterWidth * 0.5 , _characterHeight * 0.25, _characterWidth, _characterHeight * 0.5);
_shapeEx.graphics.moveTo(xpos + _characterWidth , _characterHeight* 0.4 );
_shapeEx.graphics.lineTo(xpos + _characterWidth*0.2 , _characterHeight);
return _characterWidth + _lineWidth;
}
}
}
from starling-extension-graphics.
Related Issues (20)
- graphicsEx.graphics.postProcess() works strange HOT 2
- when draw line and change thickness stroke incorrect HOT 1
- Why it doesn't use ddx/ddy oppcodes for curve drawing? HOT 1
- Stage resize - null material HOT 2
- TypeError: Error #1034 HOT 3
- Width returns 0 HOT 4
- Shapes cannot be touched HOT 1
- Texture no repeat in TextureVertexColorFragmentShader HOT 8
- Texture restoration after context loss HOT 3
- Duplicate variable definition of function paramters HOT 5
- extra comma in TextureMaterial class HOT 1
- graphics.moveTo doesn't work in this situation HOT 3
- Starling 2 HOT 46
- Add and update dependency version HOT 1
- Context loss SEG not recovering - No valid program set. HOT 5
- starling.core.RenderSupport problem with Starling 2 HOT 4
- Readme needs more detail
- Error #3600: No valid program set. HOT 3
- Stroke Problem
- Is TextureFill supported with starling 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from starling-extension-graphics.