Programming 4 - C++ drawing

Put your programming skills to the test in these challenges.

Programming 4 - C++ drawing

Post by Ninfa on Sat Feb 28, 2009 11:40 am
([msg=18875]see Programming 4 - C++ drawing[/msg])

I was gonna try this one on PHP but since I had a tiny fight with the gd library I decided to experiment in C++, I coded a parser, who seems to be working just fine. I first tried the drawing with the example on, when I could make a drawing on my application look like that one with the same coordinates, I tried out the application, and the result is not really readable, although some characters are formed.

This is the console version of the parser (executable only, avoiding spoiling - no drawing involved, just to test the parser alone):

Since the origin is at the top left corner, contrary to the bottom left corner origin that the mission uses, I gotta work it out a bit for the drawings to match. All I do to lines is inverting the y coordinates, for arcs I invert the y coordinate, and subtract the height of the arc to the y-center, then take 90 degrees on the start angle.
It appears to be fine with the example given, but then...

...Getting drawings like:
New User
New User
Posts: 16
Joined: Sun Feb 22, 2009 1:57 am
Location: Behind you.
Blog: View Blog (0)

Re: Programming 4 - C++ drawing

Post by dwmead03 on Sat Mar 07, 2009 12:44 pm
([msg=19503]see Re: Programming 4 - C++ drawing[/msg])

I recently also completed this mission and ran into the same problem as you. Looks like you are drawing your lines correctly, but your arcs, not so much. I used VB.NET and the draw an arc I had to specify a rectangle that encompasses a circle which the arc would complete, the x,y coordinates of the upper left hand corner of that rectangle, and the angles at which the arc should be drawn. The thing you need to figure out is how to successfully convert the data given in the XML file, into the exact coordinates you need for whatever is drawing your image. It only took me a little while, and some simple math should solve the trick. Just try to think about what the values need to be for whatever your using to draw your image.
User avatar
New User
New User
Posts: 30
Joined: Mon Apr 14, 2008 11:34 pm
Location: KY
Blog: View Blog (0)

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests