Skip to content

Commit

Permalink
add type declaration files
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanJPNM committed Apr 3, 2021
1 parent 1ff8d46 commit 6740764
Show file tree
Hide file tree
Showing 13 changed files with 1,672 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -8,6 +8,7 @@
"url": "http://joshondesign.com/"
},
"type": "module",
"types": "./types/index.d.ts",
"module": "./src/index.js",
"main": "./dist/pureimage-umd.cjs",
"browser": "./src/browser.js",
Expand Down Expand Up @@ -44,4 +45,4 @@
"node": ">=0.8"
},
"license": "MIT"
}
}
109 changes: 109 additions & 0 deletions types/bitmap.d.ts
@@ -0,0 +1,109 @@
import { Context } from './context.js';

/**
* The Bitmap class is used for direct pixel manipulation(for example setting a pixel colour,
* transparency etc). It also provides a factory method for creating new instances of
* {@link Context}
*
* @class Bitmap
*/
export class Bitmap {
width: number;
height: number;
data: ArrayBuffer;

/**
* Creates an instance of Bitmap.
* @param {number} w Width
* @param {number} h Height
* @param {any} options Currently unused
* @memberof Bitmap
*/
constructor(w: number, h: number, options: any);
/**
* Calculate Index
*
* @param {number} x X position
* @param {number} y Y position
*
* @returns {number}
*
* @memberof Bitmap
*/
calculateIndex(x: number, y: number): number;

/**
* Set the RGBA(Red, Green, Blue, Alpha) values on an individual pixel level
*
* @param {number} x X axis position
* @param {number} y Y axis position
* @param {number} rgba A hex representation of the RGBA value of the pixel. See {@link NAMED_COLORS} for examples
*
* @returns {void}
*
* @memberof Bitmap
*/
setPixelRGBA(x: number, y: number, rgba: number): void;

/**
* Set the individual red, green, blue and alpha levels of an individual pixel
*
* @param {number} x X axis position
* @param {number} y Y axis position
* @param {number} r Red level
* @param {number} g Green level
* @param {number} b Blue level
* @param {number} a Alpha level
*
* @returns {void}
*
* @memberof Bitmap
*/
setPixelRGBA_i(
x: number,
y: number,
r: number,
g: number,
b: number,
a: number
): void;

/**
* Get the RGBA value of an individual pixel as a hexadecimal number(See {@link NAMED_COLORS} for examples)
*
* @param {number} x X axis potiion
* @param {number} y Y axis position
*
* @returns {number}
*
* @memberof Bitmap
*/
getPixelRGBA(x: number, y: number): number;

/**
* Get Pixel RGBA Seperate
*
* @param {number} x X axis position
* @param {number} y Y axis position
*
* @ignore
*
* @returns {ArrayBuffer}
*
* @memberof Bitmap
*/
getPixelRGBA_separate(x: number, y: number): ArrayBuffer;

/**
* {@link Context} factory. Creates a new {@link Context} instance object for the current bitmap object
*
* @returns {Context}
*
* @memberof Bitmap
*/
getContext(): Context;

private _copySubBitmap(x: number, y: number, w: number, h: number): Bitmap;

private _pasteSubBitmap(src: Bitmap, x: number, y: number): void;
}
1 change: 1 addition & 0 deletions types/browser.d.ts
@@ -0,0 +1 @@
export function make(width: number, height: number): HTMLCanvasElement;

0 comments on commit 6740764

Please sign in to comment.