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

Need help with Photoshop, the GIMP, Illustrator, or others? Want to show off your work? Looking for advice on your newest Flash stuff?

Moderator: General Moderators

Post Reply
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

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

Post by onion2k »

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

Code: Select all

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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

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)
windwaker
Forum Newbie
Posts: 21
Joined: Sun Feb 13, 2005 11:18 am

Post by windwaker »

Whoa, that's awesome, though I can imagine that'll take up some CPU time. @_@
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Moved to Code Snipplets.
Post Reply