Degrafa: Declarative Graphics Framework

Degrafa Blog

Get Degrafa Now

Posts Tagged ‘beta 3’

Lights, Camera, Action: VideoFill

Sunday, November 1st, 2009

Greg Dove, a Degrafa core team member, and the creator of Degrafa’s VectorFill, has broken new ground with another new Degrafa paint object, VideoFill.

There have been a couple of sneak previews of VideoFill over the past few months; Juan showed a quick preview at 360|Flex earlier this year and Greg showed a quick demo at FlashCamp in New Zealand as recently as September. Well, no more ’sneaks’ (apart from this one!), it’s finally going to be available from beta 3.2.

You won’t believe all the things you can do with this, suffice to say that it makes some video effects that could be difficult to achieve – even in the Flash authoring tool – very easy to code in Flex with Degrafa.

To be honest, we don’t know what you will do with VideoFill. We can see it being used in creating custom players for specific video content or for specific vector/clipping effects for video -this is quite practical and quick to do with VideoFill. And yes…it can be used for skinning if absolutely required (’absolutely’? yeah we can’t think of when that would be either….but hey, we’ll let someone else tell you not to do it!).

A screen capture from the Avatar trailer being used as a VideoFill

A screen capture from the Avatar trailer being used as a VideoFill

Under the hood, to make VideoFill work, a complete new custom video player class was written from the ground up, designed for the purpose of supporting the way that VideoFill does its magic internally within Degrafa. VideoFill does require data access permission to work with the bitmapData of the video, but that is quite straightforward if you load from a domain under your control. It handles both progressive download video and also has support for rtmp streaming video content. Greg is also planning to add in support for the Camera object to round things out in terms of capabilities/support so that it’s easy to add live webcam content as a fill.

Back in the realm of regular paint classes in Degrafa, VideoFill is an ITransformablePaint object, which means you can spin, skew, scale and move a VideoFilll inside its target Geometry object using Degrafa’s Transforms…all while the video is happily playing! Watch out for more VideoFill information and tutorials after additional exciting beta 3.2 announcements in the coming days. We’ll add an official VideoFill sample to the Degrafa samples page as soon as beta 3.2 is released…for now you can whet your appetite on this one.

Degrafa Beta 3.1 and Docs Released

Friday, December 19th, 2008

Degrafa Beta 3.1 is now available. You can grab the new beta and read the new documentation.

Degrafa Beta 3 was a huge update from Beta 2 and took almost about 8 months to get done. The Beta 3 release as already received around 4,200 downloads and it seems more and more content is starting to float around, like screencasts, user group presentations, samples and tutorials. The response and encouragement from the community has been inspiring. It’s also great to hear how Degrafa has made it’s way into some of the biggest RIAs out there.

Now that the core features have been defined, we can move forward with things like updates to features, optimization, performance and bug fixes. We’re also on a more frequent release cycle on our way to Degrafa 1.0. In these releases we’ll also be including samples that display just how powerful Degrafa can be. So, be sure to keep an eye on the Degrafa Samples page.

Along with this release we gave a much needed update to the documentation. Hopefully exploring the documentation will offer some insight into all the additional goodies that comes with Beta 3 and the potential for future releases. We’ll also be updating the Degrafa Samples page with more great stuff.

If you’re using Degrafa Beta 2 or 3 you’ll probably want to update to this latest release. For SVN users, we’ve noticed some people have been unintentionally checking out old code via svn. If you are using the http://code.google.com/p/degrafa/source/browse/#svn/trunk/Degrafa for SVN you are still using the Beta 2. Beta 3 will remain in it’s original home located at http://code.google.com/p/degrafa/source/browse/#svn/branches/Origin/Degrafa . If you wish to use Beta 3 and take advantage of the ongoing work there you will need to use the Branches/Origin path for checking out from SVN in the second of those two links. Also, older downloads have been deprecated, but are still available on Google Code.

