Skip to content

Instantly share code, notes, and snippets.

@vaiorabbit
Created May 5, 2012 08:29
Show Gist options
  • Save vaiorabbit/2600931 to your computer and use it in GitHub Desktop.
Save vaiorabbit/2600931 to your computer and use it in GitHub Desktop.
Generates pattern animation table from
; Generates pattern animation table from
; * image width/height
; * cell row/column/width/height.
(let (cw ch iw ih cc cr y)
(setq cw 240) (setq ch 296) (setq iw 1440) (setq ih 1480) (setq cc 6) (setq cr 5)
(setq y 0)
(while (< y cr)
(let (x)
(setq x 0)
(while (< x cc)
(insert (format "\tnew PatternAnimRect(%d, %d, %d, %d), // %d\n" (* x cw) (* y ch) cw ch (+ x (* y cc)))) ; x, y, w, h, id
(setq x (+ x 1))))
(setq y (+ y 1))))
; Output:
; new PatternAnimRect(0, 0, 240, 296), // 0
; new PatternAnimRect(240, 0, 240, 296), // 1
; new PatternAnimRect(480, 0, 240, 296), // 2
; new PatternAnimRect(720, 0, 240, 296), // 3
; ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment