Class TCastleShape

Unit

Declaration

type TCastleShape = class(TCastleUserInterface)

Description

Draw a simple shape (rectangle, circle) with given color and optional outline.

Hierarchy

Overview

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure Render; override;
Public function PropertySections(const PropertyName: String): TPropertySections; override;

Properties

Public property Color: TCastleColor read FColor write SetColor;
Public property OutlineColor: TCastleColor read FOutlineColor write SetOutlineColor; deprecated 'do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages';
Public property OutlineThick: boolean read FOutlineThick write SetOutlineThick default false; deprecated 'do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages';
Public property OutlineWidth: Single read FOutlineWidth write SetOutlineWidth default 1.0; deprecated 'do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages';
Public property Outline: boolean read FOutline write SetOutline default false; deprecated 'leave this always false; do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages';
Public property Filled: boolean read FFilled write SetFilled default true; deprecated 'leave this always true; do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages';
Published property ShapeType: TShapeType read FShapeType write SetShapeType default stRectangle;
Published property ColorPersistent: TCastleColorPersistent read FColorPersistent ;

Description

Methods

Public constructor Create(AOwner: TComponent); override;

This item has no description.

Public destructor Destroy; override;

This item has no description.

Public procedure Render; override;

This item has no description. Showing description inherited from TCastleUserInterface.Render.

Render a control. Called only when Exists and GLInitialized, you can depend on it in the implementation of this method.

Do not explicitly call this method. Instead, render controls by adding them to the TCastleContainer.Controls list, or render them explicitly (for off-screen rendering) by TCastleContainer.RenderControl. This is method should only be overridden in your own code.

Before calling this method we always set some OpenGL state, and you can depend on it (and you can carelessly change it, as it will be reset again before rendering other control).

OpenGL state always set:

  • Viewport is set to include whole container.

  • Depth test is off.

  • (For fixed-function pipeline:) The 2D orthographic projection is always set at the beginning. Useful for 2D controls, 3D controls can just override projection matrix, e.g. use CastleRenderContext.PerspectiveProjection.

  • (For fixed-function pipeline:) The modelview matrix is set to identity. The matrix mode is always modelview.

  • (For fixed-function pipeline:) The raster position is set to (0,0). The (deprecated) WindowPos is also set to (0,0).

  • (For fixed-function pipeline:) Texturing, lighting, fog is off.

Beware that GLSL RenderContext.CurrentProgram has undefined value when this is called. You should always set it, before making direct OpenGL drawing calls (all the engine drawing routines of course do it already, this is only a concern if you make direct OpenGL / OpenGLES calls).

Public function PropertySections(const PropertyName: String): TPropertySections; override;

This item has no description. Showing description inherited from TCastleComponent.PropertySections.

Section where to show property in the editor.

Properties

Public property Color: TCastleColor read FColor write SetColor;

The fill color, used if Filled. By default, opaque white.

Public property OutlineColor: TCastleColor read FOutlineColor write SetOutlineColor; deprecated 'do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages';

Warning: this symbol is deprecated: do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages

The outline color, used if Outline. By default, opaque black.

Public property OutlineThick: boolean read FOutlineThick write SetOutlineThick default false; deprecated 'do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages';

Warning: this symbol is deprecated: do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages

Determines the drawing method of the outline, used if Outline.

False (default)

Draw the outline using lines, and apply OutlineWidth by changing line width.

Disadvantage: outline widths thicker than 1 pixel are not guaranteed to be supported. In particular they will almost never work on mobile (OpenGLES). See the LineWidth comments at DrawPrimitive2D procedure.

Consider using other methods if you need to draw a thick shape outline in a reliable manner. To draw a rectangle with frame, it's usually better to use Draw3x3 call, with a special texture with a frame and insides.

True

Draw the outline by first drawing a larger shape with OutlineColor underneath the smaller shape with Color.

Disadvantages:

  • Cannot work sensibly if Filled is False, so it's disabled then. When Filled is False, it's like OutlineThick was always also False.

  • The alpha blending may not be exactly what you want, since the pixels inside are overdrawn with both OutlineColor and then with Color.

  • May look a little worse in case of small OutlineWidth and non-rectangular shapes.

Advantage: thick OutlineWidth works reliably.

Public property OutlineWidth: Single read FOutlineWidth write SetOutlineWidth default 1.0; deprecated 'do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages';

Warning: this symbol is deprecated: do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages

The outline width, used if Outline. It is affected by UI scaling.

If OutlineThick is False, then outline widths thicker than 1 pixel are not guaranteed to be supported. In particular they will almost never work on mobile (OpenGLES). Change OutlineThick to True to have reliable thick outlines.

Public property Outline: boolean read FOutline write SetOutline default false; deprecated 'leave this always false; do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages';

Warning: this symbol is deprecated: leave this always false; do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages

This item has no description.

Public property Filled: boolean read FFilled write SetFilled default true; deprecated 'leave this always true; do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages';

Warning: this symbol is deprecated: leave this always true; do not rely on outlines implemented in TCastleShape, as both OutlineThick approaches have disadvantages

This item has no description.

Published property ShapeType: TShapeType read FShapeType write SetShapeType default stRectangle;

This item has no description.

Published property ColorPersistent: TCastleColorPersistent read FColorPersistent ;

Color that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write Color directly.

See also
Color
The fill color, used if Filled.

Generated by PasDoc 0.16.0.