A Closer Look at Fills and Strokes
As Degrafa evolves, Jason and I are trying to make sure we can account for a number of features someone may find important when creating graphics with the framework. Fills and Strokes are very important because they literally make up the shapes that get drawn.
Without a strong solution for those two things you’re left with a something somewhat lackluster. Here’s an example of where things are at so far with Fills and Strokes:
Fills
Fills are created outside and independent of any shape to make sure they can be repurposed. Each type of fill is declared in between a
Bitmap Fills
Let’s take a look at each Fill separately. The top-left circle is an example of using a Bitmap Fill and the Fill is created like this:
The imageSource variable name points to an embedded image, repeat allows you to specify if you’d like the image to repeat, rotation allows you to rotate the bitmap fill and smooth allows you to smooth out the bitmap fill. Smooth was helpful in this example where without it the edges of the repeated image were jagged.
Gradient Fills
Gradient fills allow you to create linear and radial gradient fills with multiple color, alpha, and ratio specifications. The top-middle circle is an example of a Gradient Fill. The MXML looks like this:
This creates a 3 color gradient fill with various ratios and alphas.
Solid Fills
Solid fills are pretty straight forward, it supports color and alpha. The MXML looks like this:
Working with Strokes
Just like Fills, Strokes are specified independent from any shape or object. Gradient Strokes, both linear and radial, and Solid Strokes are part of Degrafa. You can also specify things like joints, caps, spreadMethod, angle, miterLimit, scaleMode, pixelHinting and more. The MXML for a group of Strokes would look like this:
As things progress, the ability to created different stroke styles like dashed, dotted, random, etc. will be added as well as the ability to add start/end caps like arrow heads, shapes, images, etc. Here’s an example of some strokes:
Gradient Strokes
As mentioned above, Radial and Linear Gradient strokes can be created using Degrafa. The code for the top-left example looks like this:
The MXML for the radial stroke example to the top-right has square caps and bevel joints and looks like this:
Solid Strokes
Solid Strokes can have caps, joints, color, miterLimit, scaleMode, pixelHinting, etc. specified. The MXML:
Another thing worth mentioning is that we’re looking to allow the ability to specify Fills and Strokes properties through CSS, so there’s a way to maintain consistency throughout an app without code redundancy.
July 15th, 2007 at 3:52 am
Hello Jason and Juan,
When thinking further about your beautiful initiative I started to wonder to what degree you can leverage existing declarative graphics formats (like SVG)?
Cheers,
= Dirk
July 15th, 2007 at 2:03 pm
<p>Hello Dirk, Thanks for your visit.</p>
<p>We have planned support for SVG. To what extent is not yet decided, but the development of the framework has this in mind. </p>
<p>It will most likely start with support for paths and more general items. For example SVG path might look like this “M20,20 L51,31â€, Degrafa path looks the same. The Degrafa Path data property is the same as the SVG path and supports the same path command set L, l, M, c, C, Q, q, Z, z etc.. So you could eventually copy and paste the path data from an SVG file into a Degrafa path data property and have the same result (this data is converted into Degrafa segments). </p>
<p>However we are not sure about a 100% specification conformity, or whether it would provide substantial value to the users of the framework. In an ideal situation a seperate Degrafa tool will read a svg file and convert it to Degrafa MXML allowing you to repurpose your art work in Flex, add your binding, control points, and other Degrafa/Flex specific goodies to it.</p>
<p>SVG is definitely something we are giving/have given allot of consideration.</p>
<p>I hope this answers your immediate question. I have many more thoughts on the subject, feel free to email me with specific queries regarding this at Jason [at] degrafa [dot] com.</p>
<p>As a side note we have also researched some other vector formats most of which in GIS and mapping applications. We hope to eventually provide limited support for these as well.</p>
<p>cheers</p>
<p>jason</p>
August 22nd, 2007 at 4:50 pm
Hi,
“Another thing worth mentioning is that we’re looking to allow the ability to specify Fills and Strokes properties through CSS.”
Is it possible now to specify the fill/stroke in CSS ?
Thanks
Ashok
August 22nd, 2007 at 5:40 pm
We’re working on it as we speak. It’ll be available in the beta, which we hope to be releasing soon.