Class
StringShape
Warning
This item was deprecated in version 2019r2. Please use TextShape as a replacement.
Description
Draws a text string in a vector graphics environment.
Properties
Name |
Type |
Read-Only |
Shared |
---|---|---|---|
Enumerations
StringShape.Alignment
Alignment
Used to set the HorizontalAlignment and VerticalAlignment properties. (Left, Top, Center, Baseline, Right, Bottom)
Enum |
Value |
---|---|
Left |
0 |
Top |
1 |
Center |
2 |
Baseline |
3 |
Right |
4 |
Bottom |
5 |
Property descriptions
StringShape.Bold
Bold As Boolean
StringShape.BorderOpacity
BorderOpacity As Double
Indicates the level of opacity.
Degrees of transparency is currently supported only on macOS and Windows. On other platforms, the border is either visible (100%) or invisible.
The following code adds a border to an ArcShape:
Var a As New ArcShape
a.ArcAngle = 1.57
a.StartAngle = -1.57
a.BorderOpacity = 100
a.FillColor =Color.RGB(255, 0, 127)
g.DrawObject(a, 100, 100)
StringShape.FillColor
FillColor As Color
The color of the interior of the shape.
StringShape.FillOpacity
FillOpacity As Double
The opacity of the interior, from 0 (completely transparent) to 100 (opaque).
This example sets the Fill to 50% opacity.
Var a As New ArcShape
a.ArcAngle = 1.57
a.StartAngle = -1.57
a.BorderOpacity = 100
a.BorderColor = &c0000ff
a.BorderWidth = 2.75
a.FillOpacity = 50
a.FillColor =Color.RGB(255, 0, 127)
g.DrawObject(a, 100, 100)
StringShape.HorizontalAlignment
HorizontalAlignment As Alignment
Sets the horizontal alignment of the StringShape.
The choices are: Left, Center, or Right. The default is Center. The alignment is relative to the Object2D.X property.
This example aligns the StringShape to the left.
Dim ss As New StringShape
ss.X = 20
ss.Text = "Hello World"
ss.HorizontalAlignment = StringShape.Alignment.Left
StringShape.Italic
Italic As Boolean
StringShape.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
a.Border = 100
a.BorderColor = &c0000ff
a.BorderWidth = 2.75
a.Fill = 50
a.FillColor =Color.RGB(255, 0, 127)
g.DrawObject(a, 100, 100)
StringShape.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
a.Border = 100
a.BorderColor = &c0000ff
a.BorderWidth = 2.75
a.Fill = 50
a.FillColor =Color.RGB(255, 0, 127)
g.DrawObject(a, 100, 100)
StringShape.Text
Text As String
The text to draw.
The text can be only one text style (font, font size, style) specified by the other StringShape properties. Use the FillColor property to change the color of the text. Use a carriage return between text to display with multiple lines.The default text is the empty string.
StringShape.TextFont
TextFont As String
StringShape.TextSize
TextSize As Double
Font size in points.
Use zero to choose the best font size for the current platform.
StringShape.TextUnit
TextUnit As FontUnits
The units in which TextSize is measured. The options are given in the following table.
This example sets the units to points using the class constant.
Dim s As New StringShape
s.TextUnit = FontUnits.Point
s.TextSize = 20
StringShape.Underline
Underline As Boolean
StringShape.VerticalAlignment
VerticalAlignment As Alignment
Sets the vertical alignment of the StringShape.
The choices are: Top, Baseline, or Bottom. The default is Baseline. The alignment is relative to the Object2D.X and Y properties.
This code aligns the StringShape to the top:
Dim ss As New StringShape
ss.X = 20
ss.Text = "Hello World"
ss.VerticalAlignment = StringShape.Alignment.Top
StringShape.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
a.Border = 100
a.BorderColor = &c0000ff
a.Fill = 50
a.FillColor =Color.RGB(255, 0, 127)
g.DrawObject(a, 0, 100)
StringShape.Y
Y As Double
The vertical position (down from top) position of the center or anchor point.
This example moves the position of the arc down 100 pixels from the top of the containing Canvas.
Var a As New ArcShape
a.Height = 150
a.Width = 150
a.ArcAngle = 1.57
a.StartAngle = -1.57
a.Y = 100
a.Border = 100
a.BorderColor = &c0000ff
a.Fill = 50
a.FillColor =Color.RGB(255, 0, 127)
g.DrawObject(a, 100, 100)
Notes
The X,Y properties specify the center of the string's baseline. Strings that contain line breaks are not supported. StringShapes can be rotated, but doing so is memory intensive, especially for large strings.
Although they will appear in auto-complete and compile, the Border, BorderColor and BorderWidth properties do not do anything with StringShape.
Use the FillColor property to change the color of the text.
Sample code
This example draws text rotated 90 degrees. Put it in the Paint event handler of a Canvas:
Dim s As New StringShape
s.Text = "Hello World"
s.TextFont = "Helvetica"
s.Bold = True
s.Rotation = 3.14159 / 2 ' (radians, 90 degrees = pi/2)
s.Y = 100
g.DrawObject(s)
This example aligns the StringShape to the left.
Dim s As New StringShape
s.X = 20
s.Text = "Hello World"
s.HorizontalAlignment = StringShape.Alignment.Left
g.DrawObject(s)
Compatibility
All project types on all supported operating systems.
See also
Object2D parent class; ArcShape, CurveShape, FigureShape, FolderItem, Group2D, Graphics, Object2D, OvalShape, Picture, PixmapShape, RectShape, RoundRectShape classes.