Page 1 of 1
Using Brush Tool
Posted: Sat Nov 14, 2020 12:22 pm
by gsillevis
Hello!
I'm trying to add a brush tool to my stack. I can't figure out how to control what image it draws on. I want it to draw on image 'paper.png' but it keeps drawing on an image behind it. Does anyone know how to fix this?
Thank you!
Re: Using Brush Tool
Posted: Sat Nov 14, 2020 1:12 pm
by jmburnod
Hi gsillevis ,
Is your image 'paper.png' referenced from an external file "'paper.png'" ?
Best regards
Jean-Marc
Re: Using Brush Tool
Posted: Sat Nov 14, 2020 1:15 pm
by gsillevis
Yes, it is an imported control
Re: Using Brush Tool
Posted: Sat Nov 14, 2020 2:24 pm
by jmburnod
Yes, it is an imported control
Yes but i think that is a referenced control (your image have a filename9
To draw on image you have to import your image not referenced (import as control)

- MenuImportControl.png (27.55 KiB) Viewed 5117 times
Re: Using Brush Tool
Posted: Sat Nov 14, 2020 2:26 pm
by gsillevis
It is not a referenced control, it is imported.
It is inside a group, though. When I moved it out of the group, it suddenly works better.
Re: Using Brush Tool
Posted: Sat Nov 14, 2020 2:45 pm
by gsillevis
I'm making a game and I want players to be able to turn on a drawing layer (by clicking the Pencil On button at top right)
While I am able to get the new layers to appear (by turning on visible of a group called " Paper") the brush tool prefers to draw on the layers below it
Re: Using Brush Tool
Posted: Sat Nov 14, 2020 4:17 pm
by jmburnod
Just an idea...
Is it possible in your context to export snapshot to a variable from rect of image paper.png and set the text of image paper.png to content of variable ?
Be careful, if your image paper.png has been resized, the rect of image paper.png keep rect of snapshot.
Re: Using Brush Tool
Posted: Sat Nov 14, 2020 4:20 pm
by gsillevis
I ended up using this code:
Code: Select all
on mouseup
if there is no image "Paper.png" then
copy image "CleanPaper.png" of card "Menu Page" to this card
set the name of image "CleanPaper.png" to "Paper.png"
set layer of image "Paper.png" to top
end if
set blendlevel of image "Paper.png" to 50
set visible of image "Paper.png" to true
set visible of button "Clear image" to true
set visible of button "Close pencil" to true
set layer of group GUI to top
end mouseup
And it works great.
Unfortunately I only realised too late that the Brush tool doesn't work in HTML5 (which is what I'm building this for)...
But at least I learned some new things along the way!
Re: Using Brush Tool
Posted: Sat Nov 14, 2020 4:42 pm
by jmburnod
I tested what i described above and it works.
Know the name of target image will be next step (mouseenter is not sent when brush tool s selected.
Fortunately, mousemove is sent and we can get the mouseloc on mousemove. Then a simple loop can return the name of target image if the mouseloc is within the rect of an image.
Code: Select all
on doSetTextImg pImg -- pImg = image name
put the rect of img pImg into tRect
export snapshot from rect tRect of this cd to tDataImg as PNG
set the text of img seymaz to tDataImg
delete last img -- image created when you paint
end doSetTextImg
Jean-Marc