Simulation Instruments

Home›All functions›Image

Image

Simulation Instrument Studio 1

img_add

Simulation Instrument Studio 1

Overloads

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

#NameTypeDescription
1filenameStringThis 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.
2xNumberThis is the most left point of the canvas where your image should be shown.
3yNumberThis is the most top point of the canvas where your image should be shown.
4widthNumberThe 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.
5heightNumberThe 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.
6styleString(Optional) The style to use. See the style arguments below.

Style

The style string is optional. Separate arguments with a semicolon.

ArgumentTypeDescription
scale_modeStringHow the image fills the box: stretch, aspect_fit, or aspect_fill. Default is stretch.
halignStringHorizontal alignment in the box: left, center, or right.
valignStringVertical alignment in the box: top, center, or bottom.
background_colorStringA color drawn behind the image.
visibleBooleanfalse hides the image.
opacityNumber0.0 invisible to 1.0 fully visible.
angle_zNumberRotation in degrees, in instrument space.
viewport_rectx y width heightFour 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_typeStringOFF, LINEAR, or LOG.
opacity_animation_speedNumber1.0 fastest, 0.0 slowest.
move_animation_typeStringOFF, LINEAR, or LOG.
move_animation_speedNumber1.0 fastest, 0.0 slowest.
rotate_animation_typeStringOFF, LINEAR, or LOG.
rotate_animation_speedNumber1.0 fastest, 0.0 slowest.
rotate_animation_directionStringDIRECT, 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 sim
rotate(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)
Photo slot: shots/img_add.png

img_add_fullscreen

Simulation Instrument Studio 1

Overloads

img_add_fullscreen(filename)
img_add_fullscreen(filename, style)

Places a PNG over the whole instrument. An optional style string can set opacity or visibility.

Parameters

#NameTypeDescription
1filenameStringThis 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.
2styleString(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

#NameTypeDescription
1node_idIDNode 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

#NameTypeDescription
1filenameStringThis 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.
2xNumberThis is the most left point of the canvas where your running image should be shown.
3yNumberThis is the most top point of the canvas where your running image should be shown.
4nr_visible_itemsNumberNumber of image items that should be shown.
5item_widthNumberThe width of every image object in pixels.
6item_heightNumberThe height of every image object in pixels.
7radius_xNumberThe horizontal radius from the middle of the circle in pixels.
8radius_yNumber(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 line
running_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

#NameTypeDescription
1filenameStringThis 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.
2xNumberThis is the most left point of the canvas where your running image should be shown.
3yNumberThis is the most top point of the canvas where your running image should be shown.
4nr_visible_itemsNumberNumber of image items that should be shown.
5item_widthNumberThe width of every image object in pixels.
6item_heightNumberThe height of every image object in pixels.

Example

-- A row of five fuel-pump lights, same PNG
pumps = running_img_add_hor("pump.png", 10, 40, 5, 36, 36)

-- Light the second pump
running_img_move_carot(pumps, 1)
Photo slot: shots/running_img_add_hor.png

running_img_add_ver

Simulation Instrument Studio 1

Overloads

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

#NameTypeDescription
1filenameStringThis 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.
2xNumberThis is the most left point of the canvas where your running image should be shown.
3yNumberThis is the most top point of the canvas where your running image should be shown.
4nr_visible_itemsNumberNumber of image items that should be shown.
5item_widthNumberThe width of every image object in pixels.
6item_heightNumberThe height of every image object in pixels.

Example

-- A column of four flap notches
flaps = running_img_add_ver("notch.png", 8, 12, 4, 24, 28)

running_img_move_carot(flaps, 2)
Photo slot: shots/running_img_add_ver.png

running_img_move_carot

Simulation Instrument Studio 1

Overloads

running_img_move_carot(running_img_id, position)

Moves the caret of a running image. That copy moves to the front.

Parameters

#NameTypeDescription
1running_img_idNumberThe running image id of which to move the carot
2positionNumberThe position to move the carot to.

Example

ticks = running_img_add_cir("tick.png", 120, 120, 12, 8, 18, 90)

-- Caret 0 is north. Caret 3 is east.
running_img_move_carot(ticks, 3)
Photo slot: shots/running_img_move_carot.png