So, what exactly is in Degrafa Beta 3.1 and where are we going next? Here’s some notes:

Enhancements/Features

  • RasterText now has support for regular Degrafa Fills
  • Geometry now offers two mask modes
  • Advanced math utilities added.
  • A standard decorator package has been included, including two stroke decorators (for now)
  • GeometryRepeater now provides easy access to the current iteration counter
  • PropertyModifier offset property has been changed to modifier.

Bug Fixes

  • Issue 64 addressed – Changes to inline MXML segments or points on path , polygon, and polyline will now properly update/draw with binding.
  • BezierSpline will now properly auto close with the correct curvature.
  • Issue 65 addressed – RasterText binding is now working as expected.
  • RoundedRectangle and RoundedRectangleComplex now internally adapt their rendering to reduce a Flash Player rendering artifact under some circumstances. See this blog post

Known Issues

  • Multiple decorator processing has not yet been implemented. Only one decorator will have an effect. Resolution planned for next update.
  • TransformGroup processing of multiple registration points is not yet final. Review is underway. Resolution planned for next update.
  • RasterText does not support alpha with a SolidFill. Resolution planned for next update.

The Framework

We will continue to evolve the framework in various areas.
Work has starting on optimization with focus on:

  •     General Memory use and CPU
  •     Object pooling and externalization of state. 
  •     Opt in BitmapData cache

Initial memory and performance results are very promising.

The Degrafa Site

Look for new Degrafa code libraries and content based resources coming soon.

RasterText for Advanced Text Graphics

Saturday, November 29th, 2008

In Degrafa Beta 3 we introduced a new text object called RasterText. This object allows you to add text to your graphics compositions just like any other geometry. You can also have multiple text objects inside something that normally allows for one. For example, you could use RasterText to create 2 text items in a Button skin, rather than relying on the default single label of a Button, kinda like the example below. Click here to view the source.

RasterText is like other Degrafa geometry objects in the way it can be composed using fills, transforms, etc. RasterText renders as bitmap data, so things like Decorators and strokes around letters won’t work because there is not path defined. That’s what VectorText will take care of in the future.

Below is an example of several Degrafa fill types being applied to RasterText objects. As you can see, you’ll no longer be limited to solid-colored text. Click here to view the source

The ability to add these kinds of fills will be coming soon in Degrafa Beta 3.1 along with some other really great updates. Now that the core feature set is defined we’ll be looking to push out smaller updates more regularly. In the meantime you can still do some neat stuff just composing RasterText object together, like the CS4 Icon Previewer below. Click here to view the source

Degrafa Beta 3 Preview: VectorFill

Monday, August 4th, 2008

The focus of Degrafa beta 1 and 2 was to set up a solid core that would allow us to do really innovative things and make really complex things easy to do. We’re also chipping away at the need to have any external graphics referenced in your project. A new feature in Degrafa Beta 3 gets us even closer to meeting these goals.

This new feature is a new Fill type called VectorFill that is going to change the way you think about what’s possible visually in your applications. VectorFill allows you to compose any Degrafa geometry together and use it as a Fill for any other Degrafa geometry. As a simple example, imagine you wanted a background of diagonal lines. To achieve this with VectorFill all you need to do is draw one diagonal line using Degrafa, specify that Line as a source in a VectorFill, then apply that VectorFill to a Degrafa geometry object using the fill property.

Just like any other Degrafa object, you could edit that diagonal line, say change a color, and that change will dynamically get updated in the applied VectorFill. Also, when we say you can compose any Degrafa geometry together we mean shapes, transforms, fills, repeaters, strokes, and so on. You could move shapes with in VectorFill to create panning or use VectorFill with the Flex charting components to make really rich visuals. The possibilities are endless.

We’ve also added additional properties to VectorFill to allow for even more powerful ease of use. You get all the BitmapFill goodness of repeat, scale and angle etc. You also get the recently revealed fill transform features as well. And you also get filters, autosettings, background SolidFill and the ability to clip the fill source geometry based on a third geometry object (or even part of composition). Let’s take a look at some samples.

