Skip to content

Class Shapes

Kristian Virtanen edited this page Oct 28, 2024 · 2 revisions

Description:

The Shapes class provides methods to create and manipulate shapes in the GraphicsWindow, including rectangles, ellipses, triangles, lines, and images. The class also provides functionality for rotating and resizing (zooming) shapes. Error handling is included via the LastError property, which stores the most recent error message if an operation fails.

Properties

Shapes.LastError

  • Description: Stores the last error message, if any operation fails, including a timestamp in yyyy-MM-dd HH:mm:ss format.
  • Example: "2024-10-16 14:30:00: Shape with name Shape1 not found."
  • Differences from orig. SB: New feature (and class) for SBOE.

Methods

Shapes.AddRectangle(width, height)

  • Description: Adds a rectangle to the GraphicsWindow with the specified width and height.
  • Parameters:
    • width: The width of the rectangle.
    • height: The height of the rectangle.
  • Returns: The name of the created rectangle shape, or null if an error occurred.
  • Differences from orig. SB: SBOE returns null in error.

Shapes.AddEllipse(width, height)

  • Description: Adds an ellipse to the GraphicsWindow with the specified width and height.
  • Parameters:
    • width: The width of the ellipse.
    • height: The height of the ellipse.
  • Returns: The name of the created ellipse shape, or null if an error occurred.
  • Differences from orig. SB: SBOE returns null in error.

Shapes.AddTriangle(x1, y1, x2, y2, x3, y3)

  • Description: Adds a triangle to the GraphicsWindow defined by three sets of coordinates.
  • Parameters:
    • x1, y1: Coordinates of the first point.
    • x2, y2: Coordinates of the second point.
    • x3, y3: Coordinates of the third point.
  • Returns: The name of the created triangle shape, or null if an error occurred.
  • Differences from orig. SB: SBOE returns null in error.

Shapes.AddLine(x1, y1, x2, y2)

  • Description: Adds a line to the GraphicsWindow defined by two sets of coordinates.
  • Parameters:
    • x1, y1: Coordinates of the start point.
    • x2, y2: Coordinates of the end point.
  • Returns: The name of the created line shape, or null if an error occurred.
  • Differences from orig. SB: SBOE returns null in error.

Shapes.AddImage(imageName)

  • Description: Adds an image to the GraphicsWindow using the specified image name from the ImageList.
  • Parameters:
    • imageName: The name of the image in the ImageList.
  • Returns: The name of the created image shape, or null if the image is not found or an error occurs.
  • Differences from orig. SB: SBOE returns null in error.

Shapes.Rotate(shapeName, angle)

  • Description: Rotates the specified shape or image by the given angle.
  • Parameters:
    • shapeName: The name of the shape or image to rotate.
    • angle: The angle in degrees to rotate.
  • Returns: true if successful, false if an error occurs (e.g., the shape is not found).
  • Differences from orig. SB: SBOE returns true or false.

Shapes.Zoom(shapeName, scaleX, scaleY)

  • Description: Resizes (zooms) the specified shape by scaling its width and height.
  • Parameters:
    • shapeName: The name of the shape to resize.
    • scaleX: The scale factor for the width.
    • scaleY: The scale factor for the height.
  • Returns: true if successful, false if an error occurs (e.g., the shape is not found).
  • Differences from orig. SB: SBOE returns true or false.

Top

Clone this wiki locally