Hi everyone...

First things first, I suck at geometry so bear with me please

I'm having some issues with the Starling Graphics Extension's NGon class... on some iOS devices, after rotation and context restoration, my NGon's disappear and are not restored.

I wanted to start using meshes and stop relying on the Starling Graphics Extension.

I need the NGon class to draw a pie chart.

I came across this class by JohnBlackburne https://forum.starling-framework.org/topic/animated-white-border-around-a-circle#post-93639 and it works great! Restores perfectly when context is lost.

package Qyx.Mesh { import starling.display.Mesh; import starling.rendering.IndexData; import starling.styles.MeshStyle; import starling.rendering.VertexData; public class NGon extends Mesh { // properties private var _sides :int; private var _tint :uint; private var _radius :Number; private var _alpha :Number; // pre-calculated values private var fAngle :Number; private var fCos :Number; private var fSin :Number; public function NGon(sides:int = 10, radius:Number = 100, colour:uint = 0, alph:Number = 1.0) { _sides = sides; _radius = radius; _tint = colour; _alpha = alph; fAngle= (Math.PI * 2) / _sides; fCos = Math.cos(fAngle); fSin = Math.sin(fAngle); pixelSnapping = false; var vertexData:VertexData = new VertexData( MeshStyle.VERTEX_FORMAT, 1 + _sides); var indexData:IndexData = new IndexData(3 * _sides); super(vertexData, indexData); setupVertices(); updateVertices(); updateColours(); setRequiresRedraw(); } public function set radius(val:Number):void { if (_radius != val) { _radius = val; updateVertices(); setRequiresRedraw(); } } public function set colour(val:uint):void { if (_tint != val) { _tint = val; updateColours(); setRequiresRedraw(); } } public function set alph(val:Number):void { if (_alpha != val) { _alpha = val; updateColours(); setRequiresRedraw(); } } public function colourise(fAlpha:Number, iTint:uint):void { _alpha = fAlpha; _tint = iTint; updateColours(); setRequiresRedraw(); } private function updateColours():void { var colAttr:String = "color"; var vData:VertexData = vertexData; vData.colorize(colAttr, _tint, _alpha, 0, _sides + 1); } private function updateVertices():void { var iRay:int, fX:Number, fY:Number; var fX0:Number = 0.0; var fY0:Number = 1.0; var iNumVert:int = 0; var posAttr:String = "position"; var vData:VertexData = vertexData; // centre vData.setPoint(0, posAttr, 0, 0); iNumVert++; for (iRay = 0; iRay < _sides; iRay++) { // inner point fX = fX0 * _radius; fY = -fY0 * _radius; vData.setPoint(iNumVert, posAttr, fX, fY); iNumVert++; fX = fX0 * fCos - fY0 * fSin; fY = fX0 * fSin + fY0 * fCos; fX0 = fX; fY0 = fY; } } protected function setupVertices():void { var iRay:int; var iNumVert:int = 1; var vData:VertexData = vertexData; var iData:IndexData = indexData; iData.numIndices = 0; vData.numVertices = 1 + _sides; for (iRay = 0; iRay < _sides; iRay++) { iNumVert++; if (iRay == _sides - 1) { iData.addTriangle(0, 1, iNumVert - 1); } else { iData.addTriangle(0, iNumVert, iNumVert - 1); } } } } }

The thing is, it's only a partial implementation of the NGon class and not enough to make pie charts...

How can I adapt it to accept a start and end angle like the original NGon class? I really suck at geometry so I'm at a complete loss here

Thank you in advance!