Jul 23 2009 Programming

I made some pie slices with GD. Then animated them at different intervals with Javascript.
You can test your browsers timing by watching these as they should line up frequently.  


pie 1hdaypie 2hourpie 3minpie 4secpie 51/2pie 6asap


Create the images.

#!/usr/bin/perl

# e dziewa october 2008

use warnings;
use strict;
use GD;

GD::Image->trueColor(1);


my $slice = 1;
my $start = -90;
my $end = -84;

while ( $slice <= 60 ) {

    my $image = new GD::Image(64,64) || die "couldn't create image!";

    my $white = $image->colorAllocate(255,255,255);
    my $black = $image->colorAllocate(0,0,0);
    my $red      = $image->colorAllocate(255,0,0);
    my $blue  = $image->colorAllocate(0,0,255);

    $image->transparent($black);
    $image->interlaced('true');

    $image->filledArc(32,32,64,64,$start,$end,$blue,gdEdged);

    my $file = "slice$slice.png";

    open( FH, ">", $file ) or die "couldn't open $file\n$!";
    binmode FH;
    select FH;
    print $image->png;
    close FH;
    select STDOUT;
    $slice++; $end += 6;
}


Download ← Creates 60 slices.
Download ← Creates 24 slices.

Here's the code to animate. I won't print it out here because a lot of it is taken verbatim from the book "Javascript The Definitive Guide". A very good book that's always on hand when I'm writing Javascript.

Download

and the HTML.

Download

   
Comments
No comments.
Comments for this entry available via RSS.
Comment Area
Your Name
Your Email (will not be published)
Your Website
Your Comment
Profanity is Prohibited
eric.dziewa.com is running WordPress.
WhiteSpace theme designed by E. Dziewa.
All content © E. Dziewa.
Thanks for stopping by.