patrickbussmann/shooting-target

Draw shooting targets with hits based on coordinate system

1.0.1 2017-08-18 16:47 UTC

This package is auto-updated.

Last update: 2024-10-19 03:02:15 UTC


README

Build Status Latest Stable Version Total Downloads StyleCI codecov.io

The goal was it to display the hits from the www.meyton.org/shooting-data-feed-sdf/ system. The data source is called Shooting Data Feed (SDF) and could be a XML file or a MySQL database.

Installation

With Composer

$ composer require patrickbussmann/shooting-target
{
    "require": {
        "patrickbussmann/shooting-target": "dev-master"
    }
}
<?php

require 'vendor/autoload.php';

use ShootingTarget\Target;
use ShootingTarget\Hit;

Without Composer

$ git clone https://github.com/patrickbussmann/shooting-target.git
<?php

require 'shooting-target/src/Target.php';
require 'shooting-target/src/Hit.php';

use ShootingTarget\Target;
use ShootingTarget\Hit;

Usage

Example Air Rifle 10m (DE: Luftgewehr LG 10m)

$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();

Result

The picture generated by the script above

Example Air Pistol 10m (DE: Luftpistole / LP 10m)

$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);

Result

The picture generated by the script above

Example with custom font

Using a custom font is more better because it will scale up to your selected size.

$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');

Result

The picture generated by the script above

Target list

There are many targets which are compatible with this. Use them as you like. The examples below based on this document from the DSB. This is the reason why the table is in german language.

Contribution

  • Having an issue? or looking for support? Open an issue please.
  • Do you have a new feature or a bug fix? Fork the repo, make your changes, and submit a pull request. Thank you in Advance!

Support

If you like this project please star it 😉