Below is an example of a VectorFill being used in a Circle. As you move your cursor over the eagle a zoomed view is shown. If you use your mouse wheel you can zoom in and out. This is not a mask, but a VectorFill with a clipSource setting (assigned to the magnifier’s lens) moving around and scaling in the Circle. To show a possible use, a second fill, a BitmapFill is used to take ’snapshots’.

Another example is using VectorFill to customize charting components. The example below uses a VectorFill to represent visually the sport for which the data pertains to. This opens a lot of doors for really custom-looking data visualization using existing charting components.

A more simple example is based on the scenario I outlined above; a diagonal line background. Most examples I’ve seen that use Degrafa always have one bitmap graphic in there for some kind of background. Well, now you can go completely vector. Below is a diagonal line background that uses a VectorFill and a Degrafa Line applied to a Rectangle. I’ve thrown in some other controls so you can see the live updates on the VectorFill.

We’re really excited about what will now be possible with this new VectorFill and some of the other new features we’ll be sharing soon.

Degrafa Beta 3 Preview: Loading External Assets

Tuesday, July 22nd, 2008

One of the most influencing factors behind the new features we add to Degrafa comes from the community. As Degrafa has progressed we make sure to follow the Degrafa Group as much as possible to help guide people on how to use it and answer questions.

In some cases it’s hard to help because the version in question just doesn’t support what the person is asking about. When these scenarios come up we take notes and add it to our “to do” list to see if we can provide a solution in a way that elegantly fits into the roadmap for Degrafa.

One scenario that came up was the ability to load a bitmap from an external URL to be used in a Degrafa Fill. Currently you have to embed a bitmap to use it in a fill. However, Degrafa Beta 3 will allow to specify any external bitmap source to be used in a Fill. This will be no real effort to achieve this if loading images from the same domain as your application, but you’ll also be able to use images from an external domain that provides a permissive crossdomain.xml file, like Flickr.

Another recent addition to the existing COLOURlovers API, was support for runtime ‘pattern’ loading via crossdomain permissions, from COLOURlovers.com. The way we’re implementing this makes it pretty easy for users to take advantage of.

Below is a simple example using the ColourLovers API and runtime loaded random ‘patterns’ used as BitmapFills. That’s to give you an idea of what’s possible. After that a quick explanation of how easy it will be to use runtime loaded images in your BitmapFills.

Degrafa External Fills

View Sample

Loading BitmapFill images from your own domain

If you are loading images from the same domain as your Flex application, no access permissions are needed, and using a runtime loaded BitmapFill is very easy*.

If you have your images in an images directory within the same directory as your main application swf, then you would normally specify the source as follows:

1
2
3
4
<bitmapFill
      id="localExternalBitmapFill"
      source="images/myImage.png"
      angle="45" />

That’s basically all there is to it! When the image has loaded the fill will appear, for the Geometry item(s) that use(s) it. The additional delay is an indeterminate time after your Flex application has initialized, simply because your image is not embedded and it takes a little time to load. If you use the same source url assigned to multiple BitmapFills (you may for example use the same external image, but have different settings applied in another BitmapFill), then the external image file is only loaded once, and only one set of BitmapData is generated for all the BitmapFills that use it.

Loading BitmapFill images from External Domains

These examples relate to using a Flickr source:

a) A simple, one-off example:

1
2
3
4
5
<bitmapFill
      id="bitmapFill"
      source="http://static.flickr.com/15/88928122_0f06ac7417.jpg"
      rotation="45"
      smooth="true" />

The above works as is, because flickr has the crossdomain permission policy file in the default location expected by the flash player at http://static.flickr.com/crossdomain.xml. This example can be expressed in another way as a separation of basePath and relative url as in the following example.

