Example #1
0
$img->startY = 305;
$panel->addImage($img);
$img = new \TopiLib\TopiImage(dirname(__FILE__) . './p8.png', 'png');
$img->startX = 300;
$img->startY = 175;
$panel->addImage($img);
$img = new \TopiLib\TopiImage(dirname(__FILE__) . './p9.png', 'png');
$img->startX = 273;
$img->startY = 98;
$panel->addImage($img);
$img = new \TopiLib\TopiImage(dirname(__FILE__) . './border.png', 'png');
$img->startX = 63;
$img->startY = 72;
$panel->addImage($img);
// Add styled text to panel
$txt = new \TopiLib\TopiText('../font.ttf', 'Puzzle', 3, 25, 24, 36);
$txt->settxtHexColor('#fff');
$txt->startX = 200;
$txt->startY = 27;
$panel->addText($txt);
$txt = new \TopiLib\TopiText('../font.ttf', 'Puzzle Sample - Topi Lib - version 1.3.1', 3, 60, 12, 36);
$txt->settxtHexColor('#fff');
$txt->startX = 32;
$txt->startY = 457;
$panel->addText($txt);
$img = new \TopiLib\TopiImage('../topilib.png', 'png');
$img->position = 'left-bottom';
$panel->addImage($img);
// Render image
//$panel->renderToImage('./des.png');
$panel->render();
Example #2
0
    // Create panel
    $panel = new \TopiLib\TopiPanel('jpeg', 60, 255, 255, 255);
    $panel->txtLMagicMagnet = true;
    $panel->txtTMagicMagnet = true;
    $panel->txtRMagicMagnet = true;
    $panel->txtBMagicMagnet = true;
    $panel->txtLMagicMagnetTol = 10;
    $panel->createBlank(300, 200);
    // Pick random background, get info, and start captcha
    $background = $captcha_config['backgrounds'][rand(0, count($captcha_config['backgrounds']) - 1)];
    $image = new \TopiLib\TopiImage($background, 'png');
    $image->position = 'tile';
    $panel->addImage($image);
    // Determine text angle
    $angle = rand($captcha_config['angle_min'], $captcha_config['angle_max']) * (rand(0, 1) == 1 ? -1 : 1);
    // Select font randomly
    $font = $captcha_config['fonts'][rand(0, count($captcha_config['fonts']) - 1)];
    // Verify font file exists
    if (!file_exists($font)) {
        throw new Exception('Font file not found: ' . $font);
    }
    //Set the font size.
    $font_size = rand($captcha_config['min_font_size'], $captcha_config['max_font_size']);
    $text1 = new \TopiLib\TopiText($font, $captcha_config['code'], 1, $captcha_config['max_font_size'] + 1, $font_size, $font_size);
    $text1->rotation = $angle;
    $text1->settxtHexColor($captcha_config['color']);
    $text1->startY = 20;
    $text1->startX = 20;
    $panel->addText($text1);
    $panel->render();
}
Example #3
0
$txt->startX = 150;
$txt->startY = 145;
$panel->addText($txt);
$txt = new \TopiLib\TopiText('../font.ttf', 'Abdi Khojasteh', 1, 15, 24, 24);
$txt->settxtHexColor('#fff');
$txt->startX = 150;
$txt->startY = 165;
$panel->addText($txt);
$txt = new \TopiLib\TopiText('../font1.otf', 'Example Public Library', 3, 12, 15, 18);
$txt->settxtHexColor('#fff');
$txt->startX = 370;
$txt->startY = 285;
$panel->addText($txt);
$txt = new \TopiLib\TopiText('../font1.otf', 'www.example.org', 1, 20, 15, 18);
$txt->settxtHexColor('#fff');
$txt->startX = 55;
$txt->startY = 317;
$panel->addText($txt);
$txt = new \TopiLib\TopiText('../font.ttf', 'EXPIRES: 16/12', 1, 20, 16, 18);
$txt->settxtHexColor('#fff');
$txt->startX = 55;
$txt->startY = 293;
$panel->addText($txt);
$txt = new \TopiLib\TopiText('../font.ttf', 'Library Card Sample - Topi Lib - version 1.3.1', 3, 60, 12, 36);
$txt->settxtHexColor('#969696');
$txt->startX = 32;
$txt->startY = 456;
$panel->addText($txt);
// Render image
//$panel->renderToImage('./des.jpg');
$panel->render();