Guest User

Double Helix, Slow

a guest
May 19th, 2015
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.21 KB | None | 0 0
  1. --[[ ******************************************************************
  2. Double Helix by KOP
  3.                
  4. ******************************************************************* ]]
  5.  
  6. return function(pg, of, sw, sh)
  7.  
  8.         pg:translate(of,0,0)
  9.  
  10.     local pc, cx, cy, ops = math.abs(of/pg.width), pg.width/2, pg.height/2, of/pg.width
  11.         -- target distance
  12. local midx =pg.width/2
  13.  
  14.         local midy =pg.height/2+7
  15.         local tg = pg.width
  16.         local fx = pc*5
  17.         if fx>1 then fx=1 end
  18.         if fx<-1 then fx=-1 end
  19. local side = -1
  20.        
  21.         -- if(of>0) then side=1 end
  22.     for i, ic in subviews(pg) do
  23.                 -- get icon center
  24.                 local icx, icy = (ic.x+ic.width/2), (ic.y+ic.height/2)
  25.                 -- get icon offset from page center
  26.                 local ox, oy = cx-icx, cy-icy
  27.                 -- get angle of icon position
  28.                 local ang = math.atan2(oy,ox)
  29.                 -- get hypotenuse
  30.                 local h = math.sqrt( ox^2+oy^2)
  31. local iconX = ic.x+ic.width/2
  32.                 local fall = (1-pc)*h
  33.           local iconY = ic.y+ic.height/2
  34.                 -- get hypotenuse extension
  35.                 local oh = fx*h+fx*tg
  36.                 -- directions
  37.                 local dx, dy = 1,1
  38.                 if icx<cx then dx=-dx end
  39.                 if icy<cy then dy=-dy end
  40.                 if icy==cy then dy=0 end
  41.                 local nx = 0
  42. local ny = 0
  43. local cy = 3-3*pc
  44. if cy>1 then cy=1 end
  45. if pc==0 then pc=0.0001 end
  46.  
  47.                 -- calc new x & y
  48.                 -- local nx = math.sqrt(h^2-oy^2)
  49.                 -- local ny = math.sqrt(h^2-ox^2)
  50.                 nx =midx-ops/pc*100*math.sin(ops*2*math.pi+8*(oy-(.25*ox))/1.33/pg.height)
  51.                 ny =midy-oy+0.25*ox
  52.  -- midy-(ops*pg.height)-oy
  53.                 local size=(3-fx)*(fall/h)
  54.                 if size>1 then size=1 end
  55.                 -- move!!
  56.                 ic:translate(fx*(nx-iconX),fx*(ny-iconY),0)
  57. -- print(nx)
  58. ic:rotate(fx*math.abs(nx)/(100), 0, 1, 0)
  59. -- ic:scale(size*size)
  60. -- ic:translate(-0.5*nx,-0.5*ny,0)
  61.                
  62.                 -- if pc>0.6 then
  63.                         ic.alpha = 1-pc
  64.                 -- end
  65.  
  66.     end
  67. end
Advertisement
Add Comment
Please, Sign In to add comment