New version with a tweak for custom brushes.

`// --------------------------------- //`

// Project: revealPainter

// Start: Thursday, January 12, 2017

// IDE Version: 14.497

// SETCURRENTDIR("Media") // go to media files

GLOBAL brushW=14

GLOBAL brushH=7

GLOBAL brushStar[]

DIM brushStar[brushW*brushH]

//RESTORE square

RESTORE star

makeBrush(brushW,brushH)

SETSCREEN 800,600,0

SYSTEMPOINTER 1

GLOBAL array%[]

CONSTANT size=256

DIM array%[size*size]

GLOBAL back%=3000//GENSPRITE()

GLOBAL sc=5//GENSCREEN()

CREATESCREEN sc,back,size,size

USESCREEN sc

FOR q=0 TO 500

DRAWRECT RND(size),RND(size),10+RND(40),10+RND(40),RND(0xffffff)

NEXT

USESCREEN -1

DRAWSPRITE back,100,100

//IF

SPRITE2MEM(array%[],back)

GLOBAL newone%=2999//GENSPRITE()

MEM2SPRITE(array%[],newone,size,size)

LOCAL mx,my,b1,b2

FOR a=0 TO (size*size)-1

array%[a]=bAND(array%[a],0x00ffffff)

NEXT

LOCAL pos

//LOCAL bs=10

REPEAT

MOUSESTATE mx,my,b1,b2

IF mx>size-brushW THEN mx=size-brushW

IF my>size-brushH THEN my=size-brushH

IF mx<=0 THEN mx=0

IF my<=0 THEN my=0

IF b1

FOR h =0 TO brushH-1

FOR w=0 TO brushW-1

IF queryBrush(w,h,brushW,brushH)=1 //NEW BIT

pos=(my+h)*size+(mx+w)

array%[pos]=bOR(array%[pos],0xff000000)

ENDIF

NEXT

NEXT

ENDIF

MEM2SPRITE(array%[],newone,size,size)

DRAWRECT 0,0,size+2,size+2,0xffffff

DRAWRECT 1,1,size,size,0

DRAWSPRITE newone,1,1

DRAWSPRITE back,size*1.2,2

PRINT "DRAW WITH LEFT MB IN THE PANE",0,size*1.2

showBrush(brushW,brushH,5)

SHOWSCREEN

UNTIL FALSE

MOUSEWAIT

FUNCTION makeBrush:w,h

LOCAL b$,r$,c

FOR y= 0 TO h-1

READ r$

FOR x=0 TO w-1

IF MID$(r$,x,1)="*" THEN brushStar[c]=1

INC c

NEXT

NEXT

ENDFUNCTION

FUNCTION showBrush:w,h,s

LOCAL c

FOR y= 0 TO h-1

FOR x=0 TO w-1

IF brushStar[c]=1 THEN DRAWRECT 400+(x*s),400+(y*s),s,s,0x00ff00

INC c

NEXT

NEXT

ENDFUNCTION

FUNCTION queryBrush:x,y,w,h

IF brushStar[y*w+x]=1 THEN RETURN 1

ENDFUNCTION

STARTDATA square:

DATA "**************"

DATA "* *"

DATA "* *"

DATA "* *"

DATA "* *"

DATA "* *"

DATA "**************"

ENDDATA

STARTDATA star:

DATA " * "

DATA " *** "

DATA " ***** "

DATA "************* "

DATA " *********** "

DATA " ******* "

DATA " *** *** "

DATA " ** ** "

ENDDATA