Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ XR Studio

RectShape2D

  • Last UpdatedFeb 19, 2025
  • 11 minute read

The RectShape2D node displays a shape that can be selected from predefined samples or defined arbitrarily, and an image or a gallery showreel of multiple images. The shape and images can be displayed together, in which case the image is displayed on the top of the shape.

RectShape2D facilitates the design of 2D interfaces by providing configuration parameters that allow you to easily manage how the graphic scales and aligns when the RectShape2D size or aspect ratio does not match the graphic size or aspect ratio.

Platform support

This element is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-P WASM platforms.

XR-WIN

XR-P-WIN

XR-P-IOS

XR-P-AND

XR-P-WASM

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Adaptive size support

RectShape2D provides functionalities to manage how the displayed image behaves when the node rect has a different size and aspect ratio from the displayed image. The behavior is configured independently through these parameters.

Parameter

Description

imageWrapAlignment

Defines the alignment of the displayed image relative to the node rect when the image aspect ratio and the node aspect ratio do not match. The following styles are supported: center, left, top, right, bottom, top_left, top_right, bottom_left, bottom_right.

imageWrapMode

Defines the wrap mode of the image in the node rect. The following styles are supported: fit, fill, fill_width, fill_height, original_size, stretch.

Any value except for stretch will make the displayed image keep its original aspect ratio relatively to the grid or the screen (depending on the parameter imageWrapKeepProportions).

Wrap mode

The imageWrapMode and shapeWrapMode fields define how the graphic is wrapped in the node rect.

stretch

The simplest behavior is achieved with the style stretch. This behaves exactly as a Rect2D node and stretches the graphic so that is covers the entire rect area.

fit

The fit behavior makes the graphic keep its original aspect ratio and keeps the whole graphic inside the node rect by possibly displaying a padding on the top, bottom, left, or right corners—depending on the container aspect ratio and selected imageWrapAlignment.

fill

The fill behavior makes the graphic keep its original aspect ratio and fills all the available space in the node rect by possibly cropping the graphic on the top, bottom, left, or right corners—depending on the container aspect ratio and selected imageWrapAlignment. The logic is to fill either the width or height of the node rect (whichever is smaller) and crop the graphic on the other measure.

fill_width

The fill_width behavior makes the graphic keep its original aspect ratio and fills all the available width in the node rect by possibly cropping the graphic or displaying a padding on the top or bottom—depending on the container aspect ratio and selected imageWrapAlignment. The logic is to fill the width of the node rect and crop or pad the graphic on the height.

fill_height

The fill_height behavior makes the graphic keep its original aspect ratio and fills all the available height in the node rect by possibly cropping the graphic or displaying a padding on the top or bottom—depending on the container aspect ratio and selected imageWrapAlignment. The logic is to fill the height of the node rect and crop or pad the graphic on the width.

original_size

The original_size behavior makes the graphic keep its original aspect ratio regardless of the size and aspect ratio of the container. Padding and cropping of the image may occur in both width and height when the node rect size is different from the graphic size depending on the selected imageWrapAlignment.

Wrap Alignment

The imageWrapAlignment field defines how to align the graphic inside the node rect when a wrap mode (different from stretch) is applied.

The most effective way to test this parameter’s effect is to render an image in a bigger container and select original_size as imageWrapMode. This way, a small image will display inside a bigger node rect and the effect of selecting an alignment is clearly different between different options. By selecting an imageWrapMode such as fill_width, the options in the imageWrapAlignment field left, center, and right will have the same result due to the image already filling all the horizontal space and so would each top_left, top_right and bottom_left, bottom_right respectively.

center

The center behavior aligns the graphic at the center of the rect node.

top

The top behavior aligns the graphic at the center of the rect node and keeps it horizontally centered.

bottom

The top behavior aligns the graphic at the bottom of the rect node and keeps it horizontally centered.

left

The left behavior aligns the graphic at the left of the rect node and keeps it vertically centered.

right

The right behavior aligns the graphic at the right of the rect node and keeps it vertically centered.

top_left

The top_left behavior aligns the graphic at the top-left corner of the rect node.

top_right

