-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtext.php
50 lines (42 loc) · 1 KB
/
text.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/*
* This file is part of GImage.
*
* (c) Jose Quintana <https://joseluisq.net>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
/**
* Creating a Canvas with Text.
*
* @author Jose Quintana <https://joseluisq.net>
*/
namespace GImage\Examples;
use GImage\Text;
use GImage\Figure;
use GImage\Canvas;
require __DIR__ . '/_config.php';
require __DIR__ . '/../tests/bootstrap.php';
$figure = new Figure(400, 250);
$figure
->setBackgroundColor(47, 42, 39)
->create();
$text = new Text('My Text with opacity!');
$text
->setWidth(400)
->setHeight(250)
->setAlign('center') // or "none"
->setValign('center') // or "none"
// Or use line height
// ->setLineHeight(1.2)
->setSize(22)
->setOpacity(0.5)
->setColor(255, 255, 255)
->setFontface(BASE_PATH . '/fonts/Lato-Bol.ttf');
$canvas = new Canvas($figure);
$canvas
->append($text)
->toPNG()
->draw()
->save(__DIR__ . '/text.png');