Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Animations: Open as Layers to Double Animation but Maintain Replace.
#9
Hello all.  I've solved my problem at last, yesterday actually.  I was half way through reading a beginners' tutorial on Python on Monday afternoon when it struck me that even though GIMP likes C for its programs and Python for its scripts, maybe I could find a way to do what I needed to do with plain old PHP, and so that's what I did in the end.

I still use GIMP to create two base images in .XCF for the Earth 'O' and Moon 'o', and then the Spinning-Globe plugin to create my 24 Earth layers and 348 Moon layers, in two .XCF files, then I have used another plugin I found on the web by Anitools to copy each layer of those two images to each their own .PNG file, in two separate directories because Anitools likes to name every file as in 000.PNG and so on, but this was no problem.

Then I wrote a little PHP script to run through a series of creating 'truecolor' (RGB) images, and copying the appropriate Earth and Moon .PNGs (in reversed order for half the orbit), 696 times, with the Moon getting two of the same before incrementing its counter so its 348 images match the 696 hours in a 29 day month.

Here is the PHP code in case anyone's curious, and I will try to add a link to the little 64x32 .GIF animation which was the intention when I first thought about it back on Sunday night, the 5th ...

Code:
<?php
 echo 'Start of Time: '.time()."\n";
 $r = (22 / 7) / 180; $orb_t = 5.14;
 $orb_x = 1024; $orb_y = 512;
 $o_x = $orb_x / 2; $o_y = $orb_y / 2;
 $e_x = 512; $e_y = 512;
 $m_x = 256; $m_y = 256;
 $e_h = 24; $m_h = $e_h * 29; $m_q = $m_h / 4;
 $r_x = (($e_x + $m_x) / 2) - 2; $r_y = (($e_y - $m_y) / 2) -2;
 $orb_fln = 'orbit/'; $e_fln = 'earth/'; $m_fln = 'moon/'; $x_fln = '.png';
 $orb_pad = '00'; $e_pad = '00'; $m_pad = '00';
 $e_cnt = 0; $m_cnt = 0; $m_tog = 0;
 
 for($orb_cnt = 0; $orb_cnt < $m_h; $orb_cnt++ ){       
  if($e_cnt > 9){ $e_pad = '0'; }else{ $e_pad = '00'; }
  if($m_cnt > 99){ $m_pad = '';
  }else{if($m_cnt > 9){ $m_pad = '0'; }else{ $m_pad = '00';}}
  if($orb_cnt > 99){ $orb_pad = '';
  }else{if($orb_cnt > 9){ $orb_pad = '0'; }else{ $orb_pad = '00';}}
  $e_im = imagecreatefrompng($e_fln.$e_pad.$e_cnt.$x_fln);
  $m_im = imagecreatefrompng($m_fln.$m_pad.$m_cnt.$x_fln);
  $orb_im = imagecreatetruecolor($orb_x, $orb_y);
  $black = imagecolorallocate($orb_im, 0,0,0); // For a transparent background
  imagecolortransparent($orb_im, $black);      // you just have to do this.
  $pd = $orb_cnt * 360 * $r / $m_h;
  $px = round(($o_x - ($m_x / 2)) - ($r_x * sin($pd)));  
  $py = round(($o_y - ($m_y / 2)) - (($r_y / 2) * (cos($pd) - (sin($pd)*sin($orb_t)))));
  if( $orb_cnt > $m_q && $orb_cnt < ($m_q * 3 ) ){
   imagecopy($orb_im, $e_im, ($orb_x - $e_x) / 2, 0, 0, 0, $e_x, $e_y);
   imagecopy($orb_im, $m_im, $px, $py, 0, 0, $m_x+2, $m_y+2);
  }else{
   imagecopy($orb_im, $m_im, $px, $py, 0, 0, $m_x+2, $m_y+2);
   imagecopy($orb_im, $e_im, ($orb_x - $e_x) / 2, 0, 0, 0, $e_x, $e_y);
  }
  $e_cnt++; $m_tog++;
  if($e_cnt >= $e_h){ $e_cnt = 0; }      
  if($m_tog >= 2 ){ $m_cnt++; $m_tog = 0; }
  imagepng($orb_im, $orb_fln.$orb_pad.$orb_cnt.$x_fln);
  imagedestroy($orb_im); imagedestroy($m_im); imagedestroy($e_im);
 }
 echo 'End of Time: '.time()."\n";
?>

PS:  The good news is that reading the Python style guides (PEP-484?) has helped me to try to improve the readability of my own code, but I'll let someone else be the judge on that.


[Image: Orbitalogo_64x32_002.gif]
Reply


Messages In This Thread
RE: Animations: Open as Layers to Double Animation but Maintain Replace. - by Seano - 03-15-2017, 06:56 AM

Forum Jump: