getImageData

63 views
Skip to first unread message

seanodonnell

unread,
Feb 17, 2011, 3:25:54 PM2/17/11
to fxcanvas
Hi There,

I have some canvas js code Im trying to get working under ie with
fxcanvas, the problem I am coming up against is that when I use
context.invoke to work with getImageData it does not seem to block,
the handler appears to run asynchronously in the background. The
problem is that Im not trying to alter imagedata on the fly, but
rather gather it, place it in a cache, and refer to it for collision
detection later, but the code that does the collision detection is
referring to the cache before the context.invoke takes effect. Is
there any way to call it with blocking behaviour?

Thanks

Sean

Evgeny Burzak

unread,
Feb 18, 2011, 4:38:57 AM2/18/11
to seanodonnell, fxca...@googlegroups.com
Hi,

I want to figure out what's the problem.. By blocking you have in mind that after you call invoke, following canvas commands must be saved in a buffer, before they will actually applyed on a canvas? When you get image data, canvas buffer must be flushed, right? Is it problem local for IE or for all browsers?
Some code snippets may be helpful..

> Deli

--
Evgeny Burzak <buz...@gmail.com>

Sean

unread,
Feb 18, 2011, 9:08:29 AM2/18/11
to fxca...@googlegroups.com
On 18/02/11 09:38, Evgeny Burzak wrote:
> Hi,
>
> I want to figure out what's the problem.. By blocking you have in mind that after you call invoke, following canvas commands must be saved in a buffer, before they will actually applyed on a canvas? When you get image data, canvas buffer must be flushed, right? Is it problem local for IE or for all browsers?
> Some code snippets may be helpful..

Hi Evgeny,

What I have in mind is much simpler (Its possible I dont understand the
current behaviour properly).

1. I draw something on the canvas (Text usually)
2. I call getImageData to record the pixels that are now not blank
3. I save the not blank pixels in a cache when getImageData returns
4. I search for a blank area to draw the next item using the data
returned in 2


The sequence above is what I get using ff, chrome and opera with an
actual canvas, but when I use a debugger and console logs using fxcanvas
I see.

1.
2.
4.
1.
2.
4.
3.
3.

Resulting in the code drawing more text on areas it thinks are blank as
the cache has not been updated.

You can see the actual code here

http://blog.odonnell.nu/static/wurdle/wurdle.html

The important file is http://blog.odonnell.nu/static/wurdle/js/wurdle.js

The function update_word_cache at line 417 has both the fxcanvas and
normal canvas functionality in it.

It generates a sort of tag cloud given text,

easiest way to run it is to put a twitter username in the textfield

Thanks for you help

Sean

Evgeny Burzak

unread,
Feb 19, 2011, 11:11:46 AM2/19/11
to fxca...@googlegroups.com
I'll see what can i do soon.. Now busy a bit.


--
Evgeny Burzak <buz...@gmail.com>

Sean

unread,
Feb 20, 2011, 3:27:20 PM2/20/11
to fxca...@googlegroups.com
Thanks Evgeny,

I really appreciate the help, this is just a hobby project, so no panic.

All the best, and thanks for fxcanvas

Sean

Reply all
Reply to author
Forward
0 new messages