Discuss Scratch

langstone
New Scratcher
6 posts

Drawing on canvas

Hi,

Trying to write an extension, in part of it I want to draw a rectangle on the canvas, above my sprite. A bit like the say command does.

I thought I would get the scratch element and draw on to it but this isn't working.

I'm sure someone out there has done this and will be willing to share or point to someone who has.

Thanks in advance
PullJosh
Scratcher
1000+ posts

Drawing on canvas

Perhaps you want to create a div and place it over top of the player? I don't really know, but it seems like that might work…
Hydrabolt
Scratcher
100+ posts

Drawing on canvas

PullJosh wrote:

Perhaps you want to create a div and place it over top of the player? I don't really know, but it seems like that might work…
Yep, that would probably work
langstone
New Scratcher
6 posts

Drawing on canvas

How would I go about this using Javascript? that will actually draw the div.

I was hopping to use document.getElementById(“scratch”); then getting context but its not working.

Last edited by langstone (Feb. 20, 2015 12:33:57)

CosmicSans
New Scratcher
100+ posts

Drawing on canvas

Scratch isn't canvas, it's swf, flash player. Are you trying to draw on the flash player? Unfortunately, that won't work.
Hydrabolt
Scratcher
100+ posts

Drawing on canvas

Just create a div element, place the scratch player inside, and make a canvas inside said div. Make it expand to take up the entire div (as the scratch player should) and give the canvas a z-index of 2 and the player a z-index of 1. Then try drawing to the canvas/
MegaApuTurkUltra
Scratcher
1000+ posts

Drawing on canvas

Hydrabolt wrote:

Just create a div element, place the scratch player inside, and make a canvas inside said div. Make it expand to take up the entire div (as the scratch player should) and give the canvas a z-index of 2 and the player a z-index of 1. Then try drawing to the canvas/
Make sure you include an iframe shim for those of us on Chrome who hate pepperflash
QuillzToxic
Scratcher
1000+ posts

Drawing on canvas

MegaApuTurkUltra wrote:

Hydrabolt wrote:

Just create a div element, place the scratch player inside, and make a canvas inside said div. Make it expand to take up the entire div (as the scratch player should) and give the canvas a z-index of 2 and the player a z-index of 1. Then try drawing to the canvas/
Make sure you include an iframe shim for those of us on Chrome who hate pepperflash
Ikr. That is one reason to like chrome.

Powered by DjangoBB