import type { TransformDefinitions } from "../../elements/transform/type"; import { Color, CommonDisplayableConfig, ImageSrc } from "../../types"; import { LogicAction } from "../../game"; import { FlexibleTuple, SelectElementFromEach } from "../../../../util/data"; import { Chained, Proxied } from "../../action/chain"; import { Displayable } from "../../elements/displayable/displayable"; import { EventfulDisplayable } from "../../../player/elements/displayable/type"; import { ImageTransition } from "../../elements/transition/transitions/image/imageTransition"; import { Layer } from "../../elements/layer"; export type TagDefinition = T extends TagGroupDefinition ? TagDefinitionObject : never; export type TagDefinitionObject = { groups: T; defaults: SelectElementFromEach; resolve: TagSrcResolver; }; type ImageSrcType = T extends TagGroupDefinition ? TagDefinition : (Color | ImageSrc); export interface IImageUserConfig extends CommonDisplayableConfig { /** * The name of the image, only for debugging purposes */ name: string; /** * If set to false, the image won't be initialized unless you call `init` method * @default true */ autoInit: boolean; /** * Image Src, see [Image](https://react.narraleaf.com/documentation/core/elements/image) for more information */ src: ImageSrcType; /** * Auto resize image's width to fit the screen * @default false */ autoFit: boolean; /** * layer of the image */ layer?: Layer; /** * Darkness of the image, between 0 and 1 * @default 0 */ darkness?: number; } export type TagGroupDefinition = string[][]; export type TagSrcResolver = (...tags: SelectElementFromEach) => string; export declare class Image extends Displayable implements EventfulDisplayable { /** * Construct an image element. The config can describe either static sources or tagged outfits, but not both. * @param config - Image metadata such as tags, source, layer, and wearables. * @example * ```ts * const image = new Image({ * src: { * groups: [["happy", "sad"], ["top", "coat"]], * defaults: ["happy", "top"], * resolve: (emotion, top) => `https://img/${emotion}_${top}.png` * } * }); * ``` */ constructor(config?: Partial>); /** * Set the source of the image * * - Tag-based image: the src will be resolved from the tags * - Static image: the src will be a string or StaticImageData * @example * ```ts * image.char("path/to/image.png", new Dissolve(1000)); * ``` * @example * ```ts * image.char(["happy", "t-shirt", "shorts"], new Dissolve(1000)); * ``` * @chainable */ char(src: ImageSrc | Color, transition?: ImageTransition): Proxied>; char(tags: SelectElementFromEach | FlexibleTuple>, transition?: ImageTransition): Proxied>; /** * Set the darkness of the image * @param darkness - The darkness of the image, between 0 and 1 * @chainable */ darken(darkness: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied>; /** * Add wearable images that move with this image. * @param children - A wearable image or an array of wearables. * @example * ```ts * const hat = new Image({ src: "hat.png" }); * image.addWearable(hat); * ``` */ addWearable(children: Image | Image[]): this; /** * Alias of {@link Image.addWearable}. * @param children - Wearable image or images */ wear(children: Image | Image[]): this; /** * Bind this image as a wearable child of another image. * @param parent - The parent image that should carry this wearable. * @example * ```ts * childImage.bindWearable(parentImage); * ``` */ bindWearable(parent: Image): this; /** * Alias of {@link Image.bindWearable}. * @param parent - The parent image */ asWearableOf(parent: Image): this; /** * Assign a layer to the image, overriding the config. * @param layer - Layer instance or `null` to remove the override. */ useLayer(layer: Layer | null): this; } export {};