Frank Hileman's WebLog

Vector Graphics with VG.net and Visual Studio Integration

March 2004 - Posts

To simplify both code and xml files, we are considering the following set of name changes for Types in VG.net. If you use VG.net, and have an opinion on these changes, please post a comment.

Note we will keep the name of the Type and the name of any property of that Type identical. For example, currently the Style class has a property named TextStyle, which returns an instance of the TextStyle class.

First, classes related to object appearances (styling).

Current Name

New Name

Notes

Style

Style

No change. A Style currently contains one of each: BrushStyle, PenStyle, TextStyle, and RenderStyle.

SubStyle

AppearanceProperties

SubStyle is currently the name of the base class for BrushStyle, PenStyle, TextStyle, and RenderStyle.

BrushStyle

Fill

This class specifies the appearance of filled interior areas in shapes, as well as the fill used within TextStyle (TextProperties) and PenStyle (Stroke). Since Fill is a base class, the name change would affect a number of derived classes: SolidBrushStyle becomes SolidFill, etc.

PenStyle

Stroke

Specifies the appearance of shape edges. Contains a BrushStyle (Fill).

TextStyle

TextProperties

Specifies the appearance of text. Contains a BrushStyle (Fill). We cannot simply change the name to Text, as there is a string Text property in each Shape.

RenderStyle

RenderProperties

Specifies rendering options: anti-aliasing, gamma-corrected or linear composting of translucent pixels, and the pixel offset mode.

Here are newly proposed names for various Shape classes.

Current Name

New Name

Notes

RectangleShape

Rectangle

This will cause a conflict with the integer rectangle System.Drawing.Rectangle. Because all coordinates in VG.net are stored as floats, we believe code using integer rectangles may rarely mix with VG.net code. If many people believe the conflict will cause problems, we can leave RectangleShape as is.

EllipseShape

Ellipse

 

ArcShape

Arc

 

PieShape

Pie

 

PolylineShape

Polyline

 

SplineShape

Spline

 

PathShape

Path

 

Finally, we are proposing changes to our namespaces and dlls:

Current Name

New Name

ProdigeSoftware.Drawing

Prodige.Drawing

ProdigeSoftware.Drawing.Styles

Prodige.Drawing.Styles

ProdigeSoftware.Drawing.dll

Prodige.Drawing.dll

We just added the following properties to TextStyle:

  • VerticalAlignment
  • SizeUnit: the unit to be used for the Size property, expressed as a GraphicsUnit (World, Points, Millimeters, etc)

We changed the Alignment property to HorizontalAlignment.

There is a problem with SizeUnit. By default, we would like to use a SizeUnit that has a constant ratio with the coordinates used to express all graphics -- world coordinates. That SizeUnit is, you guessed, World. If you use World for SizeUnit, you are guaranteed that your text will have the same height in proportion to your grpahics, no matter what machine it is displayed on, and no matter how it is scaled.

But World coordinates, if not transformed, are equal to device coordiantes -- pixels. Expressing the Size of a TextStyle in terms of pixels is simply not intuitive. People are used to Points. We need to default to Points. Unfortunately, if you use Points for SizeUnit, your text may suddenly become too big or too small if you display on a screen with a different DPI. For example, this nice picture, from the Users Guide:

might suddenly look like this:

There is no such thing as a “device independent Points unit“ (though the Avalon team has no problem with a “device independent pixels“ oxymoron). The Points unit is fundamentally based on inches.

Suggestions?

Posted by Frank Hileman | with no comments

Hart asked a couple interesting questions in the last blog entry.

“Are you going to add some higher level animation api, like svg and avalon have”: we call this declarative animation, where you declare animation, instead of writing code.

Currently, you animate VG.net vector graphics by changing properties, in the Display timer event, or at any time. This is an excellent way to do animation if you are visualizing real-time data.

However, it is not so great for demos, cartoons, transitions between states, or advertising. Out of all these, we are only concerned with demos and transitions between states. We did not want VG.net to be a Flash replacement – people generally hate Flash ads.

We would like to add these things to VG.net, eventually:

  • A way to connect Pictures to real-time data, to animate without writing code.
  • A way to specify transitions between states for any graphical property. For example, gradual transition between various colors, based on an input value, or a transition between two positions on the screen.
  • A way to specify simulated data, for demonstrations, without writing code.

All of these require higher-level declarative animation objects. However, they will not necessarily look like SVG or Avalon animation objects. Our primary target is real-time data visualization, so we will produce an API and editor suited to that purpose. A secondary target is custom graphical controls, but these typically do not use fancy animation.

We did do some work on real-time data binding, but it has not made it into the product.

“How many man years would you estimate has gone into the development of this product”: Probably about 4 person years. Some of the ideas in the engine originated many years ago. We have much experience with vector graphics systems and editors, but Visual Studio integration was very difficult.

I am the lead developer for VG.net, an animated vector graphics system with a graphics designer integrated in Visual Studio .NET. I will be talking about VG.net, techniques for building animated vector components, and MyXaml. I also hope to post some overviews of the designer infrastructure in the .NET framework, and tips for creating root designers in Visual Studio .NET.

Here is an illustration of the latest feature added to VG.net, the ability to edit PathShape points and control points:

VG.net PathShape Point Editing

If you grab the diamond shaped adorments, you can drag around the control points for the spline on either side of the selected point, indicated by the blue “halo“. You may be thinking, what is this VG.net thing? Look at the VG.net website for an explanation.

For comparision, look at this beautiful spline designer for Avalon, created by Nikhil Kothari. He is using controls that make the Visual Studio interface look clunky. A beautiful job, but the VG.net designer is more powerful. You can create animated graphics without Avalon -- no need to wait.

More Posts