[PHP/GDlib] Volgende regel

Pagina: 1
Acties:

Onderwerpen


Acties:
  • 0 Henk 'm!

  • Japie.G
  • Registratie: Augustus 2001
  • Laatst online: 19:54

Japie.G

Colour Classic

Topicstarter
Ik heb ff een scripje gemaakt die een plaatje met een text tekent.

[script]
$txt = "Dit is de eerste tekst in een album";

// teken de shit
$img = ImageCreate(100,100);
$bg = ImageColorAllocate($img,217,234,245);
$tx = ImageColorAllocate($img,0,0,0);
ImageFilledRectangle($img,0,0,100,100,$bg);
ImageString($img,3,5,5,$txt,$tx);
[/script]

Nouja goed, het plaatje is 100x100 dus die tekst past nooit.
Ik wil dus dat ie als het ware naar de volgende regel gaat!

Ik kom er niet uit!
Wie heeft er een tip voor me?

p.s. Ik ben GD n00b, ik vond het al heel wat dat dit scrippie een plaatje tekende :P

Renault Scenic E-Tech EV - PV-Output


Acties:
  • 0 Henk 'm!

  • seweso
  • Registratie: Augustus 2003
  • Laatst online: 04-04-2018

seweso

de mouw is uit de aap

Ik doe dat zelf op de volgende manier:

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function imagestring2($image_resource, $dest_text, $x, $y, $border, $back_color, $front_color, $font_nr)
{
    imagestring ($image_resource, $font_nr, $x - $border, $y - $border, $dest_text, $back_color);
    imagestring ($image_resource, $font_nr, $x + $border, $y - $border, $dest_text, $back_color);
    imagestring ($image_resource, $font_nr, $x - $border, $y + $border, $dest_text, $back_color);
    imagestring ($image_resource, $font_nr, $x + $border, $y + $border, $dest_text, $back_color);

    imagestring ($image_resource, $font_nr, $x - $border, $y, $dest_text, $back_color);
    imagestring ($image_resource, $font_nr, $x + $border, $y, $dest_text, $back_color);
    imagestring ($image_resource, $font_nr, $x, $y + $border, $dest_text, $back_color);
    imagestring ($image_resource, $font_nr, $x, $y - $border, $dest_text, $back_color);


    imagestring ($image_resource, $font_nr, $x, $y, $dest_text, $front_color);  
};

imagestring2($dest, substr($dest_text,0,8), 2,12,1,$text_backcolor, $text_frontcolor, 3);
imagestring2($dest, substr($dest_text,8,16), 2,22,1,$text_backcolor, $text_frontcolor, 3);
imagestring2($dest, substr($dest_text,16,24), 2,32,1,$text_backcolor, $text_frontcolor, 3);
imagestring2($dest, substr($dest_text,24,32), 2,32,1,$text_backcolor, $text_frontcolor, 3);


Beetje kort-door-de-bocht maar het werkt wel.

Ooh er zit ook een extra functie in waarmee je tekst leesbaarder kan maken als je het op een foto plaatst (die kun je natuurlijk er wel uithalen).

seweso's blog


Acties:
  • 0 Henk 'm!

  • Japie.G
  • Registratie: Augustus 2001
  • Laatst online: 19:54

Japie.G

Colour Classic

Topicstarter
Okee dan!!

Het is voor elkaar!!!

Harstikke bedankt!

Renault Scenic E-Tech EV - PV-Output


Acties:
  • 0 Henk 'm!

  • SuperRembo
  • Registratie: Juni 2000
  • Laatst online: 20-08 14:36
In de PHP manual staat de functie die je zoekt:
code:
1
2
3
resource imagestringbox ( resource image, 
   int font, int left, int top, int right, int bottom, int align, int valign, 
   int leading, string text, int color )


This function allows you to draw text inside a box. It will automatically wrap at the end of the line and cut the text if it is further than the bottom line. The text can be aligned vertically and horizontally. Manual new lines can be made by using \n (note that you can not escape that symbol though). The space between lines can also be set using leading (negative values are accepted).

| Toen / Nu