[Project_owners] intensive recursions in Javascript

Preet Shihn preetshihn at gmail.com
Mon May 7 15:10:55 PDT 2007


Eric,

I did post the algorithm (
http://www.htmlgoodies.com/primers/jsp/article.php/3622321  - look at the
Flood Fill algorithm)
Note that there is a recursive implementation, and a stack based while-loop
implementation.
Although the stack-based loop implementation is slightly better, I still run
into performance issues, as I am dealing a pixel to pixel basis.

I guess I can do some research into alternative algorithms (which is going
to be hard).

- Preet


On 5/7/07, eric.jung at yahoo.com <eric.jung at yahoo.com> wrote:
>
> Perhaps if you post your algorithm we can help.
>
>
> ----- Original Message ----
> From: Preet Shihn <preetshihn at gmail.com>
> To: Mozdev Project Owners List <project_owners at mozdev.org>
> Sent: Monday, May 7, 2007 3:14:31 PM
> Subject: Re: [Project_owners] intensive recursions in Javascript
>
> I am using Canvas.. I can not use SVG... well not now at least, unless i
> revamp a whole lot of code.
> Filling is easy using canvas at the time you want to  draw, but filling
> later..after it has been drawn requires pixel manipulation, for which I am
> using the flood fill algorithm.
>
> I guess I can use window.setTimeout but it will just avoid that script
> dialog to pop-up, but the whole performance issue still exists. I am going
> to try it and see what performance stats I get.
>
> - Preet
>
> On 5/7/07, Matthew Wilson <matthew at mjwilson.demon.co.uk> wrote:
> >
> > Preet Shihn wrote:
> > > Heyas!
> > >
> > > I am a semi-javascript newbie. I noticed that Javascript isn't really
> > > great with long running recursive methods or a long running while loop
> > > that can be memory intensive.
> > > I see the browser popup "A script on the page may be busy, or it may
> > > have stopped responding..... Stop the script or continue". I was
> > > wondering how people have dealt with this. An example of such a method
> >
> > > that I was implementing is Flood Fill. Basically, fill a contoor with
> > a
> > > specified colour.
> >
> > Can you use SVG or Canvas to avoid the work?
> >
> > Or use window.setTimeout to split up the work you're doing into chunks?
> >
> > Matthew
> > _______________________________________________
> > Project_owners mailing list
> > Project_owners at mozdev.org
> > http://mozdev.org/mailman/listinfo/project_owners
> >
>
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
>
>
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/project_owners/attachments/20070507/042e50d6/attachment.html 


More information about the Project_owners mailing list