Skip to content

Commit

Permalink
fix: add more typescript definitions (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
gianluca-moro committed Oct 7, 2022
1 parent 2ddabf9 commit e4eb534
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 36 deletions.
123 changes: 97 additions & 26 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ export declare class Image {
blackHat(options?: MorphologicalOptions): Image;
morphologicalGradient(options?: MorphologicalOptions): Image;

// warpingFourPoints
warpingFourPoints(
pts: Array<Array<number>>,
options?: {
calculateRatio?: boolean;
},
): Image;
crop(options?: CropOptions): Image;
cropAlpha(options?: { threshold?: number }): Image;
resize(options?: ResizeOptions): Image;
Expand Down Expand Up @@ -154,7 +159,7 @@ export declare class Image {
getMatrix(options?: { channel?: number }): Matrix;
setMatrix(matrix: Matrix, options?: { channel?: number });
getPixelsArray(): Array<Array<number>>;
// getIntersection
getIntersection(mask2: Image): object;
getClosestCommonParent(mask: Image): Image;
getThreshold(options?: { algorithm?: ThresholdAlgorithm }): number;

Expand Down Expand Up @@ -191,9 +196,23 @@ export declare class Image {

// cannyEdge
convolution(kernel: Kernel, options?: ConvolutionOptions): Image;
// extract
extract(
mask: Image,
options?: {
position?: Array<number>;
},
): this;
// floodFill
// paintLabels
paintLabels(
labels: Array<string>,
positions: Array<Array<number>>,
options?: {
color?: Array<number> | string;
colors?: Array<Array<number>> | Array<string>;
font?: string | Array<string>;
rotate?: number | Array<number>;
},
): this;
paintMasks(
masks: Image | Array<Image>,
options?: {
Expand All @@ -207,35 +226,87 @@ export declare class Image {
labelColor?: string;
labelFont?: string;
},
): Image;
// paintPoints
// paintPolyline
// paintPolylines
): this;
paintPoints(
points: Array<Array<number>>,
options?: {
color?: Array<number> | string;
colors?: Array<Array<number>> | Array<string>;
randomColors?: boolean;
distinctColors?: boolean;
shape?: object;
},
): this;
paintPolyline(
points: Array<Array<number>>,
options?: {
color?: Array<number>;
closed?: boolean;
},
): this;
paintPolylines(
polylines: Array<Array<Array<number>>>,
options?: {
color?: Array<number> | string;
colors?: Array<Array<number>> | Array<string>;
randomColors?: boolean;
distinctColors?: boolean;
shape?: object;
},
): this;
paintPolygon(
points: Array<Array<number>>,
options?: {
color?: Array<number>;
filled?: boolean;
},
): Image;
): this;
paintPolygons(
points: Array<Array<Array<number>>>,
options?: {
color?: Array<number> | string;
colors?: Array<Array<number>> | Array<string>;
randomColors?: boolean;
distinctColors?: boolean;
shape?: object;
},
): this;

// paintPolygons

// countAlphaPixels
// monotoneChainConvexHull
// minimalBoundingRectangle
// getHistogram
// getHistograms
// getColorHistogram
// getMin
// getMax
// getSum
// getMoment
// getLocalMaxima
// getMedian
// getMean
// getPoints
// getRelativePosition
countAlphaPixels(options?: { alpha?: number }): number;
monotoneChainConvexHull(): Array<Array<number>>;
minimalBoundingRectangle(options?: {
originalPoints?: Array<Array<number>>;
}): Array<Array<number>>;
getHistogram(options?: {
maxSlots?: number;
channel?: number;
useAlpha?: boolean;
}): Array<number>;
getHistograms(options?: { maxSlots?: number }): Array<Array<number>>;
getColorHistogram(options?: {
useAlpha?: boolean;
nbSlots?: number;
}): Array<number>;
getMin(): Array<number>;
getMax(): Array<number>;
getSum(): Array<number>;
getMoment(xPower: number, yPower: number): number;
getLocalMaxima(options?: {
mask?: Image;
region?: number;
removeClosePoints?: number;
invert?: boolean;
maxEquals?: number;
}): Array<number>;
getMedian(): Array<number>;
getMean(): Array<number>;
getPoints(): Array<Array<number>>;
getRelativePosition(
targetImage: Image,
options?: {
defaultFurther?: boolean;
},
): Array<number> | boolean;
}

export declare class Stack extends Array<Image> {
Expand Down
12 changes: 6 additions & 6 deletions src/image/operator/paintLabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { css2array } from '../../util/color';
import { RGB } from '../model/model';

/**
* Paint a mask or masks on the current image.
* Paint a label or labels on the current image.
* @memberof Image
* @instance
*
* @param {Array<string>} [labels] - Array of labels to display. Should the the same size as masks.
* @param {Array<Array>} [positions] - Array of labels to display. Should the the same size as masks.
* @param {object} [options]
* @param {number[]|string} [options.color='red'] - Array of 3 elements (R, G, B) or a valid css color.
* @param {Array<Array<number>>|Array<string>} [options.colors] - Array of Array of 3 elements (R, G, B) for each color of each mask
* @param {Array<string>} [labels] - Array of labels to display.
* @param {Array<Array<number>>} [positions] - Array of points [x,y] where the labels should be displayed.
* @param {object} [options]
* @param {Array<number>|string} [options.color='red'] - Array of 3 elements (R, G, B) or a valid css color.
* @param {Array<Array<number>>|Array<string>} [options.colors] - Array of Array of 3 elements (R, G, B) for each color of each label.
* @param {string|Array<string>} [options.font='12px Helvetica'] - Paint the labels in a different CSS style
* @param {number|Array<number>} [options.rotate=0] - Rotate each label of a define angle
* @return {this} The original painted image
Expand Down
2 changes: 1 addition & 1 deletion src/image/operator/paintPolygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @param {Array<Array<number>>} points - Array of [x,y] points
* @param {object} [options]
* @param {Array<number>} [options.color=[max,0,0]] - Array of 3 elements (R, G, B), default is red.
* @param {Array<number>} [options.filled=false] - If you want the polygon to be filled or not.
* @param {boolean} [options.filled=false] - If you want the polygon to be filled or not.
* @return {this} The original painted image
*/
export default function paintPolygon(points, options = {}) {
Expand Down
4 changes: 2 additions & 2 deletions src/image/operator/paintPolygons.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getColors } from '../../util/color';

/**
* Paint an array of polygon on the current image.
* Paint an array of polygons on the current image.
* @memberof Image
* @instance
* @param {Array<Array<number>>} polygons - Array of array of [x,y] points
* @param {Array<Array<Array<number>>>} polygons - Array of array of [x,y] points
* @param {object} [options]
* @param {Array<number>|string} [options.color] - Array of 3 elements (R, G, B) or a valid css color.
* @param {Array<Array<number>>|Array<string>} [options.colors] - Array of Array of 3 elements (R, G, B) for each color of each mask
Expand Down
2 changes: 1 addition & 1 deletion src/image/operator/paintPolylines.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getColors } from '../../util/color';
* Paint polylines on the current image.
* @memberof Image
* @instance
* @param {Array<Array<number>>} polylines - Array of array of [x,y] points
* @param {Array<Array<Array<number>>>} polylines - Array of array of [x,y] points
* @param {object} [options]
* @param {Array<number>|string} [options.color] - Array of 3 elements (R, G, B) or a valid css color.
* @param {Array<Array<number>>|Array<string>} [options.colors] - Array of Array of 3 elements (R, G, B) for each color of each mask
Expand Down

0 comments on commit e4eb534

Please sign in to comment.