소스 검색

convert to PHP and make executable

tags/v0.99.beta17
Ben Wiley Sittler bsittler 16 년 전
부모
커밋
283ea9423c
1개의 변경된 파일30개의 추가작업 그리고 48개의 파일을 삭제
  1. +30
    -48
      caca-php/examples/truecolor.php

+ 30
- 48
caca-php/examples/truecolor.php 파일 보기

@@ -1,7 +1,13 @@
#!/usr/bin/php5
<?php
/*
* truecolor truecolor canvas features
* truecolor truecolor canvas features
* Copyright (c) 2008 Benjamin C. Wiley Sittler <bsittler@gmail.com>
*
* This file is a Php port of "examples/truecolor.c"
* which is:
* Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
* All Rights Reserved
*
* $Id$
*
@@ -12,55 +18,31 @@
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

#include "config.h"

#if !defined(__KERNEL__)
# include <stdio.h>
#endif

#include "caca.h"

int main(int argc, char *argv[])
{
caca_canvas_t *cv;
caca_display_t *dp;

int x, y;

cv = caca_create_canvas(32, 16);
if(cv == NULL)
{
printf("Failed to create canvas\n");
return 1;
}

dp = caca_create_display(cv);
if(dp == NULL)
{
printf("Failed to create display\n");
return 1;
}

for(y = 0; y < 16; y++)
for(x = 0; x < 16; x++)
{
uint16_t bgcolor = 0xff00 | (y << 4) | x;
uint16_t fgcolor = 0xf000 | ((15 - y) << 4) | ((15 - x) << 8);

caca_set_color_argb(cv, fgcolor, bgcolor);
caca_put_str(cv, x * 2, y, "CA");
}
$cv = caca_create_canvas(32, 16);
if(!$cv) {
die("Failed to create canvas\n");
}

caca_set_color_ansi(cv, CACA_WHITE, CACA_LIGHTBLUE);
caca_put_str(cv, 2, 1, " truecolor libcaca ");
$dp = caca_create_display($cv);
if(!$dp) {
die("Failed to create display\n");
}

caca_refresh_display(dp);
for($y = 0; $y < 16; $y++)
for($x = 0; $x < 16; $x++)
{
$bgcolor = 0xff00 | ($y << 4) | $x;
$fgcolor = 0xf000 | ((15 - $y) << 4) | ((15 - $x) << 8);
caca_set_color_argb($cv, $fgcolor, $bgcolor);
caca_put_str($cv, $x * 2, $y, "CA");
}

caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
caca_set_color_ansi($cv, CACA_WHITE, CACA_LIGHTBLUE);
caca_put_str($cv, 2, 1, " truecolor libcaca ");

caca_free_display(dp);
caca_free_canvas(cv);
caca_refresh_display($dp);

return 0;
}
caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1);

?>

불러오는 중...
취소
저장