Setting Pixels - More answers to suggestions

Jan Schenkel janschenkel at yahoo.com
Thu Jan 30 01:44:01 EST 2003


--- Monte Goulding <monte at sweattechnologies.com>
wrote:
> [snip]
> 
> Actually I just had a bit more of a play and found
> that the slow part of my
> script was getting the imageData so I used a local
> variable and tested if it
> was empty:
> 
> local tData
> 
> on mouseUp
>   put the long seconds into tSeconds
>   put empty into iData
>   put binaryEncode("CCCC",0,0,255,0) into redPixel
>   if tData = "" then
>     put the imageData of image 1 into tData
>     delete char 1 to 1600 of tData
>   end if
>   repeat for 400
>     put redPixel after iData
>   end repeat
>   set the imageData of image 1 to iData&tData
>   put the long seconds-tSeconds
> end mouseUp
> 
> This makes it slightly slower on the first run:
> 0.168s but heaps faster on
> subsequent runs 0.02s.
> 

I think you can speed this up just a litle bit on the
first run by changing:
  if tData = "" then
    put char 1601 to -1 of the imageData of image 1 \
       into tData
  end if
This ought to be slightly faster as the engine doesn't
have to resize the tData variable again, nor push its
contents forwards upon deleting from the front.

Hope this helped,

Jan Schenkel.

PS; the idea of keeping the imageData inside a local
variable instead of retrieving it again would probably
be a lifesaver for this sort of routines ; good stuff!

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the use-livecode mailing list