Graphics

author:
Unwrong
description:
This extension recreates the Flash Graphics API in Starling by wrapping up a suite of graphics primitives, including Plane, Fill and Stroke.
lastupdate:
2013-10-31
compatible:
v1.4.1
tag:
graphics, API
download:
https://github.com/StarlingGraphics/Starling-Extension-Graphics

Overview

Beware that this extension does not work with Starling 2.0 or higher!

This extension adds a suite of graphics primitives such as Planes, Fills and Strokes. These are starling display objects that are automatically triangulated for fast rendering on the GPU.

These primitives can be manipulated directly, or created on your behalf by using a familiar graphics API accessed via the Shape class.

A simple example of a Fill using Shape.graphics:

var shape:Shape = new Shape();
addChild(shape);
 
shape.graphics.beginFill(fillColor, fillAlpha);
shape.graphics.lineStyle(strokeThickness, strokeColor, strokeAlpha);
shape.graphics.drawRect(top, left, right, bottom);
shape.graphics.endFill();

A simple example of a Fill using the lower level primitive:

var w:Number = stage.stageWidth;
var h:Number = stage.stageHeight;
var waterColorTop:uint = 0x08acff;
var waterColorBottom:uint = 0x0073ad;
var waterColorSurface:uint = 0x61caff;
 
var waterHeight:Number = h-100;
var waterFill:Fill = new Fill();
waterFill.addVertex(0, waterHeight, waterColorTop );
waterFill.addVertex(w, waterHeight, waterColorTop );
waterFill.addVertex(w, h, waterColorBottom );
waterFill.addVertex(0, h, waterColorBottom );
addChild(waterFill);

Changelog

  • 2012/11/12 13:27: First version
  • 2013/10/31 13:27: Update to add Natural Cubic Splines through the GraphicsEx API,
  • geometry based hit tests,
  • drawPath and drawGraphicsData API.
  • support for multiple nativeWindows

User Comments

Feel free to edit this part of the page!

Please, make it to work with atlases and subtextures!

Wheres the API reference for this Graphics Extension? ie whats in the box?

Looks great. I'm trying to find some type of api reference like adobe makes. I want to make a line the steadily grows from both sides. Any advice on this? Thanks.

skol: drawTriangles() would be awesome or please give me a hint how to implement Context3D.drawTriangles() if it's a viable alternative? http://forum.starling-framework.org/profile/skol

Does this not work with texture atlas?

  extensions/graphics.txt · Last modified: 2016/09/22 07:37 by daniel
 
Powered by DokuWiki