ocif-js
    Preparing search index...

    Class OCIF

    Represents an OCIF (OpenComputers Image Format) image. This class provides methods to create, manipulate, load, and save OCIF images.

    Index

    Constructors

    • Creates a new OCIF image.

      Parameters

      • width: number

        The width of the image.

      • height: number

        The height of the image.

      • fill: Partial<Pixel> = {}

        Optional. A pixel for filling the image. Defaults to a black background, white foreground, and a space character.

      Returns OCIF

    Properties

    height: number
    pixels: Pixel[]
    width: number

    Methods

    • Gets the pixel at the specified coordinates.

      Parameters

      • x: number

        The x-coordinate of the pixel.

      • y: number

        The y-coordinate of the pixel.

      Returns Pixel | undefined

      The pixel at the specified coordinates, or undefined if the coordinates are out of bounds.

    • Sets the pixel at the specified coordinates.

      Parameters

      • x: number

        The x-coordinate of the pixel.

      • y: number

        The y-coordinate of the pixel.

      • pixel: Pixel

        The pixel to set.

      Returns void

    • Saves the OCIF image to a buffer.

      Parameters

      • encodingMethod: number = 8

        The OCIF encoding method to use. Can be 5, 6, 7, or 8. Defaults to 8.

      Returns Buffer

      A buffer containing the OCIF image data.

    • Converts the OCIF image to a PNG buffer.

      Parameters

      • scale: number = 1

        The scale factor for the output PNG. Defaults to 1.

      Returns Buffer

      A buffer containing the PNG image data.

    • Loads an OCIF image from a buffer.

      Parameters

      • buffer: Buffer

        The buffer containing the OCIF image data.

      Returns OCIF

      A new OCIF instance.