Jerky Animated Graphics

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Jerky Animated Graphics

Post by richmond62 » Mon Mar 21, 2016 8:16 pm

I have been messing around with what are, frankly, extremely simplistic, experiments in animating
polygon graphics.

However, as I change the vertices of a graphic the thing won't stay still but keeps moving its centre, so I have
to keep reseting its left side. As a result while the animation is running the whole thing looks like
a horrible, jerky film from about 1880, which, while charming in its own way is not what I am
aiming at: a smooth, flowing animation.
Graphic Games1.png
Graphic Games1.png (10.62 KiB) Viewed 3930 times
Graphic Games2.png
I would be most grateful for any ideas on how to achieve that smoothness of motion.
Attachments
Graphic Games.livecode.zip
Here's the stack.
(2.18 KiB) Downloaded 263 times

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Jerky Animated Graphics

Post by [-hh] » Mon Mar 21, 2016 11:19 pm

Code: Select all

on mouseUp
  setPoints 2
end mouseUp

on setPoints STRETCH
  lock screen; lock messages
  put fld "VERTS" into fld "VERTS2"
  put fld "VERTS" into fld "VERTS3"
  add 2 to STRETCH; if STRETCH > 300 then exit setPoints
  put (360 + STRETCH),310 into line 3 of fld "VERTS2"
  put (360 - STRETCH),10 into line 4 of fld "VERTS2"
  ----
  put (360 - STRETCH),310 into line 3 of fld "VERTS3"
  put (360 + STRETCH),10 into line 2 of fld "VERTS3"
  put (360 + STRETCH),10 into line 4 of fld "VERTS3"
  set points of graphic "GG" to fld "VERTS2"
  set points of graphic "GG2" to fld "VERTS3"
  send "setPoints STRETCH" to me in 1 tick
  unlock screen; unlock messages
end setPoints
I also would do that with variables, avoiding field reading/writing (and use one single polygon with 8 points).

Hermann

[Edit. Sorry, 8 points not 6 points. What I meant is the following.]

Code: Select all

local pts, dx

on mouseUp
  put 2 into dx
  put (50,10)&cr&(50,310)&cr&(360,310)&cr&(360,10) &cr&cr& \
        (50,10)&cr&(360,10)&cr&(360,310)&cr&(50,310) into pts
  setPoints 0
end mouseUp

on setPoints cntr
  add 1 to cntr
  if cntr > 310 div dx then exit setPoints
  lock screen; lock messages
  add  dx to item 1 of line 3 of pts
  add -dx to item 1 of line 4 of pts
  add  dx to item 1 of line 7 of pts
  add -dx to item 1 of line 8 of pts
  set points of graphic "GG" to pts
  -- this is now so fast than you can go up here to 3 ticks
  -- or use a slider for speed and/or dx, could be fun for kids?
  send "setPoints cntr" to me in 1 ticks 
  unlock screen; unlock messages
end setPoints
shiftLock happens

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Jerky Animated Graphics

Post by Simon » Tue Mar 22, 2016 12:42 am

Sorry
BEEF-JERKY.gif
Just too easy
BEEF-JERKY.gif (209.84 KiB) Viewed 3883 times
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Jerky Animated Graphics

Post by richmond62 » Tue Mar 22, 2016 7:19 am

That was going pastrami so fast I almost missed it!

Post Reply

Return to “Multimedia”