The top_right behavior aligns the graphic at the top-right corner of the rect node.

bottom_left

The bottom_left behavior aligns the graphic at the bottom-left corner of the rect node.

bottom_right

The bottom_right behavior aligns the graphic at the bottom-right corner of the rect node.

Image functionalities

RectShape2D can display a single image, a list of images, or an animated gif.

When the images field is provided by a list of images, you can set up an automatic image loop.

Parameter

Description

cycleSpeed

Defines the interval in seconds before to switch the shown image.

cycleEnabled

Plays the photo roll.

Playing an animated gif

For RectShape2D to display an animated GIF, the images field must contain only the .gif file. This feature is supported only on the XR-Win platform and not on the portable platforms.

Parameter

Description

cycleEnabled

Starts the animation. Not supported on portable platforms because these do not support .gif animations.

cycleSpeed

Increases GIF speed. Not supported on portable platforms because these do not support .gif animations.

Shape functionalities

The RectShape2D node can draw a shape that can have a border. The shape can be picked from three predefined shapes: rectangle, rounded_rectangle, and circle, or arbitrarily defined.

Parameter

Description

shapeBorderColor

Defines the color of the border of the shape. Can be transparent.

shapeBorderThickness

Defines the thickness of the border.

shapeColor

Defines the color of the shape. Can be transparent.

shapeCustom

Allows the definition of a custom shape for shapeStyle=custom_shape, by using the following syntax:

{tension=(float)}{points=(float) (float), (float) (float), (float) (float), […]}

where

{points=…} is mandatory and shall contain a list of tuples, separated by ‘commas’, representing the points of the contour of the shape; x,y coordinates are expressed in unitary values where 0 represents 0% of the x/y axis and 1 represents 100% of the x,y axis

{tension=…} is optional (default=0) and shall contain a float number representing the tension to apply to the edges of the shape, values >0 will make the shape convex while values <0 will make the shape concave, values in the range [-1,1] are recommended, but numbers outside that range work as well

Example:

{tension=0.1}{points=0.5 0.1,0.9 0.9,0.1 0.9}

This draws a triangle with vertexes in (x:0.5, y:0.1), (x:0.9, y:0.9) and (x:0.1, y:0.9) with slightly convex edges (according to the 0.1 tension)

This example is the default value for the shapeCustom field.

shapeRoundRectCorner

Defines the corners radius, in pixels, of the rounded_rectangle shape.

shapeStyle

Defines the style of the shape. The following styles are supported: rectangle, rounded_rectangle,circle, custom_shape.

isOverGraphics

RectShape2D provides the isOverGraphics field that gives control of the over state of the pointer with a pixel-perfect check. This field is true if the pixel of the RectShape2D graphic underlying the pointer position is colored with an alpha > 0, false otherwise.

renderToTexture2D

RectShape2D supports the rendering to a Texture2D.

Code example

This is a code example for the RectShape2D node. It creates a node with an image overlayed to a rounded_rectangle shape.

<RectShape2D name="RectShape2D_ImgAndShape"

templateInfo="RectShape2D|RectShape2D_ImgAndShape"

position="100 100"

size="600 400"

images="Sample_image.png"

imageWrapMode="original_size"

imageWrapAlignment="center"

shapeColor="0.329411774873734 0.552941203117371 0.831372559070587 1"

shapeBorderThicknes="6"

shapeBorderColor="0.752941191196442 0.313725501298904 0.301960796117783 1"

shapeRoundRectCorner="50" />

Image color filter modes

The following options define the strategy to use when applying a color filter to an image:

  • none—The selected color is not applied to the images.

  • screen—The selected color is added to the image. This makes the image brighter and has more effect on dark colors. Black color is colored, light colors will tend to white, and white color stays white (since it is already the lightest color possible). This mode is suited to color black or dark glyphs by a selected color.

  • multiply—The image colors are multiplied by the selected color. This makes the images darker and has more effect on light colors. White color is colored, dark colors will tend to black, and black color stays black (since it is already the darkest color possible). This mode is suited to color white or light glyphs by a selected color.

  • overlay—Applies both screen and multiply strategies to the image by the selected color. This keeps the image brightness almost the same, has a balanced influence on light and dark colors, and allows to color both black and white.

  • invert—Inverts the color of the displayed image. The selected color is not used in this mode.

