- Joined
- Aug 11, 2008
- Messages
- 2,628
- Solutions
- 2
- Reaction score
- 240
Some of you may be aware that not that long ago I released a character signature script, and some of you may even be using it. I would like you to stop using it, immediately. I have a new version for you, and even if we put that aside, it was poorly done.
Download: GD API © Absolute Mango
Method List (only those with public access):
Example #1:
What you need to do before you do anything else, is to actually create a background for it and then load/display it.
Example #2:
Now let's imagine you would want to add a piece of text on the image. With this API it is as easy as never before!
Example #3:
Now let's imagine you would like this to be dynamic. Then you would have no clue whatsoever how long a string may be (e.g. character name) and you would want the next string to come right after the previous text without having to set a static position.
As you can see, there's an option to set the position to MADGD_STACK which means that it will put it next to the previous entry (with a 5pixel margin, you can change that also by adding a second argument "->setPosition(MADGD_STACK, -5)").
Example #4:
There is also the option to style your text strings accordingly (not all of the 4 key elements are required, only the ones you wish for).
'
Example #5:
Then we have the option to add icons to our image (e.g. a characters equipments). It works exactly the same way as the addText function does, only that you are not able to style it with a second command. However, you are able to use the MADGD_STACK functionality.
There are several predefined variables such as the LEFTHAND_X and the LEFTHAND_Y ones, but it is not required to use those. If you do however use the same background as I do, the predefined equipment variables are positioned correctly and highly recommended to use.
That's about it folks!
If you have any questions at all, please do not hesitate to ask.
Download: GD API © Absolute Mango
Method List (only those with public access):
- $image->setBackground(image);
- $image->addText(text, configArray)->setPosition(x, y);
- $image->addIcon(image)->setPosition(x, y);
- $image->display();
Example #1:
What you need to do before you do anything else, is to actually create a background for it and then load/display it.
PHP:
$image = new MadGD;
$image->setBackground('mySignature.png');
$image->display();
Example #2:
Now let's imagine you would want to add a piece of text on the image. With this API it is as easy as never before!
PHP:
$image = new MadGD;
$image->setBackground('mySignature.png');
$image->addText('This is my awesome sentance!')->setPosition(10, 10);;
$image->display();
Example #3:
Now let's imagine you would like this to be dynamic. Then you would have no clue whatsoever how long a string may be (e.g. character name) and you would want the next string to come right after the previous text without having to set a static position.
PHP:
$image = new MadGD;
$image->setBackground('mySignature.png');
$image->addText('Name:')->setPosition(10, 10);
$image->addText('Absolute Mango')->setPosition(MADGD_STACK);
$image->display();
Example #4:
There is also the option to style your text strings accordingly (not all of the 4 key elements are required, only the ones you wish for).
PHP:
$styled = array(
'font' => 'arial.ttf',
'size' => 8,
'color' => '#AAFFFF',
'shadow' => false
);
$image = new MadGD;
$image->setBackground('mySignature.png');
$image->addText('Name:')->setPosition(10, 10);
$image->addText('Absolute Mango', $styled)->setPosition(MADGD_STACK);
$image->display();
Example #5:
Then we have the option to add icons to our image (e.g. a characters equipments). It works exactly the same way as the addText function does, only that you are not able to style it with a second command. However, you are able to use the MADGD_STACK functionality.
PHP:
$styled = array(
'font' => 'arial.ttf',
'size' => 8,
'color' => '#AAFFFF',
'shadow' => false
);
$image = new MadGD;
$image->setBackground('mySignature.png');
$image->addText('Name:')->setPosition(10, 10);
$image->addText('Absolute Mango', $styled)->setPosition(MADGD_STACK);
$image->addIcon('2400.gif')->setPosition(LEFTHAND_X, LEFTHAND_Y);
$image->display();
There are several predefined variables such as the LEFTHAND_X and the LEFTHAND_Y ones, but it is not required to use those. If you do however use the same background as I do, the predefined equipment variables are positioned correctly and highly recommended to use.
That's about it folks!
If you have any questions at all, please do not hesitate to ask.
Last edited: