Arrows in PHP Using GD Libraries

images php coding issues or problems here.

Moderators: macek, egami, gesf

Duggary
New php-forum User
New php-forum User
Posts: 13
Joined: Wed Nov 05, 2003 9:52 am

Arrows in PHP Using GD Libraries

Postby Duggary » Thu Dec 11, 2003 5:37 am

Hi,

I wish to write a PHP script that allows users to dynamically create images consisting of squares, lines and arrows. I know that there are functions in the GD library that draw rectangles, lines and polygons but have noticed that there is no function that allows the production of arrows and so have came to the realisation that I will have to write function to draw them myself.

Drawing the main body of the arrow (i.e. the line) is easy, the bit I am stuck with is drawing the lines representing the arrow head. This is because I wish to allow users to be able to draw arrow of any length and at any angle, and thus the angle of the arrow head lines will be different for every arrow drawn.

Does anyone have any suggestions about what I could do?

Thanks for your time and help in advance,
C

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

arrows

Postby ruturajv » Fri Dec 12, 2003 2:33 am

hi,
First i suppose you have basic knowledge of cartesian system. .. X, Y Axis.. and so

I haven't done this before but guess my idea is correct

CHECK
->first check what is the angle.. to the positive X axis
->set a fixed length to the arrow-head you want.
->set a replica angle of the arrow... ie. the lines which are at an angle to each other at the arrow head

PROCEDURE
->now at the end of the line(the plain one)... draw another line in the same angle with the length of the arrow head.
->now create a line with a pivot point at the apex of the head and length of the arrowhead and rotate it Counterclockwise or anticlockwise by the replica angle set
->now create a line with a pivot point at the apex of the head and length of the arrowhead and rotate it Clockwise by the replica angle set
-> and whoaaa!!!! you've got the arrow!!!! :D :D

Duggary
New php-forum User
New php-forum User
Posts: 13
Joined: Wed Nov 05, 2003 9:52 am

Postby Duggary » Wed Dec 17, 2003 2:47 am

Cheers!

It looks pretty complex but I'll give it a go!


Return to “PHP coding => Images”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

cron