Signature Mod Stuff

Thought of something everyone else is having trouble with and just wanna help them? Post it here.
Post Reply
User avatar
Warbear
Apprentice
Posts: 49
Joined: Sat Jun 14, 2008 20:24
Location: Canberra, Australia
Contact:

Signature Mod Stuff

Post by Warbear »

I was going to re-awaken the other thread, but it is since long dead, and the links no longer valid, especially mine. I have started working on these again, and am working on a new series. Doing them for myself and my alliance, but thought I would share as well. Below is a breakdown of the code in the signatures, there are still some gaps, and some things I want to know, but hopefully this will help in getting you designing your own.

If you do make some of your own, share them?! Also, if you can fill in gaps, reply here I will add them into the second post.
Image
I do stuff...contact me.
User avatar
Warbear
Apprentice
Posts: 49
Joined: Sat Jun 14, 2008 20:24
Location: Canberra, Australia
Contact:

Re: Signature Mod Stuff

Post by Warbear »

Signature Basics
This is the code from the APOC signature that is default with the EDK, so everyone will have it as a reference. I will break it down to it's parts first, then show some quick mods to show HOW something can be done to make it different.

Firstly, the base code:

Code: Select all

<?php
/**
 * @package EDK
 */

define('MFONT', dirname(__FILE__).'/evesansmm.ttf');
define('FSIZE', 12);

$im = imagecreatefromjpeg(dirname(__FILE__).'/base.jpg');

$red = imagecolorallocate($im, 255, 10, 10);
$orange = imagecolorallocate($im, 150, 120, 20);
$blue = imagecolorallocate($im, 0, 0, 200);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);

$grey_trans = imagecolorallocatealpha($im, 50, 50, 50, 50);
$grey_transblue = imagecolorallocatealpha($im, 50, 50, 110, 10);
$grey_transbluel = imagecolorallocatealpha($im, 50, 50, 110, 100);

$name = strtoupper($pilot->getName());

$list = new KillList();
$list->setOrdered(true);
$list->setPodsNoobships(false);
$list->addInvolvedPilot($pilot);
$kill = $list->getKill();
$list->getallKills();

imagettftext($im, FSIZE, 0, 80, 21, $grey_trans, MFONT, $name);
imagettftext($im, FSIZE, 0, 80, 20, $white, MFONT, $name);

$no = $list->getCount();
$string = 'KILL# '.$no;
imagettftext($im, FSIZE, 0, 80, 41, $grey_trans, MFONT, $string);
imagettftext($im, FSIZE, 0, 80, 40, $white, MFONT, $string);

$string = strtoupper($kill->getVictimName().' - '.$kill->getVictimCorpName());
$box = imagettfbbox(FSIZE, 0, MFONT, $string);
$width = $box[4];
imagettftext($im, FSIZE, 0, 80, 76, $grey_trans, MFONT, $string);
imagettftext($im, FSIZE, 0, 80, 75, $white, MFONT, $string);

$string = strtoupper($kill->getVictimShipName());
$box = imagettfbbox(FSIZE, 0, MFONT, $string);
$width = $box[4];
imagettftext($im, FSIZE, 0, 394-$width, 61, $grey_trans, MFONT, $string);
imagettftext($im, FSIZE, 0, 394-$width, 60, $white, MFONT, $string);

$string = $kill->getSolarSystemName();
$box = imagettfbbox(FSIZE, 0, MFONT, $string);
$width = $box[4];
imagettftext($im, FSIZE, 0, 394-$width, 76, $grey_trans, MFONT, $string);
imagettftext($im, FSIZE, 0, 394-$width, 75, $white, MFONT, $string);

function bevel($x, $y, $size)
{
    global $im, $grey_transblue, $grey_transbluel,$red;
    imagefilledrectangle($im, $x+1, $y+$size-3, $x+$size-1, $y+$size, $grey_transbluel);
    imagefilledrectangle($im, $x+$size-3, $y+1, $x+$size, $y+$size-1, $grey_transbluel);
    imageline($im, $x+1, $y-1, $x+$size, $y-1, $grey_transbluel);
    imagerectangle($im, $x, $y, $x+$size, $y+$size, $grey_transblue);
}

// ship
$sid = $kill->getVictimShipExternalID();
$img = shipImage::get($sid);
imagecopyresampled($im, $img, 354, 6, 0, 0, 40, 40, 64, 64);

bevel(354, 6, 40);

// player portrait
$img = imagecreatefromjpeg(Pilot::getPortraitPath(256,$pid));
//imagefilledrectangle($im, 318, 18, 392, 92, $greyred_trans);
imagecopyresampled($im, $img, 6, 6, 0, 0, 63, 63, 256,256);
imagedestroy($img);

