About the Graphic System

KiriKiri has a graphic display mechanism using layers.
Each layer has functions for transparent overlaying via alpha blending and hierarchical structure management. Additionally, it has a mechanism (focus) for receiving user input so that layers can operate as GUI components (widgets).

Overlaid layers are drawn to the window by a mechanism called a draw device. By default, a device called BasicDrawDevice is used, which simply draws the layer output to the window. The draw device can be freely replaced by manipulating the Window.drawDevice property, allowing users to define their own visual effects (in the form of plugins) according to their needs, but KiriKiri Z only includes the aforementioned BasicDrawDevice.

Readable and Writable Image Formats

The formats that can be read into or written from a layer using Layer.loadImages in the standard state of KiriKiri are as follows.

BMP
Standard Windows bitmap format. 32 bpp BMPs are treated as bitmaps with an alpha channel.
RLE-compressed bitmaps cannot be read.
PNG
Portable Network Graphic format can be read. PNGs with an alpha channel can also be read.
JPEG
JPEG format can be read. Arithmetically compressed or losslessly compressed JPEGs cannot be read, but since these are rarely seen, it should not be an issue.
TLG5
KiriKiri's original lossless compression format. The extension is .tlg. Images with an alpha channel can also be read. While the compression ratio is not very high, it features high-speed decompression. This format cannot be used for mask images (_m) or province images (_p). It can only handle full-color images without an alpha channel, or full-color images with an alpha channel.
TLG6
KiriKiri's original lossless compression format. The extension is .tlg, same as TLG5. TLG6 features a high compression ratio. Decompression speed takes nearly twice as long as TLG5, but it is still more than twice as fast as PNG, and the size is 20-40% smaller than PNG.
JPEG XR
JPEG XR format can be read. It is lossy but offers higher quality than JPEG and supports alpha channels.
When compressed with a priority on image quality, it is difficult to distinguish from lossless images, and since the file size is small, it is useful when size is important.
Supported since Ver 1.1.0, currently only reading is supported.
Saving is supported since Ver 1.3.0.
Main/Mask Separated Format
This is a format where the color information image (main) and the alpha channel (mask) image are separate. The mask image is the main image's filename with _m appended (for example, abc_m.jpeg for abc.jpeg).
The formats of the main and mask images do not have to be the same.

Additionally, you can increase the number of readable image formats using Susie Plug-ins. Susie plug-ins can be loaded with the Plugins.link method.
If a 32bpp bitmap is passed from a Susie Plug-in, it is treated as a bitmap with an alpha channel.

Layer Types

KiriKiri layers can be displayed in various composition modes (layer types).
The following composition modes are available, and layer type constants starting with lt can be specified in the Layer.type property.
In the formulas, result is the result, dest is the luminance of the destination image, src is the luminance of the source image to be overlaid, and alpha is the alpha value per pixel of the source image. All values range from 0.0 to 1.0.
Also, the following functions are defined here for explanation:

ltOpaque (ltCoverRect)
ltOpaque is a display without transparency. The entire rectangle of the layer is always completely opaque (this is not limited to this layer type, but if the opacity is lowered with Layer.opacity, it will follow that).

Formula : result = src

Note
ltCoverRect has the same meaning, but it is an old name used in versions prior to 2.23 beta 2.

ltAlpha (ltTransparent)
ltAlpha performs alpha blending. This is the most basic type for transparency. The following formula is also used for alpha channel input from BMP or Susie plug-ins.

Formula : result = blend(dest, src, alpha)

Note
ltTransparent has the same meaning, but it is an old name used in versions prior to 2.23 beta 2.

ltAddAlpha
ltAddAlpha performs additive alpha blending.
The Image Format Converter can output images suitable for this format. Also, you can convert from ltAlpha to this format using the Layer.convertType method.
ltAddAlpha layers cannot be displayed correctly if they are direct children of an ltAlpha layer.

Formula : result = min(1.0, dest * ( 1.0 - alpha ) + src)
ltAdditive
ltAdditive performs additive blending. Suitable for expressing glows. It is "Linear Dodge" in Photoshop, but if you want the same effect as Photoshop, use ltPsAdditive described later. Unlike ltPsAdditive, alpha is ignored in ltAdditive.
The neutral color (the color that does not change when overlaid) is black.

Formula : result = min(1.0, dest + src)
ltSubtractive
ltSubtractive performs subtractive blending. alpha is ignored.
The neutral color is white.

Formula : result = max(0.0, dest + src - 1.0)

Note
The only difference from result = dest - src is whether src is inverted or not.