Difference between revisions of "Img add"
Jump to navigation
Jump to search
(rotate instead of img_rotate) |
(→Style) |
||
Line 46: | Line 46: | ||
|- | |- | ||
| '''valign''' || ''String'' || The vertical alignment of the image within the image box. Can be "top", "center" or "bottom". | | '''valign''' || ''String'' || The vertical alignment of the image within the image box. Can be "top", "center" or "bottom". | ||
|- | |||
| '''background_color''' || ''String'' || Show a background color. Available from AM/AP 3.6. | |||
|- | |- | ||
| '''visible''' || ''Boolean'' || Should the image be visible. Available from AM/AP 3.5. | | '''visible''' || ''Boolean'' || Should the image be visible. Available from AM/AP 3.5. | ||
|- | |- | ||
| ''' | | '''opacity''' || ''Number'' || Opacity level of the node, between 0.0 (not visible) to 1.0 (fully visible) || '''AM 4.2/AP 4.2''' and up | ||
|- | |||
| '''angle_z''' || ''Number'' || Rotational value in Z axis, in degrees. || '''AM 4.2/AP 4.2''' and up | |||
|- | |||
| '''viewport_rect''' || ''N,N,N,N'' || Set rectangler viewport, node will not draw outside of this rectangle || '''AM 4.2/AP 4.2''' and up | |||
|- | |||
| '''opacity_animation_type''' || ''String'' || Set opacity animation, can be 'OFF', 'LINEAR' or 'LOG'. || '''AM 4.2/AP 4.2''' and up | |||
|- | |||
| '''opacity_animation_speed''' || ''Number'' || Set opacity animation speed, higher value will result in faster animation. || '''AM 4.2/AP 4.2''' and up | |||
|- | |||
| '''move_animation_type''' || ''String'' || Set move animation, can be 'OFF', 'LINEAR' or 'LOG'. || '''AM 4.2/AP 4.2''' and up | |||
|- | |||
| '''move_animation_speed''' || ''Number'' || Set move animation speed, higher value will result in faster animation. || '''AM 4.2/AP 4.2''' and up | |||
|- | |||
| '''rotate_animation_type''' || ''String'' || Set rotation animation, can be 'OFF', 'LINEAR' or 'LOG'. || '''AM 4.2/AP 4.2''' and up | |||
|- | |||
| '''rotate_animation_speed''' || ''Number'' || Set rotation animation speed, higher value will result in faster animation. || '''AM 4.2/AP 4.2''' and up | |||
|- | |||
| '''rotate_animation_direction''' || ''String'' || Set rotation animation direction. Can be 'DIRECT', 'CW', 'CCW', 'FASTEST' or 'SLOWEST'. || '''AM 4.2/AP 4.2''' and up | |||
|} | |} | ||
Revision as of 20:16, 15 March 2023
Description
image_id = img_add(filename, x, y, width, height) image_id = img_add(filename, x, y, width, height, style)
img_add is used to show an image on the specified location. The image is also stored in memory for further references.
Return value
Argument | Type | Description |
---|---|---|
image_id | ID | This value can be used for further reference. Functions such as move and rotate can use this image_id. Its good practice to store this image_id in your logic code. |
Arguments
# | Argument | 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. From AM 2.1.1, 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. From AM 2.1.1, nil will make the image the same height as the PNG image. |
6 | style | String | (Optional) The style to use. See the paragraph below for available style arguments. |
Style
Argument | Type | Description | |
---|---|---|---|
scale_mode | String | Describe how the image should be scaled inside the box. Can be "stretch", "aspect_fit" or "aspect_fill". Defaults to "stretch". | |
halign | String | The horizontal alignment of the image within the image box. Can be "left", "center" or "right". | |
valign | String | The vertical alignment of the image within the image box. Can be "top", "center" or "bottom". | |
background_color | String | Show a background color. Available from AM/AP 3.6. | |
visible | Boolean | Should the image be visible. Available from AM/AP 3.5. | |
opacity | Number | Opacity level of the node, between 0.0 (not visible) to 1.0 (fully visible) | AM 4.2/AP 4.2 and up |
angle_z | Number | Rotational value in Z axis, in degrees. | AM 4.2/AP 4.2 and up |
viewport_rect | N,N,N,N | Set rectangler viewport, node will not draw outside of this rectangle | AM 4.2/AP 4.2 and up |
opacity_animation_type | String | Set opacity animation, can be 'OFF', 'LINEAR' or 'LOG'. | AM 4.2/AP 4.2 and up |
opacity_animation_speed | Number | Set opacity animation speed, higher value will result in faster animation. | AM 4.2/AP 4.2 and up |
move_animation_type | String | Set move animation, can be 'OFF', 'LINEAR' or 'LOG'. | AM 4.2/AP 4.2 and up |
move_animation_speed | Number | Set move animation speed, higher value will result in faster animation. | AM 4.2/AP 4.2 and up |
rotate_animation_type | String | Set rotation animation, can be 'OFF', 'LINEAR' or 'LOG'. | AM 4.2/AP 4.2 and up |
rotate_animation_speed | Number | Set rotation animation speed, higher value will result in faster animation. | AM 4.2/AP 4.2 and up |
rotate_animation_direction | String | Set rotation animation direction. Can be 'DIRECT', 'CW', 'CCW', 'FASTEST' or 'SLOWEST'. | AM 4.2/AP 4.2 and up |
Example
-- Load and display text and images
myimage1 = img_add("myimage1.png", 0, 0, 200, 200)
myimage2 = img_add("myimage2.png", 200, 0, 200, 200)
-- Rotate image1
rotate(myimage1, 90)