PTX PHP GD Analog Clock: Render the time on analog clock as an image

Recommend this page to a friend!
  Info   Example   Demos   View files (17)   Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-02-01 (6 months ago) Not enough user ratingsTotal: 290 All time: 7,398 This week: 255
Version License PHP version Categories
ptx-clock 2GNU Lesser Genera...5.3HTML, PHP 5, Time and Date, Graphics
Description Author

This package can render the time on analog clock as an image.

It takes a time string with hours and minutes and renders an image displaying the pointers on circular analog clock.

There are two class variants: one that draws the clock pointers inside a circle and that renders the pointers over a base background image.

The resulting image can be saved to a PNG file or outputted as the current script output.

Innovation Award
PHP Programming Innovation award nominee
May 2015
Number 15
Many applications need to display the current time. They usually display a text string with the time, but sometimes it is nicer to display the time as a drawing of an analog clock.

This class can display the current time as an analog clock rendered as an image that can be displayed on the browser.

Manuel Lemos
Picture of Tomas Pavlatka
  Performance   Level  
Name: Tomas Pavlatka <contact>
Classes: 3 packages by
Country: Czech Republic Czech Republic
Age: 37
All time rank: 224026 in Czech Republic Czech Republic
Week rank: 713 9 in Czech Republic Czech Republic
Innovation award
Innovation award
Nominee: 2x

Details

PTX-Clock

PHP Class to create analog clock from the time given. I have a son and they are teaching him at school the clock. I though it would be great to create a simple game to help him out. This class is just a beginning of the whole idea.

Installation

You will need a composer to install autoload for you

composer install --no-dev

Example

require_once './vendor/autoload.php';

try {
    $clock = new PTX\Clock('09:55');
    $clock->draw();
    $clock->to_browser();
} catch(\PTX\ClockException $e) {
    echo $e->getMessage();
}

Example online

Visit my page and see it in action.

  PTX Clock  

Open in a separate window

  Files  
File Role Description
cache (1 file)
example (2 files, 3 directories)
fonts (1 directory)
src (1 directory)
tests (2 files)
canvas.php Example Example script
composer.json Data Auxiliary data
index.php Example Example script
LICENSE Lic. Auxiliary data
README.md Doc. Auxiliary data

  Files  /  cache  
File Role Description
   empty Data Auxiliary data

  Files  /  example  
File Role Description
cache (1 file)
css (1 file)
js (1 file)
   clock.php Example Example script
   index.php Example Example script

  Files  /  example  /  cache  
File Role Description
   empty Data Auxiliary data

  Files  /  example  /  css  
File Role Description
   ptx.css Data Auxiliary data

  Files  /  example  /  js  
File Role Description
   ptx.js Data Auxiliary data

  Files  /  fonts  
File Role Description
ennobled (1 file)

  Files  /  fonts  /  ennobled  
File Role Description
   read_me.html Data Fonts license

  Files  /  src  
File Role Description
ptx (3 files)

  Files  /  src  /  ptx  
File Role Description
   Clock.php Class Class source
   ClockCanvas.php Class Class source
   ClockException.php Class Class source

  Files  /  tests  
File Role Description
   ClockBaseTest.php Test Unit test script
   ClockTest.php Test Unit test script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:290
This week:0
All time:7,398
This week:255

For more information send a message to info at phpclasses dot org.