php programming 4

Put your programming skills to the test in these challenges.

php programming 4

Post by ozi1985 on Tue Jul 14, 2009 12:43 pm
([msg=26816]see php programming 4[/msg])

I'm trying to solve this in PHP. I don't know how it's even possible. I get something printed though, and what I actually get is the image here: http://bildr.no/view/449362

I'm just wondering if anyone else has done this mission with php, or what programming language i should use.
ozi1985
New User
New User
 
Posts: 3
Joined: Thu May 28, 2009 2:40 am
Blog: View Blog (0)


Re: php programming 4

Post by smithmetal on Tue Jul 14, 2009 12:55 pm
([msg=26817]see Re: php programming 4[/msg])

I've done it in php (gd library), but i don't have my source code anymore. If i recall correctly, the only tricky part was the arcs. If you need help, just PM me your code and i'll give you hints.
Image
User avatar
smithmetal
New User
New User
 
Posts: 22
Joined: Sun Apr 13, 2008 9:09 pm
Blog: View Blog (0)


Re: php programming 4

Post by ozi1985 on Wed Jul 15, 2009 10:03 am
([msg=26850]see Re: php programming 4[/msg])

i wasn't allowed to send messages for some reason. I'll just port parts here. It won't be enough to help with the actual translation, so i guess its ok.

I have two classes in my php code. One for Line, and one for Arc.
a line will be presented like this:
object(Line)#1 (5) {
["XEnd"]=> string(5) "402.2"
["YEnd"]=> string(5) "411.2"
["XStart"]=> string(5) "402.2"
["YStart"]=> string(5) "420.8"
["Color"]=> string(3) "red"
}
Then the imageline is: imageline($img, $XStart, $YStart, $XEnd, $YEnd, $color);

And Arc will be presented like this:
object(Arc)#91 (6) {
["XCenter"]=> string(5) "261.8"
["YCenter"]=> string(5) "386.8"
["ArcStart"]=> string(3) "165"
["Radius"]=> string(3) "4.2"
["ArcExtend"]=> string(3) "230"
["Color"]=> string(6) "yellow"
}

then the imagearc is: imagearc($img, $XCenter, $YCenter, $Radius, $Radius, $ArcStart, $ArcExtend, $color);

The imagearc is supposed to be
imagearc ( resource $image , int $cx , int $cy , int $width , int $height , int $start , int $end , int $color )

So i don't really know where to look now... I get the xml reading correct (I checked the values i got against the xml document), but the image is something I can't read. I don't know if it's just me being blind here... the color variable is with a small c, if anyone wants to comment on this. And I know I'm supposed to use lowchar on the first letter of a variable, but it was easier to see this way...
ozi1985
New User
New User
 
Posts: 3
Joined: Thu May 28, 2009 2:40 am
Blog: View Blog (0)


Re: php programming 4

Post by smithmetal on Wed Jul 15, 2009 11:40 am
([msg=26853]see Re: php programming 4[/msg])

PHP imagearc() :
int start : The arc start angle, in degrees.
int end: The arc end angle, in degrees. 0° is located at the three-o'clock position, and the arc is drawn clockwise.
---
Also, you may have noticed that the (0,0) couple in this challenge is located in the bottom left corner instead of top left.

p.s. : Radius * 2 = width and height
Image
User avatar
smithmetal
New User
New User
 
Posts: 22
Joined: Sun Apr 13, 2008 9:09 pm
Blog: View Blog (0)


Re: php programming 4

Post by ozi1985 on Thu Jul 16, 2009 1:57 pm
([msg=26879]see Re: php programming 4[/msg])

thank you :)

I knew I was just being stupid...
ozi1985
New User
New User
 
Posts: 3
Joined: Thu May 28, 2009 2:40 am
Blog: View Blog (0)


Re: php programming 4

Post by h4ck3rz on Sat Jan 23, 2010 8:32 pm
([msg=33789]see Re: php programming 4[/msg])

Thanks for the hints...
Until this morning(this night in america :D :D), I haven't mentioned that the arc is drawn counter-clockwise in this mission...
:D
h4ck3rz
New User
New User
 
Posts: 11
Joined: Mon May 26, 2008 8:53 pm
Blog: View Blog (0)


Re: php programming 4

Post by neo_2011 on Sat Feb 26, 2011 12:43 pm
([msg=54320]see Re: php programming 4[/msg])

Hi All, this is my first post in this forum. I am currently trying out the Programming Mission 4. I am using PHP GD to render the image. I am facing the same problem as the poster of this thread. Please see my rendered image at the below link:

Image

The capital letters are some what legible but the small case letters are not legible and in some cases the letter itself is not visible. I know that i am going wrong in the drawing of the arc. Below is my arc code

Code: Select all
imagearc($my_img,$xcenter,$ycenter,($radius+$radius),($radius+$radius),$arcstart,$arcextend,$blue_colour);


I am still not clear with how the degrees should be used. Can anyone please help me to understand where i am going wrong

regards

-- Mon Feb 28, 2011 1:01 pm --
EDIT:
Solved it myself.. actually the comments given by smithmetal itself is sufficient...thnx a lot smithmetal..
neo_2011
New User
New User
 
Posts: 1
Joined: Sat Feb 26, 2011 12:29 pm
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests