PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Sep 29, 2020 1:34 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Jan 24, 2005 2:48 pm 
Offline
Jedi Mod
User avatar

Joined: Tue Dec 21, 2004 6:03 pm
Posts: 5263
Location: usrlab.com
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:

Image


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 8:53 am 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
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)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 13, 2005 9:01 pm 
Offline
Forum Newbie

Joined: Sun Feb 13, 2005 12:18 pm
Posts: 21


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 10:18 am 
Offline
Site Admin
User avatar

Joined: Tue Dec 23, 2003 3:10 am
Posts: 11470
Location: Toronto


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group