import Base32Image from "classes/Base32Image" ; import ITask from "interfaces/Tasks" ; import * as request from "request-promise-native" ; import { Point2d } from "types/Point" ; async function getBoard ( ) { const res = await request . get ( "https://www.luogu.org/paintBoard/board" ) ; return res . split ( "\n" ) ; } async function getTasks ( image , [ x , y ] ) { const board = await getBoard ( ) ; const resArray = [ ] ; for ( let i = 0 ; i < image . y ; ++ i ) { for ( let j = 0 ; j < image . x ; ++ j ) { if ( board [ j + x ] [ i + y ] !== image . data [ i ] [ j ] ) { resArray . push ( { color : image . data [ i ] [ j ] , point : [ j + x , i + y ] , } ) ; } } } return resArray ; } export default getTasks ;