Create and modify
GPSS-Plus lets you define graphic elements that can be moved, transformed, and updated during the simulation. These objects can be texts, curves, images, arcs, or lines, and they can be grouped to form complete visual units.
Graphics can be moved individually or as a group, and you can modify properties such as:
- Position (
X,Y) - Rotation (
ROTATE) - Size (
RESIZE) - Opacity (
OPACITY) - Text content (
TEXT) - Color and angles, for shapes like
ARCorLINE
The MOVE commands allow:
- Absolute values, like
X:100 - Relative values, reading the current value via
GD$, for example:X:GD$(object,X) + 10
This example shows how an entity, across its steps, updates internal variables (SAVEVALUE) and uses those variables to refresh graphic objects on each advance.
It illustrates the use of graphics of type TEXT, CURVE3, CURVE, ARC, IMAGE, and GROUP, as well as the combined use of relative animations, scaling, and rotation.
About curves and filling
GPSS-Plus supports two curve types:
- CURVE3: three-point curve (simple Bezier), declared with direct coordinates
X1,Y1,X2,Y2,X3,Y3 - CURVE: Catmull-Rom smoothed curve, defined with a list of points
To declare points, there are two equivalent forms:
- Compact syntax:
POINTS:"[x1,y1],[x2,y2],[x3,y3],..." - Direct pair syntax:
X1:1,Y1:2, X2:3,Y2:4, X3:5,Y3:6
Curves, lines, or arcs can be open or closed. To render them as closed shapes with fill, you must set:
CLOSE:1FCOLOR:for the fill color
Example
/*
Create and modify graphics
*/
SYSTEM {TYPE:OPTIONS, SPEED:8, TIME_DECIMALS:1}
;==============================
; DYNAMIC VARIABLES
;==============================
INITIAL GRADO, 0
INITIAL ALTURA, 80
INITIAL ESCALA, 100
INITIAL CRECIENDO, 1
;==============================
; GRAPHIC ELEMENTS
;==============================
GRAPHIC {NAME:txt, TYPE:TEXT, X:300, Y:50,text:"--test--"}
GRAPHIC {NAME:radarGrupo, TYPE:GROUP, X:300, Y:400}
GRAPHIC {
GROUP:radarGrupo,
NAME:radarTexto,
TYPE:TEXT,
TEXT:"GRADO: X$GRADO",
COLOR:#00AAFF,
X:0, Y:-50
}
GRAPHIC {
GROUP:radarGrupo,
NAME:radarImagen,
TYPE:IMAGE,
SRC:"DOOR",
X:100, Y:100,
OPACITY:0.9,
ROTATE:0
}
GRAPHIC {
GROUP:radarGrupo,
NAME:ondaVisual,
TYPE:CURVE,
POINTS:"[0,0],[40,X$ALTURA],[80,0]",
COLOR:red,
WIDTH:2,
OPACITY:0.6
}
GRAPHIC {
NAME:puerta,
TYPE:IMAGE,
SRC:"DOOR",
X:400, Y:100,
OPACITY:0.9,
ROTATE:0
}
GRAPHIC {
NAME:barreraCircular,
TYPE:ARC,
X:100, Y:400,
COLOR:#FFAA00,
RADIUS:60,
START_ANGLE:0,
END_ANGLE:X$GRADO,
OPACITY:1,
CLOSE:0
}
;==============================
; MAIN ENTITY
;==============================
GENERATE 5, 0 {NAME:GEN1, X:50, Y:200}
;move {name:txt,text:"Pos X GD$(barreraCircular,X)"}
; Increase angle (rotation)
SAVEVALUE GRADO, (X$GRADO + 15) % 360
; Raise/lower the wave
IF ((X$GRADO % 180) < 90)
SAVEVALUE ALTURA, X$ALTURA + 4
ELSE
SAVEVALUE ALTURA, X$ALTURA - 4
ENDIF
; Animate size
IF (X$CRECIENDO == 1)
SAVEVALUE ESCALA, X$ESCALA + 5
IF (X$ESCALA >= 140)
SAVEVALUE CRECIENDO, 0
ENDIF
ELSE
SAVEVALUE ESCALA, X$ESCALA - 5
IF (X$ESCALA <= 100)
SAVEVALUE CRECIENDO, 1
ENDIF
ENDIF
ADVANCE 5, 0
;==============================
; VISUAL UPDATES
;==============================
MOVE {NAME:radarTexto, TEXT:"Degree: X$GRADO"}
MOVE {NAME:radarImagen, ROTATE:X$GRADO}
MOVE {NAME:radarImagen, RESIZE:X$ESCALA}
MOVE {NAME:ondaVisual, Y2:X$ALTURA}
MOVE {NAME:radarGrupo, Y:(GD$(radarGrupo,Y)+(RANDOM*10)-5)}
MOVE {NAME:puerta, RESIZE_X:X$ESCALA * 2}
MOVE {NAME:barreraCircular, END_ANGLE:X$GRADO}
TERMINATE 1
START 500