Last change
on this file since 3202 was
3150,
checked in by nico, 12 years ago
|
- Improve php binding of caca_render_canvas
- Destroy php resource in caca_file_close
- Improve sample program render.php
|
-
Property svn:executable set to
*
|
File size:
1.2 KB
|
Rev | Line | |
---|
[3149] | 1 | #!/usr/bin/php5 |
---|
| 2 | <? |
---|
| 3 | |
---|
| 4 | $pig_str = <<<EOT |
---|
| 5 | |
---|
| 6 | _._ _..._ .-', _.._(`)) |
---|
| 7 | '-. ` ' /-._.-' ',/ |
---|
| 8 | ) \ '. |
---|
| 9 | / _ _ | \ |
---|
| 10 | | a a / PHP | |
---|
| 11 | \ .-. ; |
---|
| 12 | '-('' ).-' ,' ; |
---|
| 13 | '-; | .' |
---|
| 14 | \ \ / |
---|
| 15 | | 7 .__ _.-\ \ |
---|
| 16 | | | | ``/ /` / |
---|
| 17 | jgs /,_| | /,_/ / |
---|
| 18 | /,_/ '`-' |
---|
| 19 | EOT; |
---|
| 20 | |
---|
| 21 | $canvas = caca_create_canvas(0, 0); |
---|
| 22 | caca_set_color_ansi($canvas, CACA_RED, CACA_WHITE); |
---|
| 23 | caca_import_string($canvas, $pig_str, "text"); |
---|
| 24 | caca_set_color_ansi($canvas, CACA_BLUE, CACA_LIGHTGRAY); |
---|
| 25 | caca_put_str($canvas, 0, 0, "Я люблю Либкаку"); |
---|
| 26 | echo caca_export_string($canvas, "utf8"); |
---|
| 27 | |
---|
| 28 | $font = caca_load_builtin_font("Monospace Bold 12"); |
---|
[3150] | 29 | |
---|
| 30 | $width = caca_get_canvas_width($canvas) * caca_get_font_width($font); |
---|
| 31 | $height = caca_get_canvas_height($canvas) * caca_get_font_height($font); |
---|
| 32 | |
---|
| 33 | $img = imagecreatetruecolor($width, $height); |
---|
| 34 | |
---|
[3149] | 35 | caca_render_canvas($canvas, $font, $img); |
---|
| 36 | |
---|
| 37 | imagepng($img, "out.png"); |
---|
| 38 | echo "Please, open new created png file: out.png\n"; |
---|
| 39 | |
---|
| 40 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.