DADrawingSurface Class

The DADrawingSurface class uses a style of drawing that depends on a graphics context. This is in contrast to the other Microsoft® DirectAnimation® classes that use a constructive approach. The constructive approach combines primitive data types into a more complex model, in a hierarchical fashion.

The graphics context approach is analagous to the way a pen plotter works, where the pen acts as the mechanical extension of a hand and the plotter acts as a piece of paper. To draw something the pen is directed to a location on the plotter and then draws the shape. Many people find this approach to be more familiar than hierarchical modeling. For example, to draw the sun in the sky it may seem more obvious to simply draw a yellow circle exactly where you want it instead of first drawing a circle, then creating a yellow circle, and then, with a transform, creating yet another yellow circle that is now correctly placed. The difference is in the approach rather than in capabilities.

A DADrawingSurface object maintains a graphics state object for two-dimensional graphics. This state includes attributes such as line style, fill style, border style, font style, and two-dimensional transformations. The drawing commands (such as Oval and RoundRect are always interpreted in terms of the current state.

For relevant functions in the DAStatics class, see DAStatics Functions Relevant to DADrawingSurface Objects.

DADrawingSurface Functions

ArcDegreesDraws a portion of an oval. (This is, in effect, an arc).
ArcRadiansDraws a portion of an oval. (This is, in effect, an arc). Same as ArcDegrees except that startAngle and endAngle are expressed in radians.
AutoSizeFillScaleScales the fill pattern horizontally and vertically to fit the drawn object's bounding box.
BorderColorSpecifies the color of a filled region's outline (border).
BorderDashStyleSets the dash style of the border.
BorderJoinStyleSpecifies the border's join style.
BorderWidthSets the width of the border, in points.
ClearResets both the global images (Image) and the local context images (LocalContextImage).
CropSets a rectangular cropping region outside of which drawing commands have no effect.
CropPoints Sets a rectangular cropping region outside of which drawing commands have no effect. Same as Crop except that the parameters are specified as DAPoint2 objects.
DrawPathDraws a set of line segments according to the current line style. Same as Polyline, except that it takes a DAPath2 object instead of points.
FillColorIf used with a gradient fill, specifies the starting color. If used with a hatched fill, specifies its color.
FillImageCreates a fill pattern that is an image.
FillPathDraws and fills a polygon, using the current fill and border styles. Same as Polygon except that it takes a DAPath2 object rather than points.
FillStyleSets the fill style.
FillTextureSpecifies a fill image that will be tiled (according to its bounding box) and/or clipped to fit within the extents of the path.
FixedFillScaleSpecifies that the fill pattern will not be be scaled.
FontSets the font attributes.
GradientExtent Specifies a length and a direction for a gradient to transition between colors.
GradientExtentPoints Specifies a length and a direction for a gradient to transition between colors. Same as GradientExtent except that the parameters are DAPoint2 objects.
GradientRolloffPower Controls the sharpness of the transition between the colors. Same as GradientRolloffPowerAnim except that power is a nonanimated number (a double).
GradientRolloffPowerAnim Controls the sharpness of the transition between the colors.
GradientShapeSpecifies a polygon that is progressively scaled to control the shape of the color transition.
HorizontalFillScaleStretches or compresses the fill pattern horizontally to match the width of the drawn object's bounding box.
LineDraws a line segment from the starting point to the ending point, using the current LineDashStyle.
LineColorSets the color of the line.
LineDashStyleSets the dash style of the line.
LineEndStyleSets the end style of the line.
LineJoinStyleSets the join style of the line.
LinePointsDraws a line segment from the starting point to the ending point, using the current LineDashStyle. Same as Line except that the parameters are DAPoint2 objects (they can be animated).
LineWidthSets the width of the current line, in points.
OpacitySets the opacity used by drawing commands. Same as OpacityAnim except that opac is a nonanimated number (a double).
OpacityAnimSets the opacity used by drawing commands.
OvalDraws an outline of an oval and fills it, using the current fill and border styles.
OverlayImageOverlays a DAImage object onto the current drawing surface.
PieDegreesRenders a closed path that traces a segment of an oval and connects it to the origin.
PieRadiansRenders a closed path that traces a segment of an oval and connects it to the origin. Same as PieDegrees except that startAngle and endAngle are expressed in radians.
PolygonDraws and fills a polygon, using the current fill and border styles.
PolylineDraws a set of line segments according to the current line style.
RectDraws and fills a rectangle, using the current fill and border styles.
ResetResets the local context and sets all attributes to their defaults (nested transformations from the context still apply although local transformations are reset).
RestoreGraphicsStateRestores the drawing surface's graphics state (the font, color, fill styles, and so on) to what it was before the last SaveGraphicsState.
RoundRectDraws a rectangle with rounded rather than square corners.
SaveGraphicsStateSaves the drawing surface's current graphics state by pushing it onto an internal stack.
SecondaryFillColorSpecifies a secondary fill color.
TextCreates a filled region from the text outlines, using the current font style to determine the size of the font and the face.
TextPointCreates a filled region from the text outlines, using the current font style to determine the size of the font and the face. Same as Text except that the starting location is given by a DAPoint2 object.
TransformTransform operations include translation, scaling, and/or shearing. The function affects only the state used for upcoming drawing methods, not the current drawing.
VerticalFillScaleStretches or compresses the fill pattern vertically to match the width of the drawn object's bounding box.

DADrawingSurface Properties

BorderStyleA write-only property that specifies a DALineStyle object describing how the outline of a filled region will be drawn.
ClipMatteA write-only property that specifies an image matte (or masking stencil) for the drawing context.
FontStyleA write-only property that specifies a DAFontStyle (animated) object that sets font attributes such as face, size, and color.
HatchFillTransparentA write-only property that is a boolean value specifying whether the hatch fill is transparent.
ImageA read-only property that retrieves the DAImage object (animated image) associated with the DrawingSurface.
LineStyleA write-only property that adds a DALineStyle to the graphics state.
LocalContextImageA read-only property that retrieves an image that corresponds to what was drawn since the latest SaveGraphicsState call.
MouseEventsEnabledA write-only property that specifies whether mouseover and selection events will be detected for the objects subsequently drawn.

DADrawingSurface Functions

This section contains reference material for the DADrawingSurface functions.

ArcDegrees

DADrawingSurface Class

Draws a portion of an oval. (This is, in effect, an arc).

Syntax

drawingObj.ArcDegrees( xPos, yPos, startAngle, endAngle, arcWidth, arcHeight )

Parameters

xPos
The x-coordinate of the lower-lefthand corner of the oval's bounding box.
yPos
The y-coordinate of the lower-lefthand corner of the oval's bounding box.
startAngle
Angle, in degrees, where the arc begins.
endAngle
Angle, in degrees, where the arc ends.
arcWidth
Arc width, in either pixels or meters, depending on whether the PixelLibrary or the MeterLibrary is selected.
arcHeight
Arc height, in either pixels or meters, depending on whether the PixelLibrary or the MeterLibrary is selected.

Example

The following example, in VBScript, draws a series of differently-sized arcs.

<HTML>
<HEAD>
<TITLE>Demonstration of ArcDegrees Function</TITLE>
</HEAD>

<BODY>

<DIV ID=controlDiv>
<OBJECT ID="DAViewer"
        STYLE="position:absolute; left:10; top:10;width:450;height:450"
        CLASSID="CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D">
</OBJECT>
</DIV>

<SCRIPT LANGUAGE="VBScript">

sub window_onLoad 

  Set s = DAViewer.MeterLibrary
  Set ds = s.NewDrawingSurface()

  ds.Text "Degrees 0", -.04, .06
  ds.ArcDegrees 0, .05, 0, 0, .01, .01
  
  ds.Text "Degrees 45", -.04, .04
  ds.ArcDegrees 0, .03, 0, 45, .01, .01

  ds.Text "Degrees 90", -.04, .02
  ds.ArcDegrees 0, .01, 0, 90, .01, .01

  ds.Text "Degrees 180", -.04, 0
  ds.ArcDegrees 0, -.01, 0, 180, .01, .01

  ds.Text "Degrees 270", -.04, -.02
  ds.ArcDegrees 0, -.03, 0, 270, .01, .01

  ds.Text "Degrees 360", -.04, -.04
  ds.ArcDegrees 0, -.05, 0, 360, .01, .01

  DAViewer.Image = ds.Image
  DAViewer.Start

end sub

</SCRIPT>

</BODY>
</HTML>

ArcRadians

DADrawingSurface Class

Draws a portion of an oval. (This is, in effect, an arc). Same as ArcDegrees except that startAngle and endAngle are expressed in radians.

Syntax

drawingObj.ArcRadians( xPos, yPos, startAngle, endAngle, arcWidth, arcHeight )

Parameters

xPos
The x-coordinate of the lower-left corner of the oval's bounding box.
yPos
The y-coordinate of the lower-left corner of the oval's bounding box.
startAngle
Angle, in radians, where the arc begins.
endAngle
Angle, in radians, where the arc ends.
arcWidth
Arc width, in either pixels or meters, depending on whether the PixelLibrary or the MeterLibrary is selected.
arcHeight
Arc height, in either pixels or meters, depending on whether the PixelLibrary or the MeterLibrary is selected.

AutoSizeFillScale

DADrawingSurface Class

Scales the fill pattern horizontally and vertically to fit the drawn object's bounding box.

Syntax

drawingObj.AutoSizeFillScale( )

Remarks

There is no guarantee that the entire fill style will appear in a drawn object because many fill regions are not rectangular.

BorderColor

DADrawingSurface Class

Specifies the color of a filled region's outline (border).

Syntax

drawingObj.BorderColor( color )

Parameters

color
DAColor object that is the color of the border.

BorderDashStyle

DADrawingSurface Class

Sets the dash style of the border.

Syntax

drawingObj.BorderDashStyle( id )

Parameters

id
Number (a long) that sets the dash style of the border. For a table listing the available choices, see LineDashStyle.

BorderJoinStyle

DADrawingSurface Class

Specifies the border's join style. By default, the join style is bevel.

Syntax

drawingObj.BorderJoinStyle( id )

Parameters

id
ID (a long) of the selected join style. Can be any of the following possible styles.
IDJoin Style
0 Bevel
1 Round
2 Miter

BorderWidth

DADrawingSurface Class

Sets the width of the border, in points. Border widths are affected by Transform. For example, scaling by 2 will double the border width.

Syntax

drawingObj.BorderWidth( width )

Parameters

width
Number (a double) that is the border width. The units are in points.

Example

The following example demonstrates different border widths, using JScript.

<HTML>
<HEAD>
<TITLE>Demonstration of BorderWidth Function</TITLE>
</HEAD>

<BODY>

<DIV ID=controlDiv>
<OBJECT ID="DAViewer"
        STYLE="position:absolute; left:10; top:10;width:450;height:450"
        CLASSID="CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D">
</OBJECT>
</DIV>


<SCRIPT LANGUAGE="JScript" for="window" event="onload">
  s  = DAViewer.MeterLibrary;
  ds = s.NewDrawingSurface();

  ds.BorderWidth(1);
  ds.Rect(0, .05, .06, .01);
  
  ds.BorderWidth(2);
  ds.Rect(0, .03, .06, .01);

  ds.BorderWidth(3);
  ds.Rect(0, .01, .06, .01);
  
  ds.BorderWidth(4);
  ds.Rect(0, -.01, .06, .01);

  ds.BorderWidth(5);
  ds.Rect(0, -.03, .06, .01);
  
  DAViewer.Image = ds.Image;
  DAViewer.Start();

</SCRIPT>

</BODY>
</HTML>

Clear

DADrawingSurface Class

Resets both the global images (Image) and the local context images (LocalContextImage). All attributes for the local context images are set to their defaults.

Syntax

drawingObj.Clear( )

Crop

DADrawingSurface Class

Sets a rectangular cropping region outside of which drawing commands have no effect. Note that, unlike the DAImage Crop function, this Crop function affects what will be drawn, not what has been drawn.

Syntax

drawingObj.Crop( minX, minY, maxX, maxY )

Parameters

minX
Number (a double) specifying the minimum x-coordinate of the rectangular cropping region.
minY
Number (a double) specifying the minimum y-coordinate of the rectangular cropping region.
maxX
Number (a double) specifying the maximum x-coordinate of the rectangular cropping region.
maxY
Number (a double) specifying the maximum y-coordinate of the rectangular cropping region.

CropPoints

DADrawingSurface Class

Sets a rectangular cropping region outside of which drawing commands have no effect. Same as Crop except that the parameters are specified as DAPoint2 objects.

Syntax

drawingObj.CropPoints( min, max )

Parameters

min
DAPoint2 object specifying the minimum point of the cropping region.
max
DAPoint2 object specifying the maximum point of the cropping region.

DrawPath

DADrawingSurface Class

Draws a set of line segments according to the current line style. Same as Polyline, except that it takes a DAPath2 object instead of points.

Syntax

drawingObj.DrawPath( path )

Parameters

path
DAPath2 object defining the line.

FillColor

DADrawingSurface Class

If used with a gradient fill, specifies the starting color. If used with a hatched fill, specifies its color. It is ignored for solid fills. The default foreground color is black.

Syntax

drawingObj.FillColor( foreground )

Parameters

foreground
DAColor object that is the foreground color.

FillImage

DADrawingSurface Class

Creates a fill pattern that is an image. This function allows you to create your own fill pattern from any type of two-dimensional animation. The default is to scale the image to fit the window. If the mode is set to FixedFillScale and the image is transformed before being passed in, it will retain its position relative to the shape.

Syntax

drawingObj.FillImage( img )

Parameters

img
DAImage object to be used as the fill.

FillPath

DADrawingSurface Class

Draws and fills a polygon, using the current fill and border styles. Same as Polygon except that it takes a DAPath2 object rather than points.

Syntax

drawingObj.FillPath( path )

Parameters

path
DAPath2 object defining the polygon.

FillStyle

DADrawingSurface Class

Sets the fill style.

Syntax

drawingObj.FillStyle( id )

Parameters

id
ID (a long) of the fill style. Can be any of the following possible styles.
IDStyle
0 Empty (does not support mouse events)
1 Solid
2 Empty Pickable (supports mouse events)
3 HatchHorizontal
4 HatchVertical
5 HatchForwardDiagonal
6 HatchBackwardDiagonal
7 HatchCross
8 HatchDiagonalCross
9 HorizontalGradient
10 VerticalGradient
11 RadialGradient
12 LinearGradient
13 RectangularGradient
14 ShapeGradient

Remarks

Fill styles are used to paint closed regions. The default fill type is the solid fill. Some uses of particular fill styles are:

Fill colors are used in three ways. For gradient fills, the fill color is the first color used for blending. For hatched fills, it is the color used to draw the hatch marks. For solid fills, it is the color used for the entire filled area. It does not apply to empty and texture fill styles. The default color is black.

A secondary (or background) fill color is possible and is also used in several ways. For gradient fills, it specifies the second color used for blending. For hatch fills, it is the color used to fill around the hatch marks. For empty fills, it is always transparent. Solid fills have no secondary color. The default secondary color depends on the fill type. For solid and gradient fills, the default background color is white. For hatched fills, the default background color is transparent.

Gradient and texture fills can be either scaled to fit the shape being filled or can use their own scaling information. This is called a size-to-fit option. It does not apply to empty, solid, or hatched fill styles.

Scale-to-fit uses rectangular bounding regions to scale the fill style into the region to be filled. Thus, scale-to-fit does not guarantee that the entire fill style will appear in the shape because many fill regions are not rectangular. Gradient fills in which no interpolation coordinates are specified use scale-to-fit by default. Gradient fills with explicit coordinates as well as all texture fills, by default, use their local coordinates and are not scaled to fit the drawing region. For particular scale-to-fit functions, see AutoSizeFillScale, FixedFillScale, HorizontalFillScale, and VerticalFillScale.

For gradient fills, it can be useful to explicitly set the starting and ending positions for the transition between the colors. For example, with a radial gradient, (which is a color transition in a circular shape) it may be useful to set the center point. To set these points, use the GradientExtent function.

The GradientRolloffPower function uses an exponent (the power argument) to control how rapidly one color transitions into another. A value of 1 is a linear transition. For 0 < power < 1 the transition occurs rapidly, while power > 1 means that the transition occurs more slowly. For example, if you are transitioning from red to blue, and power = 2, you will see a great deal of red in the gradient fill. On the other hand, if power = 0.5 (the inverse of 2), you will see very little red. If power = 0, you will see only blue.

More precisely, if x is considered the normalized distance (from 0 to 1), then the gradient is xp, where p is in the range [0, infinity].

The following table summarizes the default values of the different fill attributes (such as color) for each fill style:
DefaultEmptyEmpty/PickableSolidHatchedGradientTextureImage
Fill Color N/A N/A Black Black Black N/A N/A
Secondary N/A N/A N/A Transparent White N/A N/A
Mouse Events? Always No Always Yes No No No No No
Size-to-fit N/A N/A N/A N/A Yes, if no start point, No, if start point specified Always No No
Gradient End Points N/A N/A N/A N/A No Default N/A N/A
Rolloff Power N/A N/A N/A N/A 1 N/A N/A

FillTexture

DADrawingSurface Class

Specifies a fill image that will be tiled (according to its bounding box) and/or clipped to fit within the extents of the path. It is not scaled. If the image is transformed before being passed in, it will retain its position relative to the shape.

Syntax

drawingObj.FillTexture( image )

Parameters

image
DAImage used as the fill.

FixedFillScale

DADrawingSurface Class

Specifies that the fill pattern will not be be scaled. The fill style attributes are applied directly to the drawn object, regardless of size.

Syntax

drawingObj.FixedFillScale( )

Font

DADrawingSurface Class

Sets the font attributes.

Syntax

drawingObj.Font( face, size, bold, italic, underline, strikethrough )

Parameters

face
Name of the font family (this is a string).
size
Size of the font, in points.
bold
Boolean value that turns the bold attribute on or off.
italic
Boolean value that turns the italic attribute on or off.
underline
Boolean value that turns the underline attribute on or off.
strikethrough
Boolean value that turns the strikethrough attribute on or off.

GradientExtent

DADrawingSurface Class

Specifies a length and a direction for a gradient to transition between colors. The starting color is unblended, as is the ending color. Between the points, the colors are blended according to the gradient type.

Syntax

drawingObj.GradientExtent( startX, startY, endX, endY )

Parameters

startX
Starting x-coordinate(a double).
startY
Starting y-coordinate (a double).
endX
Ending x-coordinate (a double).
endY
Ending y-coordinate (a double).

See Also

FillStyle

GradientExtentPoints

DADrawingSurface Class

Specifies a length and a direction for a gradient to transition between colors. Same as GradientExtent except that the parameters are DAPoint2 objects.

Syntax

drawingObj.GradientExtentPoints( startPoint, endPoint )

Parameters

startPoint
DAPoint2 object that specifies the location of the starting color.
endPoint
DAPoint2 object that specifies the location of the ending color.

GradientRolloffPower

DADrawingSurface Class

Controls the sharpness of the transition between the colors. Same as GradientRolloffPowerAnim except that power is a nonanimated number (a double). In the current implementation, the power parameter is ignored.

Syntax

drawingObj.GradientRolloffPower( power )

Parameters

power
Nonanimated number (a double) that is an exponent controlling how rapidly one color transitions into another. In the current implementation, this is fixed at 1, which is a linear transition. The value of power is ignored.

GradientRolloffPowerAnim

DADrawingSurface Class

Controls the sharpness of the transition between the colors.

Syntax

drawingObj.GradientRolloffPowerAnim( power )

Parameters

power
DANumber object that is an exponent controlling how rapidly one color transitions into another. In the current implementation, this is fixed at 1, which is a linear transition. The value of power is ignored.

GradientShape

DADrawingSurface Class

Specifies a polygon that is progressively scaled to control the shape of the color transition. This applies only if the FillStyle function was invoked with an id of 14 (ShapeGradient).

Syntax

drawingObj.GradientShape( pts )

Parameters

pts
Array (variant) of points specifying the polygon.

HorizontalFillScale

DADrawingSurface Class

Stretches or compresses the fill pattern horizontally to match the width of the drawn object's bounding box.

Syntax

drawingObj.HorizontalFillScale( )

Remarks

There is no guarantee that the entire fill style will appear in drawn object because many fill regions are not rectangular.

Line

DADrawingSurface Class

Draws a line segment from the starting point to the ending point, using the current LineDashStyle.

Syntax

drawingObj.Line( startX, startY, endX, endY )

Parameters

startX
Starting point's x-coordinate (a double).
startY
Starting point's y-coordinate (a double).
endX
Ending point's x-coordinate (a double).
endY
Ending point's y-coordinate (a double).

LineColor

DADrawingSurface Class

Sets the color of the line.

Syntax

drawingObj.LineColor( col )

Parameters

col
DAColor object that sets the line color.

LineDashStyle

DADrawingSurface Class

Sets the dash style of the line.

Syntax

drawingObj.LineDashStyle( id )

Parameters

id
ID (a long) of the selected dash style. Can be any of the following possible styles.
IDDash Style
0 Null
1 Solid
2 Dash

LineEndStyle

DADrawingSurface Class

Sets the end style of the line.

Syntax

drawingObj.LineEndStyle( id )

Parameters

id
The number (a long) specifying which end style to use. Can be any of the following possible styles.
IDEnd Style
0 Flat
1 Square
2 Round

LineJoinStyle

DADrawingSurface Class

Sets the join style of the line. By default, the join style is bevel.

Syntax

drawingObj.LineJoinStyle( id )

Parameters

id
ID (a long) of the selected join style. Can be any of the following possible styles.
IDJoin Style
0 Bevel
1 Round
2 Miter

LinePoints

DADrawingSurface Class

Draws a line segment from the starting point to the ending point, using the current LineDashStyle. Same as Line except that the parameters are DAPoint2 objects (they can be animated).

Syntax

drawingObj.LinePoints( pt1, pt2 )

Parameters

pt1 and pt2
DAPoint2 objects specifying the line's starting and ending points.

LineWidth

DADrawingSurface Class

Sets the width of the current line, in points. Line widths are affected by Transform. For example, scaling by 2 will double the line width.

Syntax

drawingObj.LineWidth( width )

Parameters

width
Width of the current line, in points.

Opacity

DADrawingSurface Class

Sets the opacity used by drawing commands. Same as OpacityAnim except that opac is a nonanimated number (a double).

Syntax

drawingObj.Opacity( opac )

Parameters

opac
A double value that sets the opacity. Values can range from 0.0 (fully transparent) to 1.0 (fully opaque). This is a nonanimated number.

OpacityAnim

DADrawingSurface Class

Sets the opacity used by drawing commands. In contrast to the DAImage Opacity function, this OpacityAnim function affects what will be drawn rather than what has been drawn.

Syntax

drawingObj.OpacityAnim( opac )

Parameters

opac
DANumber object that sets the opacity. Values can range from 0.0 (fully transparent) to 1.0 (fully opaque). This must be an animated number.

Oval

DADrawingSurface Class

Draws an outline of an oval and fills it, using the current fill and border styles.

Syntax

drawingObj.Oval( xPos, yPos, width, height )

Parameters

xPos
The x-coordinate (a double) of the lower-lefthand corner of the oval's bounding box.
yPos
The y-coordinate (a double) of the lower-lefthand corner of the oval's bounding box.
width
Width of the oval, in either pixels or meters, depending on whether the PixelLibrary or the MeterLibrary is selected.
height
Height of the oval, in either pixels or meters, depending on whether the PixelLibrary or the MeterLibrary is selected.

Example

The following example uses VBScript to draw an oval with a hatch cross fill style:


<HTML>
<HEAD>
<TITLE>Oval with Hatch Cross Fill Style</TITLE>
</HEAD>

<BODY>

<DIV ID=controlDiv>
<OBJECT ID="DAViewer"
        STYLE="position:absolute; left:10; top:10;width:450;height:450"
        CLASSID="CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D">
</OBJECT>
</DIV>

<SCRIPT LANGUAGE="VBScript">

sub window_onLoad 

  Set s = DAViewer.MeterLibrary
  Set ds = s.NewDrawingSurface()

  ds.FillColor          s.ColorRgb255(0,0,200)
  ds.SecondaryFillColor s.ColorRgb255(255,0,0)

  ds.Text "Hatch Cross", -.04, .06
  ds.FillStyle 7
  ds.Oval -.04, -.04, .1, .1
  
  DAViewer.Image = ds.Image
  DAViewer.Start

end sub

</SCRIPT>

</BODY>
</HTML>

OverlayImage

DADrawingSurface Class

Overlays a DAImage object onto the current drawing surface. This means the image can be animated.

Syntax

drawingObj.OverlayImage( img )

Parameters

img
DAImage image.

PieDegrees

DADrawingSurface Class

Renders a closed path that traces a segment of an oval and connects it to the origin. (In effect, it is a pie-shaped wedge).

Syntax

drawingObj.PieDegrees( xPos, yPos, startAngle, endAngle, arcWidth, arcHeight )

Parameters

xPos
The x-coordinate (a double) of the lower-lefthand corner of the oval's bounding box.
yPos
The y-coordinate (a double) of the lower-lefthand corner of the oval's bounding box.
startAngle
Starting angle, in degrees (a double) of the wedge.
endAngle
Ending angle, in degrees (a double) of the wedge.
arcWidth
Double representing the arc width, expressed in meters, or pixels, depending on whether the MeterLibrary or the PixelLibrary is selected.
arcHeight
Double representing the arc height, expressed in meters, or pixels, depending on whether the MeterLibrary or the PixelLibrary is selected.

Example

The following example uses VBScript to draw a series of wedges, each with a solid-red fill.


<HTML>
<HEAD>
<TITLE>Demonstration of PieDegrees Function</TITLE>
</HEAD>

<BODY>

<DIV ID=controlDiv>
<OBJECT ID="DAViewer"
        STYLE="position:absolute; left:10; top:10;width:450;height:450"
        CLASSID="CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D">
</OBJECT>
</DIV>

<SCRIPT LANGUAGE="VBScript">

sub window_onLoad 

  Set s = DAViewer.MeterLibrary
  Set ds = s.NewDrawingSurface()

  ds.FillStyle          1
  ds.FillColor          s.ColorRgb255(255,0,0)
  
  ds.Text "Degrees 0", -.04, .06
  ds.PieDegrees 0, .05, 0, 0, .01, .01
  
  ds.Text "Degrees 45", -.04, .04
  ds.PieDegrees 0, .03, 0, 45, .01, .01

  ds.Text "Degrees 90", -.04, .02
  ds.PieDegrees 0, .01, 0, 90, .01, .01

  ds.Text "Degrees 180", -.04, 0
  ds.PieDegrees 0, -.01, 0, 180, .01, .01

  ds.Text "Degrees 270", -.04, -.02
  ds.PieDegrees 0, -.03, 0, 270, .01, .01

  ds.Text "Degrees 360", -.04, -.04
  ds.PieDegrees 0, -.05, 0, 360, .01, .01

  DAViewer.Image = ds.Image
  DAViewer.Start

end sub

</SCRIPT>

</BODY>
</HTML>

PieRadians

DADrawingSurface Class

Renders a closed path that traces a segment of an oval and connects it to the origin. Same as PieDegrees except that startAngle and endAngle are expressed in radians.

Syntax

drawingObj.PieRadians( xPos, yPos, startAngle, endAngle, arcWidth, arcHeight )

Parameters

xPos
The x-coordinate (a double) of the lower-lefthand corner of the oval's bounding box.
yPos
The y-coordinate (a double) of the lower-lefthand corner of the oval's bounding box.
startAngle
Starting angle, in radians (a double), of the wedge.
endAngle
Ending angle, in radians (a double), of the wedge.
arcWidth
Double representing the arc width, expressed in meters, or pixels, depending on whether the MeterLibrary or the PixelLibrary is selected.
arcHeight
Double representing the arc height, expressed in meters, or pixels, depending on whether the MeterLibrary or the PixelLibrary is selected.

Polygon

DADrawingSurface Class

Draws and fills a polygon, using the current fill and border styles. The points can be specified as a variant array of either DAPoint2[] objects or doubles. The array of doubles array must contain (2 * numPts) because it represents (x, y) coordinate pairs.

Syntax

drawingObj.Polygon( points )

Parameters

points
Array (variant) of either DAPoint2[] objects or (x, y) coordinates (doubles).

Polyline

DADrawingSurface Class

Draws a set of line segments according to the current line style. The points can be specified as a variant array of either DAPoint2[] objects or doubles. The array of doubles array must contain (2 * numPts) because it represents (x, y) coordinate pairs.

Syntax

drawingObj.Polyline( points )

Parameters

points
Array (variant) of either DAPoint2[] objects or (x, y) coordinates (doubles).

Rect

DADrawingSurface Class

Draws and fills a rectangle, using the current fill and border styles.

Syntax

drawingObj.Rect( xPos, yPos, width, height )

Parameters

xPos
A double value that is the x-coordinate of the lower-lefthand corner of the rectangle's bounding box.
yPos
A double that is the y-coordinate of the lower-lefthand corner of the rectangle's bounding box.
width
Width of the rectangle (a double), in either pixels or meters, depending on whether the PixelLibrary or the MeterLibrary is selected.
height
Height of the rectangle (a double), in either pixels or meters, depending on whether the PixelLibrary or the MeterLibrary is selected.

Reset

DADrawingSurface Class

Resets the local context and sets all attributes to their defaults (nested transformations from the context still apply although local transformations are reset). This function affects only the state used for upcoming drawing methods, not the current drawing.

Syntax

drawingObj.Reset( )

RestoreGraphicsState

DADrawingSurface Class

Restores the drawing surface's graphics state (the font, color, fill styles, and so on) to what it was before the last SaveGraphicsState.

Syntax

drawingObj.RestoreGraphicsState( )

RoundRect

DADrawingSurface Class

Draws a rectangle with rounded rather than square corners. The corners are considered to be segments of an oval (in effect, an arc).

Syntax

drawingObj.RoundRect( xPos, yPos, width, height, arcWidth, arcHeight )

Parameters

xPos
A double value that is the x-coordinate of the lower-lefthand corner of the rectangle's bounding box.
yPos
A double that is the y-coordinate of the lower-lefthand corner of the rectangle's bounding box.
width
A double that is the width of the rectangle, in either pixels or meters, depending on whether the PixelLibrary or the MeterLibrary is selected.
height
A double that is the the height of the rectangle, in either pixels or meters, depending on whether the PixelLibrary or the MeterLibrary is selected.
arcWidth
Arc width (a double) in either pixels or meters, depending on whether the PixelLibrary or the MeterLibrary is selected.
arcHeight
Arc height (a double), in either pixels or meters, depending on whether the PixelLibrary or the MeterLibrary is selected.

SaveGraphicsState

DADrawingSurface Class

Saves the drawing surface's current graphics state by pushing it onto an internal stack.

Syntax

drawingObj.SaveGraphicsState( )

SecondaryFillColor

DADrawingSurface Class

Specifies a secondary fill color. For gradient fills, this is the second color used for blending. For hatch fills, it is the color used to fill around the hatch marks. For empty fills, it is always transparent. It does not apply to solid fills.

Syntax

drawingObj.SecondaryFillColor( val )

Parameters

val
DAColor object that is the secondary color.

See Also

FillColor

Text

DADrawingSurface Class

Creates a filled region from the text outlines, using the current font style to determine the size of the font and the face. Color and other attributes come from the current fill and border styles. Note that the color attribute of the current font style is ignored. The text's starting location is given by xPos, yPos.

Syntax

drawingObj.Text( string, xPos, yPos )

Parameters

string
Text used as the outline (a string).
xPos
Starting point's x-coordinate (a double).
yPos
Starting point's y-coordinate (a double).

TextPoint

DADrawingSurface Class

Creates a filled region from the text outlines, using the current font style to determine the size of the font and the face. Same as Text except that the starting location is given by a DAPoint2 object.

Syntax

drawingObj.TextPoint( string, pt )

Parameters

string
Text used as the outline (a string).
pt
DAPoint2 object designating the text's starting location. This can be animated.

Transform

DADrawingSurface Class

Transform operations include translation, scaling, and/or shearing. The function affects only the state used for upcoming drawing methods, not the current drawing. This operation is cumulative.

Syntax

drawingObj.Transform( xf )

Parameters

xf
DATransform2 object that is the two-dimensional transform.

VerticalFillScale

DADrawingSurface Class

Stretches or compresses the fill pattern vertically to match the width of the drawn object's bounding box.

Syntax

drawingObj.VerticalFillScale( )

Remarks

There is no guarantee that the entire fill style will appear in drawn object because many fill regions are not rectangular.

DADrawingSurface Properties

This section contains reference material for the DADrawingSurface properties.

BorderStyle

DADrawingSurface Class

A DALineStyle object that specifies how the outline of a filled region will be drawn. The color specified in the line style determines the color of the border. (Interior fills are specified with FillStyle.) For an alternative way of setting border attributes, see BorderColor, BorderDashStyle, BorderJoinStyle, and BorderWidth.

Syntax

drawingObj.BorderStyle

Remarks

As an example how to use this property, see the following JScript code:

ds.BorderStyle = m.DefaultLineStyle.Color(m.Black).Dash(n.DashStyleSolid);

ClipMatte

DADrawingSurface Class

A DAMatte object that specifies an image matte (or masking stencil) to the drawing context. Note that, unlike the DAImage Clip function, this property affects what will be drawn rather than what has already been drawn.

Syntax

drawingObj.ClipMatte

FontStyle

DADrawingSurface Class

A DAFontStyle (animated) object that sets font attributes such as face, size, and color.

Syntax

drawingObj.FontStyle

See Also

Font

HatchFillTransparent

DADrawingSurface Class

A Boolean value specifying whether the hatch fill is transparent.

Syntax

drawingObj.HatchFillTransparent

Image

DADrawingSurface Class

Retrieves the DAImage object (animated image) associated with the DrawingSurface.

Syntax

drawingObj.Image

LineStyle

DADrawingSurface Class

Adds a DALineStyle to the graphics state. A DALineStyle object determines the line color, dash style, width, endpoint, and join style. Setting this property affects how the line drawing commands (such as ArcRadians and Polyline) are drawn.

Syntax

drawingObj.LineStyle

See Also

LineColor, LineDashStyle, LineEndStyle, LineJoinStyle, LineWidth

LocalContextImage

DADrawingSurface Class

Retrieves an image that corresponds to what was drawn since the latest SaveGraphicsState call. This property is useful for instancing and procedural tiling.

Syntax

drawingObj.LocalContextImage

MouseEventsEnabled

DADrawingSurface Class

Specifies whether mouseover and selection events will be detected for the objects subsequently drawn. TRUE means that events are detected and FALSE means they are not.

Syntax

drawingObj.MouseEventsEnabled


Top of Page Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.