Class

PixmapShape


Description

Used to place a picture in a vector graphics environment.

Methods

Name

Parameters

Returns

Shared

Constructor

image As Picture

Contains

X As Double, Y As Double

Boolean

Property descriptions


PixmapShape.Height

Height As Double

The height of the rectangle.

This example sets the height and width of the shape to 150 pixels.

Var r As New RectShape
r.Width = 150
r.Height = 150
r.Border = 100
r.BorderColor = Color.Black
r.FillColor = Color.Teal
r.BorderWidth = 2.5
r.Rotation = -0.78
g.DrawObject(r)

PixmapShape.Image

Image As Picture

The source image to use.

This example uses a jpeg image that has been added to the project. You can also initialize the PixmapShape to the image using the constructor. This code is is in the Paint event of a Canvas:

Var p As Picture
Var px As PixmapShape
p = New Picture(640, 480)
px = New PixmapShape(p)
px.Image = CarImage

g.DrawObject(px)

PixmapShape.Rotation

Rotation As Double

Clockwise rotation, in radians, around the X, Y point. Only set the rotation after you have drawn all your objects.

This code rotates the arc 0.9 radians.

Var a As New ArcShape
a.Height = 150
a.Width = 150
a.Rotation = 0.90
a.ArcAngle = 1.57
a.StartAngle = -1.57
g.DrawObject(a)

PixmapShape.Scale

Scale As Double

The scaling factor relative to the object's original size.

The following code rescales the arc by a factor of 1.5.

Var a As New ArcShape
a.Scale = 1.5
a.Rotation = .90
a.ArcAngle = 1.57
a.StartAngle = -1.57
g.DrawObject(a)

PixmapShape.SourceHeight

SourceHeight As Integer

The height (pixels) of the source image, from SourceTop, SourceLeft. Used to define a subregion of Image to use.

This example reports the left, top, width, and height of the image that was assigned to the PixmapShape. This image was added to the project and the coordinates are 0, 0, 558, 372.

Var p As Picture
Var px As PixmapShape
p = New Picture(558, 372)
px = New PixmapShape(p)
px.Image = CarImage

Label1.Text = px.SourceLeft.ToString
Label2.Text = px.SourceTop.ToString
Label3.Text = px.SourceWidth.ToString
Label4.Text = px.SourceHeight.ToString

PixmapShape.SourceLeft

SourceLeft As Double

The number of pixels from the left edge of the source image. Used to define the subregion of Image to draw.

This example reports the left, top, width, and height of the image that was assigned to the PixmapShape. This image was added to the project and the coordinates are 0, 0, 558, 372.

Var p As Picture
Var px As PixmapShape
p = New Picture(558, 372)
px = New PixmapShape(p)
px.Image = CarImage

Label1.Text = px.SourceLeft.ToString
Label2.Text = px.SourceTop.ToString
Label3.Text = px.SourceWidth.ToString
Label4.Text = px.SourceHeight.ToString

PixmapShape.SourceTop

SourceTop As Double

The number of pixels from the top edge of the source image. Used to define subregion of Image to draw.

This example reports the left, top, width, and height of the image that was assigned to the PixmapShape. This image was added to the project and the coordinates are 0, 0, 558, 372.

Var p As Picture
Var px As PixmapShape
p = New Picture(558, 372)
px = New PixmapShape(p)
px.Image = CarImage

Label1.Text = px.SourceLeft.ToString
Label2.Text = px.SourceTop.ToString
Label3.Text = px.SourceWidth.ToString
Label4.Text = px.SourceHeight.ToString

PixmapShape.SourceWidth

SourceWidth As Integer

The width (pixels) from SourceLeft of Image to draw. Used to define a subregion of Image to use.

This example reports the left, top, width, and height of the image that was assigned to the PixmapShape. This image was added to the project and the coordinates are 0, 0, 558, 372.

Var p As Picture
Var px As PixmapShape
p = New Picture(558, 372)
px = New PixmapShape(p)
px.Image = CarImage

Label1.Text = px.SourceLeft.ToString
Label2.Text = px.SourceTop.ToString
Label3.Text = px.SourceWidth.ToString
Label4.Text = px.SourceHeight.ToString

PixmapShape.Width

Width As Double

The width of the rectangle.


PixmapShape.X

X As Double

The horizontal position of the center or main anchor point.

This example sets the horizontal position to 100 pixels from the left of the containing Canvas.

Var a As New ArcShape
a.Height = 150
a.Width = 150
a.ArcAngle = 1.57
a.StartAngle = -1.57
a.X = 100
g.DrawObject(a)

PixmapShape.Y

Y As Double

The vertical position of the center or main anchor point.

Method descriptions


PixmapShape.Constructor

Constructor(image As Picture)

Note

Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.

Creates a new PixmapShape that is initialized to the passed image.

The following code in the Paint event of a Canvas draws a red oval using the Constructor to initialize the shape:

Var p As Picture
p = New Picture(240, 200)
p.Graphics.DrawingColor = Color.Black
p.Graphics.FillOval(0, 0, 240, 200)
Var px As New PixmapShape(p)
px.Rotation = 45 / 57.2958  ' 45 Degrees in radians
g.DrawObject(px)

PixmapShape.Contains

Contains(X As Double, Y As Double) As Boolean

Tests whether the object contains the point X, Y. Returns True if the rectangle contains the point specified by X, Y.

This code tests whether the RectShape contains the passed point:

Var r As New RectShape
r.Width = 75
r.Height = 75
r.Border = 100
r.Bordercolor = Color.Black
r.FillColor = Color.Teal
r.BorderWidth = 2.5
r.Rotation = -0.78
If r.Contains(50, 50) Then
  ' draw something here..
End If
g.DrawObject(r)

Sample code

The following method in the Paint event of a Canvas draws a red oval:

Var p As Picture
p = New Picture(240, 200)
p.Graphics.DrawingColor = Color.Black
p.Graphics.FillOval(0, 0, 240, 200)
Var px As New PixmapShape(p)
px.Rotation = 45 / 57.2958  ' 45 Degrees in radians
g.DrawObject(px)

Compatibility

Desktop and web project types on all supported operating systems.