Welcome, Guest. Please login or register.

Login with username, password and session length
February 07, 2012, 11:38:26 PM
[Less]
  • News: ATokar.net 3.0 has been released! Click here for more info.

  •  
linktree ATokar.net  >  General Community  >  Off Topic
linktree Topic: Easter 2008
Pages: [1]   Go Down
  Print  
Author Topic: Easter 2008  (Read 1130 times)
0 Members and 1 Guest are viewing this topic. Bookmarked by 0 members.
Cleo
Administrator
Developer
Karma: +6/-0
Offline Offline

Gender: Male
Posts: 172




WWW
« on: March 23, 2008, 02:17:22 PM »

Happy Easter Everyone!

:D

And of course we have a little Easter egg for all of you. The Easter egg is a little PHP script.

Code: (php) [Select]


$image = imagecreatetruecolor(400, 500);

$bg = imagecolorallocate($image, 10, 10, 150);
imagefill($image, 0, 0, $bg);

// allocate some colors
$white = imagecolorallocate($image, 255, 255, 255);
$grey = imagecolorallocate($image, 128, 128, 128);
$black = imagecolorallocate($image, 0, 0, 0);

// choose a color for the elipse
$col_ellipse = imagecolorallocate($image, 255, 200, 255);

// draw ellipse shadow
imagefilledellipse($image, 215, 265, 320, 400, $black);

// draw the ellipse
imagefilledellipse($image, 200, 250, 320, 400, $col_ellipse);

//draw arc where plastic egg opens
imagearc($image, 198, 235, 326, 100, 0, 180, $bg);

$colour = imagecolorallocate($image, 100, 0, 200);

$ca = rand(2,5);
$cb = rand(2,5);
$cc = rand(2,5);
$cd = rand(2,5);

${"colour".$ca} = imagecolorallocate($image, 153, 204, 255);
${"colour".$cb} = imagecolorallocate($image, 102, 0, 153);
${"colour".$cc} = imagecolorallocate($image, 204, 153, 204);
${"colour".$cd} = imagecolorallocate($image, 153, 0, 255);

//positions of stars relative to original position

$shift['x'][]=0;  //star 1
$shift['y'][]=0;
$star['color'][] = $colour;

$shift['x'][]=-80;  //star 2
$shift['y'][]=-120;
$star['color'][] = $colour2;

$shift['x'][]=-130; //star 3
$shift['y'][]=10;
$star['color'][] = $colour3;

$shift['x'][]=-10; //star 4
$shift['y'][]=-250;
$star['color'][] = $colour4;

$shift['x'][]=-160; //star 5
$shift['y'][]=-200;
$star['color'][] = $colour5;

for($ii=0; $ii < count($shift['x']); $ii++)
{

// set up array of points for polygon
$values = array(
            230,  330,
            290,  390,
            280,  340,
            240, 380,
            310, 370,
            230,  330
            );

    $shiftX = $shift['x'][$ii];
    $shiftY = $shift['y'][$ii];
   
    foreach ($values as &$val)
    {
        if($i == 1){    $val = $val+$shiftY;    $i++;    }
        else
        {    $val = $val+$shiftX;        $i = 1;    }
    }
   
   
    // draw a star filled in with a circle
    imagefilledpolygon($image, $values, 6, $star['color'][$ii]);
    imagefilledellipse($image, 273+$shiftX, 364+$shiftY, 35, 24, $star['color'][$ii]);
}//end for

// Rotate
$degrees = rand(0,360);

$image= imagerotate($image, $degrees, 0);

imagefilter($image, IMG_FILTER_MEAN_REMOVAL, 0);
imagefilter($image, IMG_FILTER_SMOOTH, 0);

//resize the image
$width = imagesx($image);
$height = imagesy($image);

if($height > 0) { $ratio = $width/$height; }

$rand = rand(25,75);
$perc = $rand/100;

$newwidth = $width * $perc;
$newheight = $height * $perc;

$image2 = imagecreatetruecolor($newwidth, $newheight);

imagecopyresampled($image2, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

header("Content-type: image/png");
imagepng($image2);

?>


Preview:



Try refreshing this page several times, the egg rotates and changes size! And once more, Happy Easter to everyone!
Logged

Voodoo
Karma: +0/-0
Offline Offline

Gender: Male
Posts: 5



« Reply #1 on: March 24, 2008, 08:47:55 AM »

way cool php script =] and yes Happy Easter
Logged
Cleo
Administrator
Developer
Karma: +6/-0
Offline Offline

Gender: Male
Posts: 172




WWW
« Reply #2 on: March 24, 2008, 02:22:26 PM »

I forgot to mention that GD2 is required for the script to run properly. :)
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  


Copyright © 2007–2010 ATokar.net. All trademarks are property of their respective owners.
Powered by SMF | SMF © 2006–2007, Simple Machines LLC
Page created in 0.107 seconds with 28 queries.
Contact Us - ATokar.net - XML - Sitemap - Top
Valid HTML 4.01! Valid CSS! Valid RSS! Powered by Linux Powered by MySQL Powered by PHP Powered by Apache 2.2