b) Loading multiple images from a single external location, managed with a LoadingLocation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<utilities:LoadingLocation
      id="flickr"
      basePath="http://static.flickr.com/"
      policyFile="http://static.flickr.com/crossdomain.xml" />
<paint:BitmapFill
      id="bitmapFill"
      loadingLocation="{flickr}"
      source="15/88928122_0f06ac7417.jpg"
      rotation="45"
      smooth="true" />
<paint:BitmapFill
      id="bitmapFill2"
      loadingLocation="{flickr}"
      source="142/325447236_ac4c1b9b3a.jpg"
      rotation="30"
      smooth="true" />

The above is likely to be suited to applications which have collections of external assets hosted externally, and where the location of the assets (domain) may change at some point in time. By setting up a single LoadingLocation to reference a basePath and policyFile (particularly if the policy file granting access is not using the default name and/or in the default location) you can make code maintenance easier if/when the external location of the assets changes.

As you can see the use of external images from within mxml is quick and easy. Watch out for more additions in the Degrafa Fills arena coming up before too long in another beta3 preview post.

*However you should also be aware that if your domain is accessed with both http://www.mydomain.com and http://mydomain.com then you may still need a crossdomain.xml file that grants permission to both, if you specify absolute urls for the local domain image files. The reason for this is that if you specify a url for the image that is on a different subdomain than that under which the application swf has been accessed, flash player security rules come into play and the flash player will seek permission via a policy file – which will fail to be granted it doesn’t exist. You should be ok using relative urls.

Degrafa Beta 3 Preview: Transforms

Sunday, June 22nd, 2008

In the last post we previewed the revamped Repeaters in Degrafa Beta 3. Another feature we’re excited about is transforms, which will include Scale, Skew, Translate, Rotate and Matrix. Transforms will allow you to further manipulate the graphics you create with Degrafa and with bindable properties Transforms can change graphics “on the fly” and bring things closer to cleanly converting SVG (and other formats) to Degrafa.

All this is similar to what you might expect from a graphics editing tool like Illustrator. What’s cool is in Degrafa the children inherit the parent transform but each can also have their own individual transform as well (without incurring the overhead and provides a more compact markup). Also, transforms are applied at render time and are none destructive (i.e. do not actually modify the geometry properties).

In most cases a single Transform may suit your needs for multiple transform types. If not, you can use a TransformGroup to create your own sequence in which the transforms will be applied, so you have complete flexibility. We also allow you to specify a registration point beyond top-left to include center, top-center, bottom-right, etc., as well as centerX and centerY providing additional control. This saves you from having to come up the math to set the registration point on your own.

Below is a basic example of a RegularRectangle with the following transforms applied to it from left to right: Scale, Skew, Rotate. (Matrix and Translate not shown).

Rectangle Transform

Click to View and View Source

As you might expect Degrafa Transforms will work on any geometry drawn using Degrafa. However, there’s a bit more to it than that. You can also apply transforms to Fills (like a bitmap fill and any gradient fill) and Gradient-based Strokes. For example, below is a basic sample of a BitmapFill with a Scale, Skew and Rotate transform applied (images from COLOURlovers).

BitmapFill Transform

Click to View and View Source

Transforms allow you to manipulate geometry very easily rather than having to manually change properties or points. However, the real power comes from using Transforms with other features of Degrafa. Below are several examples of using a Repeater with different transforms. The one with the orange, white and grey “tick marks” actually has a transform applied to a Repeater with a transform on its children (mind-boggling, right?). This also shows that transforms are propagated to the children and that the parent can have a transform that also gets applied to the children, yet each child could add to their final transform with a transform of their own.

Transformed Repeaters

Click to View and View Source

When you start thinking about all the unique combinations of using transforms you can begin to see just how powerful they can be. As we preview more features of Degrafa Beta 3 you’ll be able to see how adding a single transform can drastically change graphics drawn with Degrafa to create very unique and interesting visuals.