embracing and extending

toshok | moonlight, mono, geek | Friday, July 20th, 2007

WPF has a nice brush called “VisualBrush”, to compliment the more usual set of brush types: SolidColorBrush which paints 1 color, Linear and Radial GradientBrushes, an Image and VideoBrush.

A Visual in WPF represents something drawn to the screen (UI elements, shapes, etc). VisualBrush allows you to draw a Visual hierarchy at some location on the screen, transformed in whatever way you want. The cool thing is that the VisualBrush will reflect changes made to the visual hierarchy through animations.

given our framework, VisualBrush was rather trivial to implement. Took maybe 2 hours.

This screencast (sorry about the poor quality, blame ffmpeg) shows an animated line in the upper half of the window. The lower half of the window is a rectangle with its stroke set to a SolidColorBrush (red) and its Fill set to a VisualBrush referencing the canvas in the upper half. The VisualBrush was reflected and offset in the Y direction to make it look like a mirror image.

Here’s a slightly more complex example. A VideoBrush is used to paint video on text in the upper half, while the lower half shows the same reflected VisualBrush. Note that the lower rectangle is the same size as in the first screencast, but the upper half’s display is much larger. The VisualBrush in the second half scales the contents properly to fit in the rectangle.

pretty sweet.

This isn’t in svn because I’m not really sure where to put it. VisualBrush, as I said, exists in WPF, but not in Silverlight. Maybe we’ll need to start putting more classes in agmono.dll. :)

Cat’s out of the bag

toshok | pyro, geek | Wednesday, July 18th, 2007

I’m surprised so few people knew about it up until Alex’s keynote. It was pretty much the worst kept secret ever. We were constantly asking ourselves “should we just announce it?” because so many people already knew. There were also the vague blog posts about it, which did nothing to help keep things quiet :)

Go here to see one of the two projects that has eaten up my life lately.

If you’re lazy and don’t want to click on links and read a bunch of text: Pyro is a pseudo-compositing window manager/desktop environment. I say “pseudo-” because unlike compiz/beryl/metacity/xfce/etc, it doesn’t do the compositing itself. Instead, it reflects window contents into the firefox DOM as canvas elements, and firefox composites them as it does an HTML page. Simply put, pyro uses the X damage and composite extensions to turn firefox into your desktop. From there everything you can do to a dom element can be done to native window contents.

It has nice window frames (from the nice folks over at meebo) and easy (as easy as CSS can be :) theming.

All the desktop effects (expose, the alt-tab picker, minimization/maximization) are written in javascript and can make use of whatever javascript animation library you want to use. Multiple views of native windows are possible so expose and the window picker window contents are live and update as you’d expect.

It also provides a way for javascript components to be written that appear as toplevel windows (such as the entirely javascript+html flickr feed viewer and debug window seen here).

Anyway, download it, build it, try it out, and let us know what you think! :)

Powered by WordPress | Theme by Roy Tanck