PrimaryFeather/Starling-Framework — pull request #176 by robsilv (2012-10-02 11:59:23+00:00)
Title: starling.display.Graphics API added

Hi guys,

We've added the old flash.display.Graphics API to Starling, as we keep finding we need it in our projects.

Central to this implementation are Jon Pace's:

starling.display.graphics.Fill
starling.display.graphics.Stroke

These both extend:

starling.display.graphics.Graphic

which extends:

starling.display.DisplayObject

..and wraps up a reference to:

starling.display.materials.StandardMaterial

If you take a look at the Sandbox example, you'll see that the Fill and Stroke classes provide a more powerful, lower level API than the familiar Graphics API and can be used directly.

Although more powerful, this API is unfamiliar to the regular Flash dev, so in the spirit of the Starling framework we've also provided an augmented Graphics API. If you look at GraphicsExample, you'll see we've provided:

starling.display.Graphics

..which provides a higher level API that wraps up references to Fill and Stroke. The idea being that the developer could first familiarise themselves with this API, delve into it and discover lower level API.

As well as providing familiar functions such as:

beginFill()
beginBitmapFill()
drawCircle()
drawRect()
lineStyle()
moveTo()
lineTo()

We've also augmented the API to provide:

beginTextureFill()
lineTexture()

If you run GraphicsExample, you'll see the last example is a rectangle with a rock fill texture and a grass line texture.

There are also 2 other examples:

FillExample demonstrates a Fill being drawn at runtime.
And Profiling, which is obviously a performance test.

We hope you like what we've made and see it as a worthy addition to the framework!

cheers
rob