📄 text.php
字号:
<?php
/**
* Image_Text - Advanced text maipulations in images
*
* Image_Text provides advanced text manipulation facilities for GD2
* image generation with PHP. Simply add text clippings to your images,
* let the class automatically determine lines, rotate text boxes around
* their center or top left corner. These are only a couple of features
* Image_Text provides.
* @package Image_Text
* @license The PHP License, version 3.0
* @author Tobias Schlitt <toby@php.net>
* @category images
*/
/**
*
* Require PEAR file for error handling.
*
*/
require_once 'PEAR.php';
/**
* Regex to match HTML style hex triples.
*/
define("IMAGE_TEXT_REGEX_HTMLCOLOR", "/^[#|]([a-f0-9]{2})?([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i", true);
/**
* Defines horizontal alignment to the left of the text box. (This is standard.)
*/
define("IMAGE_TEXT_ALIGN_LEFT", "left", true);
/**
* Defines horizontal alignment to the center of the text box.
*/
define("IMAGE_TEXT_ALIGN_RIGHT", "right", true);
/**
* Defines horizontal alignment to the center of the text box.
*/
define("IMAGE_TEXT_ALIGN_CENTER", "center", true);
/**
* Defines vertical alignment to the to the top of the text box. (This is standard.)
*/
define("IMAGE_TEXT_ALIGN_TOP", "top", true);
/**
* Defines vertical alignment to the to the middle of the text box.
*/
define("IMAGE_TEXT_ALIGN_MIDDLE", "middle", true);
/**
* Defines vertical alignment to the to the bottom of the text box.
*/
define("IMAGE_TEXT_ALIGN_BOTTOM", "bottom", true);
/**
* TODO: This constant is useless until now, since justified alignment does not work yet
*/
define("IMAGE_TEXT_ALIGN_JUSTIFY", "justify", true);
/**
* Image_Text - Advanced text maipulations in images
*
* Image_Text provides advanced text manipulation facilities for GD2
* image generation with PHP. Simply add text clippings to your images,
* let the class automatically determine lines, rotate text boxes around
* their center or top left corner. These are only a couple of features
* Image_Text provides.
*
* @package Image_Text
*/
/*
// This is a simple example script, showing Image_Text's facilities.
require_once 'Image/Text.php';
$colors = array(
0 => '#0d54e2',
1 => '#e8ce7a',
2 => '#7ae8ad'
);
$text = "EXTERIOR: DAGOBAH -- DAY\nWith Yoda\nstrapped to\n\nhis back, Luke climbs up one of the many thick vines that grow in the swamp until he reaches the Dagobah statistics lab. Panting heavily, he continues his exercises -- grepping, installing new packages, logging in as root, and writing replacements for two-year-old shell scripts in PHP.\nYODA: Code! Yes. A programmer's strength flows from code maintainability. But beware of Perl. Terse syntax... more than one way to do it... default variables. The dark side of code maintainability are they. Easily they flow, quick to join you when code you write. If once you start down the dark path, forever will it dominate your destiny, consume you it will.\nLUKE: Is Perl better than PHP?\nYODA: No... no... no. Orderless, dirtier, more seductive.\nLUKE: But how will I know why PHP is better than Perl?\nYODA: You will know. When your code you try to read six months from now...";
$options = array(
'canvas' => array('width'=> 600,'height'=> 600), // Generate a new image 600x600 pixel
'cx' => 300, // Set center to the middle of the canvas
'cy' => 300,
'width' => 300, // Set text box size
'height' => 300,
'line_spacing' => 1, // Normal linespacing
'angle' => 45, // Text rotated by 45
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -