PHP Developers Network

Imagepolygon Stars (Now with pic) [56K WARNING]
Page 1 of 1

Author:  onion2k [ Mon Jan 24, 2005 2:48 pm ]
Post subject:  Imagepolygon Stars (Now with pic) [56K WARNING]

I'm on a roll here. Playing with imagepolygon() stuff, I came up with a nice function to make stars..

Syntax: [ Download ] [ Hide ]
function star($number_of_points,$outer_radius=100,$inner_radius=40) {

                $p = array();

                $degrees = 360/($number_of_points*2);

                for ($i=0;$i<$number_of_points*2;$i++) {

                        $cos = cos(deg2rad($degrees*$i));

                        $sin = sin(deg2rad($degrees*$i));

                        $x = 0;

                        $y = ($i%2==0)?$outer_radius:$inner_radius;

                        $p&#1111;] = $cos*($x) - $sin*($y);

                        $p&#1111;] = $sin*($x) + $cos*($y);


                return $p;


Small isue with it at the moment coz it doesn't work with the rotatePolygon() function I posted yesterday. I'll fix it eventually. Unless someone else does.

Made a groovy pic using this function:


Author:  Chris Corbyn [ Tue Feb 08, 2005 8:53 am ]
Post subject: 

Wow that is pretty cool. I couldn't work it until I looked closer and saw that the whole picture is made from stars.

I like cool code like that... I hated maths at school but now with programming I see why we learnt it and how it can actually be pretty fun...

Nice one ;-) 8)

Author:  windwaker [ Sun Feb 13, 2005 9:01 pm ]
Post subject: 

Author:  John Cartwright [ Wed Oct 26, 2005 10:18 am ]
Post subject: 

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group