bevel(6, 6, 63);
?>
//FONTS

Code: Select all

define('MFONT', dirname(__FILE__).'/evesansmm.ttf');
define('FSIZE', 12);
The first line defines the reference to the font, and the location/name of the font. You can go to places like dafont.com and grab any font you like, just make sure it is a .ttf (true type format) font and you will be okay to use it in the sigs. The second line defines the size of the font in PIXELS. This is important because EVERYTHING in the php is pixel based for measurements. You can have multiple fonts in one sig, you just need to define a new font name for each font you wish to use. You can also have multiple sizes as well. Below is a list of three fonts, and 3 sizes to use them for:

Code: Select all

define('MAIN_FONT', dirname(__FILE__).'/somefontname.ttf');
define('SMALL_FONT', dirname(__FILE__).'/someotherfontname.ttf');
define('LARGE_FONT', dirname(__FILE__).'/somethingofafontname.ttf');
define('MAIN_SIZE', 12);
define('SMALL_SIZE', 9);
define('LARGE_SIZE', 18);
//BACKGROUND IMAGE

Code: Select all

$im = imagecreatefromjpeg(dirname(__FILE__).'/base.jpg');
This defines the background image of the signature. For each sig you make, the easiest thing you can do is actually have this remain the same, and name the image file in each folder base.jpg. I am working slowly at the moment on a way to use transparent .pngs to do some cool effects, but it's slow going. Anyway...

Rules for this are simple. Whatever size the base.jpg, that's the output size of the sig. The $im variable is called as the basis of what to place everything else onto and what to apply things to (like colors etc). Speaking of colors...

//COLORS

Code: Select all

$red = imagecolorallocate($im, 255, 10, 10);
$orange = imagecolorallocate($im, 150, 120, 20);
$blue = imagecolorallocate($im, 0, 0, 200);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);

$grey_trans = imagecolorallocatealpha($im, 50, 50, 50, 50);
$grey_transblue = imagecolorallocatealpha($im, 50, 50, 110, 10);
$grey_transbluel = imagecolorallocatealpha($im, 50, 50, 110, 100);
Colors are based on an RGB (red, green, blue) setup. It also uses transparency, but I will get to that in a second. You can have as many colors as you want to use. Like the fonts you just define the name to use it as, and then set the color up. If you don't know RGB color codes, then go to this link, and find the color, then the reference numbers ###-###-### and use them. You will just need to change the structure so that it matches those in the existing section ($im, rrr, ggg, bbb).

Transparency is the same as above with an extra number. In the second set of colors you see they have a 4th number. This also goes to 255. 0 makes it solid (and is assumed in the other lines above), 255 makes it invisible. No point to that, but you CAN get some interesting effects from transparency. It also only works on TEXT in the current version of the setup.

//THE TEXT

Code: Select all

$name = strtoupper($pilot->getName());
strtoupper is designed to make the name of the pilot who the sig is for all uppercase. I will document how to adjust this down below. But for now the main part of this line is that $name will be the code used to call the name of the owner of the sig.

Code: Select all

$list = new KillList();
$list->setOrdered(true);
$list->setPodsNoobships(false);
$list->addInvolvedPilot($pilot);
$kill = $list->getKill();
$list->getallKills();
This bit is pulling all the information for the sig. There is a lot more to go than this list, and some I will detail in the next post. There are however also some gaps in here that I am working on still and once I have them will add to the post as well. The big one at the moment is that I want to have the points earned from the kill listed.

//PLACING THE TEXT / ELEMENTS

Code: Select all

imagettftext($im, FSIZE, 0, 80, 21, $grey_trans, MFONT, $name);
imagettftext($im, FSIZE, 0, 80, 20, $white, MFONT, $name);
So this is going to place the NAME ($name) of the sig owner. The syntax works like this:

Code: Select all

imagettftext(<the image base>, <size of the font>, <angle going counter clockwise>, <x position>, <y position>, <font color>, <font used>, <what to present>);
The rules. The image top left is 0,0 x,y and the x is the height.
Almost EVERY line called into the image will start with the base $im to apply it to.
Text should be built UP per element, with the shadow (if used) listed BEFORE the actual text in sequence.

Let's discuss each part of the placement.

> size of the font <
You can use a numerical value here, but using the code from the top allows it to be reused, and easy referencing, swap them as you need. This is measured in pixels.

> angle of rotation <
You can make text rotate, with the fixed point being the middle of the left most character. If you enter a value of 90, it will read from bottom to top. If you type in 270 you read from top to bottom.

