images.d.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /// <reference path="./global.d.ts" />
  2. interface Image {
  3. getWidth(): number;
  4. getHeight(): number;
  5. saveTo(path: string): void;
  6. pixel(x: number, y: number): number;
  7. }
  8. declare namespace images {
  9. function requestScreenCapture(landscape?: boolean): boolean;
  10. function captureScreen(): Image;
  11. function captureScreen(path: string): void;
  12. function pixel(image: Image, x: number, y: number): number;
  13. function save(image: Image, path: string): void;
  14. function read(path: string): Image;
  15. function load(url: string): Image;
  16. interface FindColorOptions {
  17. region?: [number, number] | [number, number, number, number];
  18. threshold?: number;
  19. }
  20. function clip(image: Image, x: number, y: number, w: number, h: number): Image;
  21. function findColor(image: Image, color: number | string, options?: FindColorOptions): Point;
  22. function findColorInRegion(image: Image, color: number | string, x: number, y: number, width?: number, height?: number, threshold?: number): Point;
  23. function findColorEquals(image: Image, color: number | string, x?: number, y?: number, width?: number, height?: number): Point;
  24. function detectsColor(image: Image, color: number | string, x: number, y: number, threshold?: number, algorithm?: 'diff'): Point;
  25. interface FindImageOptions {
  26. region?: [number, number] | [number, number, number, number];
  27. threshold?: number;
  28. level?: number;
  29. }
  30. function findImage(image: Image, template: Image, options?: FindImageOptions): Point;
  31. function findImageInRegion(image: Image, template: Image, x: number, y: number, width?: number, height?: number, threshold?: number): Point;
  32. function findMultiColors(image: Image, firstColor: number | string, colors: [number, number, number | string][], options?: FindColorOptions): Point;
  33. function fromBase64(base64: string): Image;
  34. function toBase64(img: Image): string;
  35. }