Fast animating

Discussion related to the Cross Codebot open source framework
aradeonas
Posts: 3
Joined: Sat May 02, 2015 1:51 pm

Fast animating

Postby aradeonas » Sat May 02, 2015 1:56 pm

Hi,

for test purpose I made an array of 30 clock from clock example from repository in one render box and run them all in a normal Windows PC but in has lag in clock movement and it skips some frame.
How can I run it smoothly?

sysrpl
Posts: 108
Joined: Thu Feb 05, 2015 6:31 pm

Re: Fast animating

Postby sysrpl » Wed May 06, 2015 6:48 pm

You're probably trying to rendering too much. If you really want 30 simultaneous ticking clocks, for efficiency you should render the static parts one time to a bitmap, then only render the parts which move (the hands).

For example render the clock border and clock face to a bitmap, then save that bitmap and use ISurface.CopyTo to paint copy it 30 times across your render area, then issue the commands to draw 30 hour hands, 30 minute hands, 30 second hands, and 30 microsecond hands.

aradeonas
Posts: 3
Joined: Sat May 02, 2015 1:51 pm

Re: Fast animating

Postby aradeonas » Thu May 07, 2015 8:49 pm

Thanks but problem is still there.I removed everything except a hour ,minute,second and micro second hand and a circle for each background and all of them have just a simple color and I still have lag sometimes specially I add shadow.
I cant save them in bitmap otherwise I done that.

Can you test it your self or it need I send you project code?
Its just array of 30 clock in a grid and an animate timer and they run simultaneously and show time.
I tested BGRABitmap and it slow in this case and I think with my self maybe Codebot can do the job.

sysrpl
Posts: 108
Joined: Thu Feb 05, 2015 6:31 pm

Re: Fast animating

Postby sysrpl » Fri May 08, 2015 5:37 pm

You can save the bitmap. You need to alter the code to do this. Here is how:

var
ClockFace: IBitmap;

procedure ClockResize(Width, Height: Integer);
begin
// Create a new bitmap whenever the clocks are resized
ClockFace := NewBitmap(Width, Height);
// Extracted clock face drawing logic
ClockDrawFace(ClockFace);
// You can later use ClockFace.Surface.CopyTo
end;


Return to “Cross Codebot”

Who is online

Users browsing this forum: No registered users and 2 guests

cron