> x position <
This is the position along the left side.

> y position <
This is the position along the bottom edge.

> font color <
You can either use the value of the string(s) at the top as required, or just use the strings themselves. Either or works.

> font used <
You can define it here individually, but using the ones at the top makes it easier to manage, and once one is working, needs it less.

> what you are going to present <
Be it a variable pulled from the killmail, or a string of text (or combination) this will be the basics of signature each time.

Code: Select all

$no = $list->getCount();
$string = 'KILL# '.$no;
imagettftext($im, FSIZE, 0, 80, 41, $grey_trans, MFONT, $string);
imagettftext($im, FSIZE, 0, 80, 40, $white, MFONT, $string);
This bit is getting the kill number as per that board. It only looks at that board, so if it is not there it won't count it. It then outputs the kill number as WELL as some text, and combines them. If you want text either before, after or both where a variable is, you MUST make sure you place a period (full stop) on the side of the variable the string is located, and single quotes around the text, examples:

Code: Select all

$string = 'KILL# '.$no;
$string = 'KILL# '.$no.' Or something';
$string = $no.' kills to date.';
Just use that format and you should be okay to add your own text.

Code: Select all

$string = strtoupper($kill->getVictimName().' - '.$kill->getVictimCorpName());
$box = imagettfbbox(FSIZE, 0, MFONT, $string);
$width = $box[4];
imagettftext($im, FSIZE, 0, 80, 76, $grey_trans, MFONT, $string);
imagettftext($im, FSIZE, 0, 80, 75, $white, MFONT, $string);
Th BOX element is a way to define an area for text to sit. I won't go into it too much for one simple reason, I remove it. But if you want to learn something about it, go here.

//SHIP IMAGE

Code: Select all

$sid = $kill->getVictimShipExternalID();
$img = shipImage::get($sid);
imagecopyresampled($im, $img, 354, 6, 0, 0, 40, 40, 64, 64);
Like everything, the first part is the $im, which is the image to apply this to. The second $img, is based on the $sid (ship ID) of the ship. The format of the numbers is:
imagecopyresampled($im, $img, <where to start drawing the image on the X axis>, <where to start drawing the image on the Y axis>, <where to start measuring x> , <where to start measuring y>, <set the width of the image>, <set the height of the image>, <define the width of the original image>, <define the height of the original image>)
If the original image is not the same as it is deisplayed you will get weird image shaping and weird borders around the image. You can apply this same trick to adding other images to a sig (see the cool stuff below).

//PLAYER IMAGE (PORTRAIT)
Same as //SHIP IMAGE above. Thing to note, is that the portrait is pulled in in 256px size by default, this may cause it to blur a little, so you can play with other sizes. Check cool things below for other options.

//BEVEL

Code: Select all

function bevel($x, $y, $size)
{
    global $im, $grey_transblue, $grey_transbluel,$red;
    imagefilledrectangle($im, $x+1, $y+$size-3, $x+$size-1, $y+$size, $grey_transbluel);
    imagefilledrectangle($im, $x+$size-3, $y+1, $x+$size, $y+$size-1, $grey_transbluel);
    imageline($im, $x+1, $y-1, $x+$size, $y-1, $grey_transbluel);
    imagerectangle($im, $x, $y, $x+$size, $y+$size, $grey_transblue);
}
bevel(354, 6, 40);
Actually tells you the layout, x & y are the starting points of the box being drawn. Size refers to how many pixels wide & tall the box is. It will always be a square. it also due to the format places this OVER the ship and portrait images. Better off to place it first, make it 2 pixels larger and start 1 pixel shorter on the X and Y if you want just a simple box around something. It uses the same colors from the section at the top.

I hope that helps someone, and some of you mad skillerz will come and add more to it.
Last edited by Warbear on Mon Oct 14, 2013 08:09, edited 3 times in total.
Image
I do stuff...contact me.
User avatar
Warbear
Apprentice
Posts: 49
Joined: Sat Jun 14, 2008 20:24
Location: Canberra, Australia
Contact:

Re: Signature Mod Stuff

Post by Warbear »

Cool tricks
Image
I do stuff...contact me.
User avatar
Warbear
Apprentice
Posts: 49
Joined: Sat Jun 14, 2008 20:24
Location: Canberra, Australia
Contact:

Re: Signature Mod Stuff

Post by Warbear »

Examples...

Here is one I made for a client.
Image

All the text is built into the script, the faded name in the back ground is also made in the script.

This is mine below:
Image
Multiple fonts, different colors, multiple images brought in (the ship image is one, then the cancelled image).
Image
I do stuff...contact me.
Post Reply