img_add(filename, x, y, width, height)
img_add(filename, x, y, width, height, style)
Places a PNG at x, y in instrument pixels. A missing width or height uses the file size.
Parameters
#
Name
Type
Description
1
filename
String
This is the filename of the image you would like to show. Note that this is both filename and extension. Only the PNG file format is supported.
2
x
Number
This is the most left point of the canvas where your image should be shown.
3
y
Number
This is the most top point of the canvas where your image should be shown.
4
width
Number
The image width on the canvas. Note that the software won't preserve the aspect ratio. Scaling will be done, both stretching and cropping of the image. nil will make the image the same width as the PNG image.
5
height
Number
The image height on the canvas. Note that the software won't preserve the aspect ratio. Scaling will be done, both stretching and cropping of the image. nil will make the image the same height as the PNG image.
The style string is optional. Separate arguments with a semicolon.
Argument
Type
Description
scale_mode
String
How the image fills the box: stretch, aspect_fit, or aspect_fill. Default is stretch.
halign
String
Horizontal alignment in the box: left, center, or right.
valign
String
Vertical alignment in the box: top, center, or bottom.
background_color
String
A color drawn behind the image.
visible
Boolean
false hides the image.
opacity
Number
0.0 invisible to 1.0 fully visible.
angle_z
Number
Rotation in degrees, in instrument space.
viewport_rect
x y width height
Four numbers, in instrument pixels: left, top, width, height. The image is clipped to that rectangle. viewport_rect: 40 20 120 80 shows only the part of the image inside a box that starts 40 px from the left and 20 px from the top, and is 120 px wide and 80 px tall.
opacity_animation_type
String
OFF, LINEAR, or LOG.
opacity_animation_speed
Number
1.0 fastest, 0.0 slowest.
move_animation_type
String
OFF, LINEAR, or LOG.
move_animation_speed
Number
1.0 fastest, 0.0 slowest.
rotate_animation_type
String
OFF, LINEAR, or LOG.
rotate_animation_speed
Number
1.0 fastest, 0.0 slowest.
rotate_animation_direction
String
DIRECT, CW, CCW, FASTEST, or SLOWEST.
Example
-- Altimeter face, then the needle on top of it
face = img_add("alt_face.png", 0, 0, 240, 240)
needle = img_add("alt_needle.png", 100, 20, 40, 200, "opacity: 1; viewport_rect: 80 20 80 200")
-- Park the needle at 90 degrees while we wait for the simrotate(needle, 90)
Example: animated needle
-- The needle eases to the new angle instead of jumping
needle = img_add("alt_needle.png", 100, 20, 40, 200, "rotate_animation_type: LOG; rotate_animation_speed: 0.4")
rotate(needle, 90)
Places a PNG over the whole instrument. An optional style string can set opacity or visibility.
Parameters
#
Name
Type
Description
1
filename
String
This is the filename of the image you would like to show. Note that this is both filename and extension. Only the PNG file format is supported.
2
style
String
(Optional) The style to use. See img_add for available style arguments.
Clip example
-- Face is 200 by 200. Only the middle 80 by 80 is drawn.
face = img_add("face.png", 0, 0, 200, 200, "viewport_rect: 60 60 80 80")
Example
-- Bezel covers the whole instrument. The glass sits on top, with its alpha.
bezel = img_add_fullscreen("bezel.png")
glass = img_add_fullscreen("glass.png")
Photo slot: shots/img_add_fullscreen.png
remove
Simulation Instrument Studio 1
Overloads
remove(node_id)
Removes a node. It is no longer drawn.
Parameters
#
Name
Type
Description
1
node_id
ID
Node identifier. This number can be obtained by calling functions like img_add, txt_add or canvas_add.
Example
-- A flag we only want while the sim is disconnected
flag = img_add("off_flag.png", 70, 90, 100, 40)
-- Sim answered. Take the flag down. Do not touch flag after this.remove(flag)
Photo slot: shots/remove.png
running_img_add_cir
Simulation Instrument Studio 1
Overloads
running_img_add_cir(filename, x, y, nr_visible_items, item_width, item_height, radius)
running_img_add_cir(filename, x, y, nr_visible_items, item_width, item_height, radius_x, radius_y)
One image, repeated around a circle. The caret turns which copy is in front.
Parameters
#
Name
Type
Description
1
filename
String
This is the filename of the image you would like to show. Note that this is both filename and extension. Its good practice to always the PNG format for images. JPG and BMP are also supported, but not recommended.
2
x
Number
This is the most left point of the canvas where your running image should be shown.
3
y
Number
This is the most top point of the canvas where your running image should be shown.
4
nr_visible_items
Number
Number of image items that should be shown.
5
item_width
Number
The width of every image object in pixels.
6
item_height
Number
The height of every image object in pixels.
7
radius_x
Number
The horizontal radius from the middle of the circle in pixels.
8
radius_y
Number
(Optional) The vertical radius from the middle of the circle in pixels. When not present, radius_x is used.
Example
-- Twelve heading ticks, one PNG, on a circle of radius 90
ticks = running_img_add_cir("tick.png", 120, 120, 12, 8, 18, 90)
-- Bring the north tick to the lubber linerunning_img_move_carot(ticks, 0)
Photo slot: shots/running_img_add_cir.png
running_img_add_hor
Simulation Instrument Studio 1
Overloads
running_img_add_hor(filename, x, y, nr_visible_items, item_width, item_height)
One image, repeated in a row. The caret slides which copy is in front.
Parameters
#
Name
Type
Description
1
filename
String
This is the filename of the image you would like to show. Note that this is both filename and extension. Its good practice to always the PNG format for images. JPG and BMP are also supported, but not recommended.
2
x
Number
This is the most left point of the canvas where your running image should be shown.
3
y
Number
This is the most top point of the canvas where your running image should be shown.
running_img_add_ver(filename, x, y, nr_visible_items, item_width, item_height)
One image, repeated in a column. The caret slides which copy is in front.
Parameters
#
Name
Type
Description
1
filename
String
This is the filename of the image you would like to show. Note that this is both filename and extension. Its good practice to always the PNG format for images. JPG and BMP are also supported, but not recommended.
2
x
Number
This is the most left point of the canvas where your running image should be shown.
3
y
Number
This is the most top point of the canvas where your running image should be shown.