RectShape2D fields

These are the fields for RectShape2D node. Only the node-specific fields are indicated, fields obtained by inheritance are not.

Field inheritance: NodeBase > RectBase2D > RectShape2D

Fields

Type

Use

Default value

Description

cycleEnabled

sbool

Optional

false

Enables image show reel or GIF animation.

cycleSpeed

sfloat

Optional

1

Speed, expressed in images per second, for image switch during show reel or GIF animation multiplier.

images

mstring

Optional

A comma-separated list of image files that can contain one or more images, an animated gif, or a reference to a node that supports image generation. When using a node reference, the list must contain the reference only with the syntax node:nodeName. When the list is empty, the Rect2D is filled with color.

imageColorFilter

svec4

Optional

0, 175, 239

A solid color that is blended on the displayed imageDown, supports alpha channel.

For more information about different blend strategies, see Image color filter modes.

imageColorFilterMode

senum

Optional

none

Defines the strategy used to blend the color selected in imageColorFilter on the displayed imageDown.

The following options are available: none, screen, multiply, color, invert.

See Image color filter modes section for details.

imageIndex

sint

Optional

0

The currently displayed imageIndex. Used to change the display content or can be read in case of gallery show reel.

imageWrapAlignment

senum

Optional

center

Defines the alignment of the displayed image relative to the node rect. When the image aspect ratio and the node aspect ratio do not match, the following styles are supported: center, left, top, right, bottom, top_left, top_right, bottom_left, bottom_right.

Used only when the images field is set.

imageWrapMode

senum

Optional

fit

Defines the wrap mode of the image in the node rect. The following styles are supported: fit, fill, fill_width, fill_height, original_size, stretch.

Any value except for stretch will make the displayed image keep its original aspect ratio relatively to the grid or the screen— depending on the parameter imageWrapKeepProportions.

isOverGraphics

sbool

Readonly

false

Reveals the over state of the pointer with a pixel-perfect check. This field is true if the pixel of the RectShape2D graphics underlying the pointer position is colored with an alpha>0, false otherwise.

shapeBorderColor

svec4

Optional,

255, 0, 0, 255

Defines the color of the border of the shape. Can be transparent. Used only when the shapeStyle field is different from none.

shapeBorderThickness

sfloat

Optional,

2

Defines the thickness of the border. Used only when the shapeStyle field is different from none.

shapeColor

svec4

Optional,

0, 112, 193, 255

Defines the color of the shape. Can be transparent. Used only when the shapeStyle field is different from none.

shapeCustom

senum

Optional

{tension=0.1}
{points=0.5 0.1,0.9 0.9,0.1 0.9}

 

Allows the definition of a custom shape, by using the following syntax:
{tension=(float)}{points=(float) (float), (float) (float), (float) (float), […]}

where

{points=…} is mandatory and shall contain a list of tuples, separated by ‘commas’, representing the points of the contour of the shape; x,y coordinates are expressed in unitary values where 0 represents 0% of the x/y axis and 1 represents 100% of the x/y axis

{tension=…} is optional (default=0) and shall contain a float number representing the tension to apply to the edges of the shape, values >0 will make the shape convex while values <0 will make the shape concave, values in the range [-1,1] are recommended, but values outside that range work as well.

Used only when the shapeStyle field is different from none.

Example

This example is the default value for the shapeCustom field

{tension=0.1}{points=0.5 0.1,0.9 0.9,0.1 0.9}

This draws a triangle with vertexes in (x:0.5, y:0.1), (x:0.9, y:0.9) and (x:0.1, y:0.9) with slightly convex edges (according to the 0.1 tension).

shapeRoundRectCorner

sfloat

Optional,

20

Defines the corners radius, in pixels, of the rounded_rectangle shape. Used only when the shapeStyle field is rounded_rectangle.

shapeStyle

senum

Mandatory (can be "none")

none

Defines the style of the shape. The following styles are supported: rectangle, rounded_rectangle,circle, custom_shape, none.

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in