PHP code example of patrickbussmann / shooting-target

1. Go to this page and download the library: Download patrickbussmann/shooting-target library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

patrickbussmann / shooting-target example snippets




hootingTarget\Target;
use ShootingTarget\Hit;



e 'shooting-target/src/Hit.php';

use ShootingTarget\Target;
use ShootingTarget\Hit;

$target = new Target(0.5, 0.5, 2.5, 4, 10);
$target->addHit(new Hit(0, 0));
$target->addHit(new Hit(500, 500));
$target->addHit(new Hit(-500, 500));
$target->addHit(new Hit(500, -500));
$target->addHit(new Hit(-500, -500));
header('Content-Type: image/png');
$target->draw();

$target = new Target(11.5, 5.0, 8.0, 7, 10);
$target->addHit(new Hit(0, 0));
$target->addHit(new Hit(1000, 1000));
$target->addHit(new Hit(-1000, 1000));
$target->addHit(new Hit(1000, -1000));
$target->addHit(new Hit(-1000, -1000));
header('Content-Type: image/png');
$target->draw(10);

$target = new Target(0.5, 0.5, 2.5, 4, 10);
$target->addHit(new Hit(0, 0));
$target->addHit(new Hit(500, 500));
$target->addHit(new Hit(-500, 500));
$target->addHit(new Hit(500, -500));
$target->addHit(new Hit(-500, -500));
header('Content-Type: image/png');
$target->draw(10, Target::DRAW_TYPE_PNG, __DIR__ . '/arial.ttf');