Reputation: 3758
How can I draw a line on a bitmap in Stage3D using Agal? Can someone provide a code example?
Upvotes: 1
Views: 2001
Reputation: 884
I recently wrote a simple library to draw lines on Stage3D.
It's called Zebroid, https://github.com/luwes/Zebroid
Zebroid does not support line caps or joints yet.
Upvotes: 0
Reputation: 1575
If you use Starling you can try this:
/**
* Class Line
* @author Leandro Barreto 2012
* @version 1.0
**/
package starling.utils
{
import starling.display.Quad;
import starling.display.Sprite;
public class Line extends Sprite
{
private var baseQuad:Quad;
private var _thickness:Number = 1;
private var _color:uint = 0x000000;
public function Line()
{
baseQuad = new Quad(1, _thickness, _color);
addChild(baseQuad);
}
public function lineTo(toX:int, toY:int):void
{
baseQuad.width = Math.round(Math.sqrt((toX*toX)+(toY*toY)));
baseQuad.rotation = Math.atan2(toY, toX);
}
public function set thickness(t:Number):void
{
var currentRotation:Number = baseQuad.rotation;
baseQuad.rotation = 0;
baseQuad.height = _thickness = t;
baseQuad.rotation = currentRotation;
}
public function get thickness():Number
{
return _thickness;
}
public function set color(c:uint):void
{
baseQuad.color = _color = c;
}
public function get color():uint
{
return _color;
}
}
}
Someone suggested at the Starling forums that we create a Line class which draws a few quads connecting two points. This tutorial shows how to create polygons using AGAL for shaders:
http://wiki.starling-framework.org/manual/custom_display_objects
Upvotes: 2