Add and polish up documentation for Image methods

Written new documentation for undocumented methods. The already
documented methods seemed to follow a very old style and changed them to
fit the new guidelines for documentation.

Signed-off-by: Jakob Sinclair <sinclair.jakob@mailbox.org>
This commit is contained in:
Jakob Sinclair 2017-10-25 11:08:55 +02:00
parent 2987e6ce4f
commit 3d810a207c

View file

@ -4,7 +4,7 @@
Image datatype. Image datatype.
</brief_description> </brief_description>
<description> <description>
Native image datatype. Contains image data, which can be converted to a texture, and several functions to interact with it. Native image datatype. Contains image data, which can be converted to a [Texture], and several functions to interact with it. The maximum width and height for an [code]Image[/code] is 16384 pixels.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -21,7 +21,7 @@
<argument index="2" name="dst" type="Vector2"> <argument index="2" name="dst" type="Vector2">
</argument> </argument>
<description> <description>
Alpha-blends a "src_rect" [Rect2] from "src" [code]Image[/code] to this [code]Image[/code] on coordinates "dest". Alpha-blends [code]src_rect[/code] from [code]src[/code] image to this image at coordinates [code]dest[/code].
</description> </description>
</method> </method>
<method name="blend_rect_mask"> <method name="blend_rect_mask">
@ -36,7 +36,7 @@
<argument index="3" name="dst" type="Vector2"> <argument index="3" name="dst" type="Vector2">
</argument> </argument>
<description> <description>
Alpha-blends a "src_rect" [Rect2] from "src" [code]Image[/code] to this [code]Image[/code] using a "mask" [code]Image[/code] on coordinates "dest". Alpha channels are required for both "src" and "mask", dest pixels and src pixels will blend if the corresponding mask pixel's alpha value is not 0. "src" [code]Image[/code] and "mask" [code]Image[/code] *must* have the same size (width and height) but they can have different formats Alpha-blends [code]src_rect[/code] from [code]src[/code] image to this image using [code]mask[/code] image at coordinates [code]dst[/code]. Alpha channels are required for both [code]src[/code] and [code]mask[/code]. [code]dst[/code] pixels and [code]src[/code] pixels will blend if the corresponding mask pixel's alpha value is not 0. [code]src[/code] image and [code]mask[/code] image [b]must[/b] have the same size (width and height) but they can have different formats.
</description> </description>
</method> </method>
<method name="blit_rect"> <method name="blit_rect">
@ -49,7 +49,7 @@
<argument index="2" name="dst" type="Vector2"> <argument index="2" name="dst" type="Vector2">
</argument> </argument>
<description> <description>
Copy a "src_rect" [Rect2] from "src" [code]Image[/code] to this [code]Image[/code] on coordinates "dest". Copies [code]src_rect[/code] from [code]src[/code] image to this image at coordinates [code]dst[/code].
</description> </description>
</method> </method>
<method name="blit_rect_mask"> <method name="blit_rect_mask">
@ -64,13 +64,14 @@
<argument index="3" name="dst" type="Vector2"> <argument index="3" name="dst" type="Vector2">
</argument> </argument>
<description> <description>
Blits a "src_rect" [Rect2] from "src" [code]Image[/code] to this [code]Image[/code] using a "mask" [code]Image[/code] on coordinates "dest". Alpha channel is required for "mask", will copy src pixel onto dest if the corresponding mask pixel's alpha value is not 0. "src" [code]Image[/code] and "mask" [code]Image[/code] *must* have the same size (width and height) but they can have different formats Blits [code]src_rect[/code] area from [code]src[/code] image to this image at the coordinates given by [code]dst[/code]. [code]src[/code] pixel is copied onto [code]dst[/code] if the corresponding [code]mask[/code] pixel's alpha value is not 0. [code]src[/code] image and [code]mask[/code] image [b]must[/b] have the same size (width and height) but they can have different formats.
</description> </description>
</method> </method>
<method name="clear_mipmaps"> <method name="clear_mipmaps">
<return type="void"> <return type="void">
</return> </return>
<description> <description>
Removes the image's mipmaps.
</description> </description>
</method> </method>
<method name="compress"> <method name="compress">
@ -83,6 +84,7 @@
<argument index="2" name="lossy_quality" type="float"> <argument index="2" name="lossy_quality" type="float">
</argument> </argument>
<description> <description>
Compresses the image to use less memory. Can not directly access pixel data while the image is compressed. Returns error if the chosen compression mode is not available. See [code]COMPRESS_*[/code] constants.
</description> </description>
</method> </method>
<method name="convert"> <method name="convert">
@ -91,6 +93,7 @@
<argument index="0" name="format" type="int" enum="Image.Format"> <argument index="0" name="format" type="int" enum="Image.Format">
</argument> </argument>
<description> <description>
Converts the image's format. See [code]FORMAT_*[/code] constants.
</description> </description>
</method> </method>
<method name="copy_from"> <method name="copy_from">
@ -99,6 +102,7 @@
<argument index="0" name="src" type="Image"> <argument index="0" name="src" type="Image">
</argument> </argument>
<description> <description>
Copies [code]src[/code] image to this image.
</description> </description>
</method> </method>
<method name="create"> <method name="create">
@ -113,7 +117,7 @@
<argument index="3" name="format" type="int" enum="Image.Format"> <argument index="3" name="format" type="int" enum="Image.Format">
</argument> </argument>
<description> <description>
Create an empty image of a specific size and format. Creates an empty image of given size and format. See [code]FORMAT_*[/code] constants. If [code]use_mipmaps[/code] is true then generate mipmaps for this image. See the [code]generate_mipmaps[/code] method.
</description> </description>
</method> </method>
<method name="create_from_data"> <method name="create_from_data">
@ -130,6 +134,7 @@
<argument index="4" name="data" type="PoolByteArray"> <argument index="4" name="data" type="PoolByteArray">
</argument> </argument>
<description> <description>
Creates a new image of given size and format. See [code]FORMAT_*[/code] constants. Fills the image with the given raw data. If [code]use_mipmaps[/code] is true then generate mipmaps for this image. See the [code]generate_mipmaps[/code] method.
</description> </description>
</method> </method>
<method name="crop"> <method name="crop">
@ -140,24 +145,28 @@
<argument index="1" name="height" type="int"> <argument index="1" name="height" type="int">
</argument> </argument>
<description> <description>
Crops the image to the given [code]width[/code] and [code]height[/code]. If the specified size is larger than the current size, the extra area is filled with black pixels.
</description> </description>
</method> </method>
<method name="decompress"> <method name="decompress">
<return type="int" enum="Error"> <return type="int" enum="Error">
</return> </return>
<description> <description>
Decompresses the image if it is compressed. Returns an error if decompress function is not available.
</description> </description>
</method> </method>
<method name="detect_alpha" qualifiers="const"> <method name="detect_alpha" qualifiers="const">
<return type="int" enum="Image.AlphaMode"> <return type="int" enum="Image.AlphaMode">
</return> </return>
<description> <description>
Returns ALPHA_BLEND if the image has data for alpha values. Returns ALPHA_BIT if all the alpha values are below a certain threshold or the maximum value. Returns ALPHA_NONE if no data for alpha values is found.
</description> </description>
</method> </method>
<method name="expand_x2_hq2x"> <method name="expand_x2_hq2x">
<return type="void"> <return type="void">
</return> </return>
<description> <description>
Stretches the image and enlarges it by a factor of 2. No interpolation is done.
</description> </description>
</method> </method>
<method name="fill"> <method name="fill">
@ -166,52 +175,56 @@
<argument index="0" name="color" type="Color"> <argument index="0" name="color" type="Color">
</argument> </argument>
<description> <description>
Fills an [code]Image[/code] with a specified [Color] Fills the image with a given [Color].
</description> </description>
</method> </method>
<method name="fix_alpha_edges"> <method name="fix_alpha_edges">
<return type="void"> <return type="void">
</return> </return>
<description> <description>
Blends low-alpha pixels with nearby pixels.
</description> </description>
</method> </method>
<method name="flip_x"> <method name="flip_x">
<return type="void"> <return type="void">
</return> </return>
<description> <description>
Flips the image horizontally.
</description> </description>
</method> </method>
<method name="flip_y"> <method name="flip_y">
<return type="void"> <return type="void">
</return> </return>
<description> <description>
Flips the image vertically.
</description> </description>
</method> </method>
<method name="generate_mipmaps"> <method name="generate_mipmaps">
<return type="int" enum="Error"> <return type="int" enum="Error">
</return> </return>
<description> <description>
Generates mipmaps for the image. Mipmaps are pre-calculated and lower resolution copies of the image. Mipmaps are automatically used if the image needs to be scaled down when rendered. This improves image quality and the performance of the rendering. Returns an error if the image is compressed, in a custom format or if the image's width/height is 0.
</description> </description>
</method> </method>
<method name="get_data" qualifiers="const"> <method name="get_data" qualifiers="const">
<return type="PoolByteArray"> <return type="PoolByteArray">
</return> </return>
<description> <description>
Return the raw data of the [code]Image[/code]. Returns the image's raw data.
</description> </description>
</method> </method>
<method name="get_format" qualifiers="const"> <method name="get_format" qualifiers="const">
<return type="int" enum="Image.Format"> <return type="int" enum="Image.Format">
</return> </return>
<description> <description>
Return the format of the [code]Image[/code], one of [code]Image[/code].FORMAT_*. Returns the image's raw data.
</description> </description>
</method> </method>
<method name="get_height" qualifiers="const"> <method name="get_height" qualifiers="const">
<return type="int"> <return type="int">
</return> </return>
<description> <description>
Return the height of the [code]Image[/code]. Returns the image's height.
</description> </description>
</method> </method>
<method name="get_mipmap_offset" qualifiers="const"> <method name="get_mipmap_offset" qualifiers="const">
@ -220,6 +233,7 @@
<argument index="0" name="mipmap" type="int"> <argument index="0" name="mipmap" type="int">
</argument> </argument>
<description> <description>
Returns the offset where the image's mipmap with index [code]mipmap[/code] is stored in the [code]data[/code] dictionary.
</description> </description>
</method> </method>
<method name="get_pixel" qualifiers="const"> <method name="get_pixel" qualifiers="const">
@ -230,6 +244,7 @@
<argument index="1" name="y" type="int"> <argument index="1" name="y" type="int">
</argument> </argument>
<description> <description>
Returns the color of the pixel at [code](x, y)[/code] if the image is locked. If the image is unlocked it always returns a [Color] with the value [code](0, 0, 0, 1.0)[/code].
</description> </description>
</method> </method>
<method name="get_rect" qualifiers="const"> <method name="get_rect" qualifiers="const">
@ -238,51 +253,56 @@
<argument index="0" name="rect" type="Rect2"> <argument index="0" name="rect" type="Rect2">
</argument> </argument>
<description> <description>
Return a new [code]Image[/code] that is a copy of "area" in this [code]Image[/code]. Returns a new image that is a copy of the image's area specified with [code]rect[/code].
</description> </description>
</method> </method>
<method name="get_size" qualifiers="const"> <method name="get_size" qualifiers="const">
<return type="Vector2"> <return type="Vector2">
</return> </return>
<description> <description>
Returns the image's size (width and height).
</description> </description>
</method> </method>
<method name="get_used_rect" qualifiers="const"> <method name="get_used_rect" qualifiers="const">
<return type="Rect2"> <return type="Rect2">
</return> </return>
<description> <description>
Return the area of this [code]Image[/code] that is used/visibly colored/opaque. Returns a [Rect2] enclosing the visible portion of the image.
</description> </description>
</method> </method>
<method name="get_width" qualifiers="const"> <method name="get_width" qualifiers="const">
<return type="int"> <return type="int">
</return> </return>
<description> <description>
Return the width of the [code]Image[/code]. Returns the image's width.
</description> </description>
</method> </method>
<method name="has_mipmaps" qualifiers="const"> <method name="has_mipmaps" qualifiers="const">
<return type="bool"> <return type="bool">
</return> </return>
<description> <description>
Returns [code]true[/code] if the image has generated mipmaps.
</description> </description>
</method> </method>
<method name="is_compressed" qualifiers="const"> <method name="is_compressed" qualifiers="const">
<return type="bool"> <return type="bool">
</return> </return>
<description> <description>
Returns [code]true[/code] if the image is compressed.
</description> </description>
</method> </method>
<method name="is_empty" qualifiers="const"> <method name="is_empty" qualifiers="const">
<return type="bool"> <return type="bool">
</return> </return>
<description> <description>
Returns [code]true[/code] if the image has no data.
</description> </description>
</method> </method>
<method name="is_invisible" qualifiers="const"> <method name="is_invisible" qualifiers="const">
<return type="bool"> <return type="bool">
</return> </return>
<description> <description>
Returns [code]true[/code] if all the image's pixels have an alpha value of 0. Returns [code]false[/code] if any pixel has an alpha value higher than 0.
</description> </description>
</method> </method>
<method name="load"> <method name="load">
@ -291,25 +311,28 @@
<argument index="0" name="path" type="String"> <argument index="0" name="path" type="String">
</argument> </argument>
<description> <description>
Load an [code]Image[/code]. Loads an image from file [code]path[/code].
</description> </description>
</method> </method>
<method name="lock"> <method name="lock">
<return type="void"> <return type="void">
</return> </return>
<description> <description>
Locks the data and prevents changes.
</description> </description>
</method> </method>
<method name="normalmap_to_xy"> <method name="normalmap_to_xy">
<return type="void"> <return type="void">
</return> </return>
<description> <description>
Converts the image's data to represent coordinates on a 3D plane. This is used when the image represents a normalmap. A normalmap can add lots of detail to a 3D surface without increasing the polygon count.
</description> </description>
</method> </method>
<method name="premultiply_alpha"> <method name="premultiply_alpha">
<return type="void"> <return type="void">
</return> </return>
<description> <description>
Multiplies color values with alpha values. Resulting color values for a pixel are [code](color * alpha)/256[/code].
</description> </description>
</method> </method>
<method name="resize"> <method name="resize">
@ -322,6 +345,7 @@
<argument index="2" name="interpolation" type="int" enum="Image.Interpolation" default="1"> <argument index="2" name="interpolation" type="int" enum="Image.Interpolation" default="1">
</argument> </argument>
<description> <description>
Resizes the image to the given [code]width[/code] and [code]height[/code]. New pixels are calculated using [code]interpolation[/code]. See [code]interpolation[/code] constants.
</description> </description>
</method> </method>
<method name="resize_to_po2"> <method name="resize_to_po2">
@ -330,6 +354,7 @@
<argument index="0" name="square" type="bool" default="false"> <argument index="0" name="square" type="bool" default="false">
</argument> </argument>
<description> <description>
Resizes the image to the nearest power of 2 for the width and height. If [code]square[/code] is [code]true[/code] then set width and height to be the same.
</description> </description>
</method> </method>
<method name="save_png" qualifiers="const"> <method name="save_png" qualifiers="const">
@ -338,7 +363,7 @@
<argument index="0" name="path" type="String"> <argument index="0" name="path" type="String">
</argument> </argument>
<description> <description>
Save this [code]Image[/code] as a png. Saves the image as a PNG file to [code]path[/code].
</description> </description>
</method> </method>
<method name="set_pixel"> <method name="set_pixel">
@ -351,29 +376,43 @@
<argument index="2" name="color" type="Color"> <argument index="2" name="color" type="Color">
</argument> </argument>
<description> <description>
Sets the [Color] of the pixel at [code](x, y)[/code] if the image is unlocked. Example:
[code]
var img = Image.new()
img.lock()
img.set_pixel(x, y, color) # Does not have an effect
img.unlock()
img.set_pixel(x, y, color) # Works
[/code].
</description> </description>
</method> </method>
<method name="shrink_x2"> <method name="shrink_x2">
<return type="void"> <return type="void">
</return> </return>
<description> <description>
Shrinks the image by a factor of 2.
</description> </description>
</method> </method>
<method name="srgb_to_linear"> <method name="srgb_to_linear">
<return type="void"> <return type="void">
</return> </return>
<description> <description>
Converts the raw data from the sRGB colorspace to a linear scale.
</description> </description>
</method> </method>
<method name="unlock"> <method name="unlock">
<return type="void"> <return type="void">
</return> </return>
<description> <description>
Unlocks the data for writing access.
</description> </description>
</method> </method>
</methods> </methods>
<members> <members>
<member name="data" type="Dictionary" setter="_set_data" getter="_get_data"> <member name="data" type="Dictionary">
<description>
Holds all of the image's color data in a given format. See [code]FORMAT_*[/code] constants.
</description>
</member> </member>
</members> </members>
<constants> <constants>