forked from halo-battle/game
Upgrade jpgrah to 4.3.4
This commit is contained in:
parent
7c3999c5cd
commit
b5868f05f6
72 changed files with 19157 additions and 10327 deletions
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
//=======================================================================
|
||||
// File: JPGRAPH_PLOTMARK.PHP
|
||||
// Description: Class file. Handles plotmarks
|
||||
// Created: 2003-03-21
|
||||
// Ver: $Id: jpgraph_plotmark.inc.php 956 2007-11-17 13:19:20Z ljp $
|
||||
// File: JPGRAPH_PLOTMARK.PHP
|
||||
// Description: Class file. Handles plotmarks
|
||||
// Created: 2003-03-21
|
||||
// Ver: $Id: jpgraph_plotmark.inc.php 1106 2009-02-22 20:16:35Z ljp $
|
||||
//
|
||||
// Copyright (c) Aditus Consulting. All rights reserved.
|
||||
// Copyright (c) Asial Corporation. All rights reserved.
|
||||
//========================================================================
|
||||
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ class PlotMark
|
|||
|
||||
//--------------
|
||||
// CONSTRUCTOR
|
||||
public function PlotMark()
|
||||
public function __construct()
|
||||
{
|
||||
$this->title = new Text();
|
||||
$this->title->Hide();
|
||||
|
|
@ -62,7 +62,7 @@ class PlotMark
|
|||
$this->iFileName = $aFileName;
|
||||
$this->iScale = $aScale;
|
||||
}
|
||||
|
||||
|
||||
public function SetCallback($aFunc)
|
||||
{
|
||||
$this->iFormatCallback = $aFunc;
|
||||
|
|
@ -72,17 +72,17 @@ class PlotMark
|
|||
{
|
||||
$this->iFormatCallback2 = $aFunc;
|
||||
}
|
||||
|
||||
|
||||
public function GetType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
|
||||
public function SetColor($aColor)
|
||||
{
|
||||
$this->color=$aColor;
|
||||
}
|
||||
|
||||
|
||||
public function SetFillColor($aFillColor)
|
||||
{
|
||||
$this->fill_color = $aFillColor;
|
||||
|
|
@ -98,7 +98,7 @@ class PlotMark
|
|||
{
|
||||
$this->width=$aWidth;
|
||||
}
|
||||
|
||||
|
||||
public function SetWidth($aWidth)
|
||||
{
|
||||
$this->width=$aWidth;
|
||||
|
|
@ -107,25 +107,25 @@ class PlotMark
|
|||
public function SetDefaultWidth()
|
||||
{
|
||||
switch ($this->type) {
|
||||
case MARK_CIRCLE:
|
||||
case MARK_FILLEDCIRCLE:
|
||||
$this->width=4;
|
||||
break;
|
||||
default:
|
||||
$this->width=7;
|
||||
case MARK_CIRCLE:
|
||||
case MARK_FILLEDCIRCLE:
|
||||
$this->width=4;
|
||||
break;
|
||||
default:
|
||||
$this->width=7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function GetWidth()
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
|
||||
public function Hide($aHide=true)
|
||||
{
|
||||
$this->show = !$aHide;
|
||||
}
|
||||
|
||||
|
||||
public function Show($aShow=true)
|
||||
{
|
||||
$this->show = $aShow;
|
||||
|
|
@ -136,23 +136,23 @@ class PlotMark
|
|||
$this->yvalue=$aY;
|
||||
$this->xvalue=$aX;
|
||||
}
|
||||
|
||||
|
||||
public function SetCSIMTarget($aTarget, $aWinTarget='')
|
||||
{
|
||||
$this->csimtarget=$aTarget;
|
||||
$this->csimwintarget=$aWinTarget;
|
||||
}
|
||||
|
||||
|
||||
public function SetCSIMAlt($aAlt)
|
||||
{
|
||||
$this->csimalt=$aAlt;
|
||||
}
|
||||
|
||||
|
||||
public function GetCSIMAreas()
|
||||
{
|
||||
return $this->csimareas;
|
||||
}
|
||||
|
||||
|
||||
public function AddCSIMPoly($aPts)
|
||||
{
|
||||
$coords = round($aPts[0]).", ".round($aPts[1]);
|
||||
|
|
@ -175,7 +175,7 @@ class PlotMark
|
|||
$this->csimareas .= " />\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function AddCSIMCircle($x, $y, $r)
|
||||
{
|
||||
$x = round($x);
|
||||
|
|
@ -196,7 +196,7 @@ class PlotMark
|
|||
$this->csimareas .= " />\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function Stroke($img, $x, $y)
|
||||
{
|
||||
if (!$this->show) {
|
||||
|
|
@ -241,91 +241,91 @@ class PlotMark
|
|||
($this->type >= MARK_FLAG1 && $this->type <= MARK_FLAG4) ||
|
||||
$this->type >= MARK_IMG_PUSHPIN) {
|
||||
|
||||
// Note: For the builtin images we use the "filename" parameter
|
||||
// Note: For the builtin images we use the "filename" parameter
|
||||
// to denote the color
|
||||
$anchor_x = 0.5;
|
||||
$anchor_y = 0.5;
|
||||
switch ($this->type) {
|
||||
case MARK_FLAG1:
|
||||
case MARK_FLAG2:
|
||||
case MARK_FLAG3:
|
||||
case MARK_FLAG4:
|
||||
$this->markimg = FlagCache::GetFlagImgByName($this->type-MARK_FLAG1+1, $filename);
|
||||
break;
|
||||
case MARK_FLAG1:
|
||||
case MARK_FLAG2:
|
||||
case MARK_FLAG3:
|
||||
case MARK_FLAG4:
|
||||
$this->markimg = FlagCache::GetFlagImgByName($this->type-MARK_FLAG1+1, $filename);
|
||||
break;
|
||||
|
||||
case MARK_IMG:
|
||||
// Load an image and use that as a marker
|
||||
// Small optimization, if we have already read an image don't
|
||||
// waste time reading it again.
|
||||
if ($this->markimg == '' || !($this->oldfilename === $filename)) {
|
||||
$this->markimg = Graph::LoadBkgImage('', $filename);
|
||||
$this->oldfilename = $filename ;
|
||||
}
|
||||
break;
|
||||
case MARK_IMG:
|
||||
// Load an image and use that as a marker
|
||||
// Small optimization, if we have already read an image don't
|
||||
// waste time reading it again.
|
||||
if ($this->markimg == '' || !($this->oldfilename === $filename)) {
|
||||
$this->markimg = Graph::LoadBkgImage('', $filename);
|
||||
$this->oldfilename = $filename ;
|
||||
}
|
||||
break;
|
||||
|
||||
case MARK_IMG_PUSHPIN:
|
||||
case MARK_IMG_SPUSHPIN:
|
||||
case MARK_IMG_LPUSHPIN:
|
||||
if ($this->imgdata_pushpins == null) {
|
||||
require_once 'imgdata_pushpins.inc.php';
|
||||
$this->imgdata_pushpins = new ImgData_PushPins();
|
||||
}
|
||||
$this->markimg = $this->imgdata_pushpins->GetImg($this->type, $filename);
|
||||
list($anchor_x, $anchor_y) = $this->imgdata_pushpins->GetAnchor();
|
||||
break;
|
||||
case MARK_IMG_PUSHPIN:
|
||||
case MARK_IMG_SPUSHPIN:
|
||||
case MARK_IMG_LPUSHPIN:
|
||||
if ($this->imgdata_pushpins == null) {
|
||||
require_once 'imgdata_pushpins.inc.php';
|
||||
$this->imgdata_pushpins = new ImgData_PushPins();
|
||||
}
|
||||
$this->markimg = $this->imgdata_pushpins->GetImg($this->type, $filename);
|
||||
list($anchor_x, $anchor_y) = $this->imgdata_pushpins->GetAnchor();
|
||||
break;
|
||||
|
||||
case MARK_IMG_SQUARE:
|
||||
if ($this->imgdata_squares == null) {
|
||||
require_once 'imgdata_squares.inc.php';
|
||||
$this->imgdata_squares = new ImgData_Squares();
|
||||
}
|
||||
$this->markimg = $this->imgdata_squares->GetImg($this->type, $filename);
|
||||
list($anchor_x, $anchor_y) = $this->imgdata_squares->GetAnchor();
|
||||
break;
|
||||
case MARK_IMG_SQUARE:
|
||||
if ($this->imgdata_squares == null) {
|
||||
require_once 'imgdata_squares.inc.php';
|
||||
$this->imgdata_squares = new ImgData_Squares();
|
||||
}
|
||||
$this->markimg = $this->imgdata_squares->GetImg($this->type, $filename);
|
||||
list($anchor_x, $anchor_y) = $this->imgdata_squares->GetAnchor();
|
||||
break;
|
||||
|
||||
case MARK_IMG_STAR:
|
||||
if ($this->imgdata_stars == null) {
|
||||
require_once 'imgdata_stars.inc.php';
|
||||
$this->imgdata_stars = new ImgData_Stars();
|
||||
}
|
||||
$this->markimg = $this->imgdata_stars->GetImg($this->type, $filename);
|
||||
list($anchor_x, $anchor_y) = $this->imgdata_stars->GetAnchor();
|
||||
break;
|
||||
case MARK_IMG_STAR:
|
||||
if ($this->imgdata_stars == null) {
|
||||
require_once 'imgdata_stars.inc.php';
|
||||
$this->imgdata_stars = new ImgData_Stars();
|
||||
}
|
||||
$this->markimg = $this->imgdata_stars->GetImg($this->type, $filename);
|
||||
list($anchor_x, $anchor_y) = $this->imgdata_stars->GetAnchor();
|
||||
break;
|
||||
|
||||
case MARK_IMG_BEVEL:
|
||||
if ($this->imgdata_bevels == null) {
|
||||
require_once 'imgdata_bevels.inc.php';
|
||||
$this->imgdata_bevels = new ImgData_Bevels();
|
||||
}
|
||||
$this->markimg = $this->imgdata_bevels->GetImg($this->type, $filename);
|
||||
list($anchor_x, $anchor_y) = $this->imgdata_bevels->GetAnchor();
|
||||
break;
|
||||
case MARK_IMG_BEVEL:
|
||||
if ($this->imgdata_bevels == null) {
|
||||
require_once 'imgdata_bevels.inc.php';
|
||||
$this->imgdata_bevels = new ImgData_Bevels();
|
||||
}
|
||||
$this->markimg = $this->imgdata_bevels->GetImg($this->type, $filename);
|
||||
list($anchor_x, $anchor_y) = $this->imgdata_bevels->GetAnchor();
|
||||
break;
|
||||
|
||||
case MARK_IMG_DIAMOND:
|
||||
if ($this->imgdata_diamonds == null) {
|
||||
require_once 'imgdata_diamonds.inc.php';
|
||||
$this->imgdata_diamonds = new ImgData_Diamonds();
|
||||
}
|
||||
$this->markimg = $this->imgdata_diamonds->GetImg($this->type, $filename);
|
||||
list($anchor_x, $anchor_y) = $this->imgdata_diamonds->GetAnchor();
|
||||
break;
|
||||
case MARK_IMG_DIAMOND:
|
||||
if ($this->imgdata_diamonds == null) {
|
||||
require_once 'imgdata_diamonds.inc.php';
|
||||
$this->imgdata_diamonds = new ImgData_Diamonds();
|
||||
}
|
||||
$this->markimg = $this->imgdata_diamonds->GetImg($this->type, $filename);
|
||||
list($anchor_x, $anchor_y) = $this->imgdata_diamonds->GetAnchor();
|
||||
break;
|
||||
|
||||
case MARK_IMG_BALL:
|
||||
case MARK_IMG_SBALL:
|
||||
case MARK_IMG_MBALL:
|
||||
case MARK_IMG_LBALL:
|
||||
if ($this->imgdata_balls == null) {
|
||||
require_once 'imgdata_balls.inc.php';
|
||||
$this->imgdata_balls = new ImgData_Balls();
|
||||
case MARK_IMG_BALL:
|
||||
case MARK_IMG_SBALL:
|
||||
case MARK_IMG_MBALL:
|
||||
case MARK_IMG_LBALL:
|
||||
if ($this->imgdata_balls == null) {
|
||||
require_once 'imgdata_balls.inc.php';
|
||||
$this->imgdata_balls = new ImgData_Balls();
|
||||
}
|
||||
$this->markimg = $this->imgdata_balls->GetImg($this->type, $filename);
|
||||
list($anchor_x, $anchor_y) = $this->imgdata_balls->GetAnchor();
|
||||
break;
|
||||
}
|
||||
$this->markimg = $this->imgdata_balls->GetImg($this->type, $filename);
|
||||
list($anchor_x, $anchor_y) = $this->imgdata_balls->GetAnchor();
|
||||
break;
|
||||
}
|
||||
|
||||
$w = $img->GetWidth($this->markimg);
|
||||
$h = $img->GetHeight($this->markimg);
|
||||
|
||||
|
||||
$dw = round($imgscale * $w);
|
||||
$dh = round($imgscale * $h);
|
||||
|
||||
|
|
@ -334,15 +334,15 @@ class PlotMark
|
|||
|
||||
$dx = round($x-$dw*$anchor_x);
|
||||
$dy = round($y-$dh*$anchor_y);
|
||||
|
||||
|
||||
$this->width = max($dx, $dy);
|
||||
|
||||
|
||||
$img->Copy($this->markimg, $dx, $dy, 0, 0, $dw, $dh, $w, $h);
|
||||
if (!empty($this->csimtarget)) {
|
||||
$this->csimareas = "<area shape=\"rect\" coords=\"".
|
||||
$dx.','.$dy.','.round($dx+$dw).','.round($dy+$dh).'" '.
|
||||
"href=\"".htmlentities($this->csimtarget)."\"";
|
||||
|
||||
$dx.','.$dy.','.round($dx+$dw).','.round($dy+$dh).'" '.
|
||||
"href=\"".htmlentities($this->csimtarget)."\"";
|
||||
|
||||
if (!empty($this->csimwintarget)) {
|
||||
$this->csimareas .= " target=\"".$this->csimwintarget."\" ";
|
||||
}
|
||||
|
|
@ -353,7 +353,7 @@ class PlotMark
|
|||
}
|
||||
$this->csimareas .= " />\n";
|
||||
}
|
||||
|
||||
|
||||
// Stroke title
|
||||
$this->title->Align("center", "top");
|
||||
$this->title->Stroke($img, $x, $y+round($dh/2));
|
||||
|
|
@ -366,65 +366,65 @@ class PlotMark
|
|||
$pts=0;
|
||||
|
||||
switch ($this->type) {
|
||||
case MARK_SQUARE:
|
||||
$c[]=$x-$dx;$c[]=$y-$dy;
|
||||
$c[]=$x+$dx;$c[]=$y-$dy;
|
||||
$c[]=$x+$dx;$c[]=$y+$dy;
|
||||
$c[]=$x-$dx;$c[]=$y+$dy;
|
||||
$c[]=$x-$dx;$c[]=$y-$dy;
|
||||
$pts=5;
|
||||
break;
|
||||
case MARK_UTRIANGLE:
|
||||
++$dx;++$dy;
|
||||
$c[]=$x-$dx;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
|
||||
$c[]=$x;$c[]=$y-0.87*$dy;
|
||||
$c[]=$x+$dx;$c[]=$y+0.87*$dy;
|
||||
$c[]=$x-$dx;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
|
||||
$pts=4;
|
||||
break;
|
||||
case MARK_DTRIANGLE:
|
||||
++$dx;++$dy;
|
||||
$c[]=$x;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
|
||||
$c[]=$x-$dx;$c[]=$y-0.87*$dy;
|
||||
$c[]=$x+$dx;$c[]=$y-0.87*$dy;
|
||||
$c[]=$x;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
|
||||
$pts=4;
|
||||
break;
|
||||
case MARK_DIAMOND:
|
||||
$c[]=$x;$c[]=$y+$dy;
|
||||
$c[]=$x-$dx;$c[]=$y;
|
||||
$c[]=$x;$c[]=$y-$dy;
|
||||
$c[]=$x+$dx;$c[]=$y;
|
||||
$c[]=$x;$c[]=$y+$dy;
|
||||
$pts=5;
|
||||
break;
|
||||
case MARK_LEFTTRIANGLE:
|
||||
$c[]=$x;$c[]=$y;
|
||||
$c[]=$x;$c[]=$y+2*$dy;
|
||||
$c[]=$x+$dx*2;$c[]=$y;
|
||||
$c[]=$x;$c[]=$y;
|
||||
$pts=4;
|
||||
break;
|
||||
case MARK_RIGHTTRIANGLE:
|
||||
$c[]=$x-$dx*2;$c[]=$y;
|
||||
$c[]=$x;$c[]=$y+2*$dy;
|
||||
$c[]=$x;$c[]=$y;
|
||||
$c[]=$x-$dx*2;$c[]=$y;
|
||||
$pts=4;
|
||||
break;
|
||||
case MARK_FLASH:
|
||||
$dy *= 2;
|
||||
$c[]=$x+$dx/2; $c[]=$y-$dy;
|
||||
$c[]=$x-$dx+$dx/2; $c[]=$y+$dy*0.7-$dy;
|
||||
$c[]=$x+$dx/2; $c[]=$y+$dy*1.3-$dy;
|
||||
$c[]=$x-$dx+$dx/2; $c[]=$y+2*$dy-$dy;
|
||||
$img->SetLineWeight($weight);
|
||||
$img->SetColor($color);
|
||||
$img->Polygon($c);
|
||||
$img->SetLineWeight(1);
|
||||
$this->AddCSIMPoly($c);
|
||||
break;
|
||||
}
|
||||
case MARK_SQUARE:
|
||||
$c[]=$x-$dx;$c[]=$y-$dy;
|
||||
$c[]=$x+$dx;$c[]=$y-$dy;
|
||||
$c[]=$x+$dx;$c[]=$y+$dy;
|
||||
$c[]=$x-$dx;$c[]=$y+$dy;
|
||||
$c[]=$x-$dx;$c[]=$y-$dy;
|
||||
$pts=5;
|
||||
break;
|
||||
case MARK_UTRIANGLE:
|
||||
++$dx;++$dy;
|
||||
$c[]=$x-$dx;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
|
||||
$c[]=$x;$c[]=$y-0.87*$dy;
|
||||
$c[]=$x+$dx;$c[]=$y+0.87*$dy;
|
||||
$c[]=$x-$dx;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
|
||||
$pts=4;
|
||||
break;
|
||||
case MARK_DTRIANGLE:
|
||||
++$dx;++$dy;
|
||||
$c[]=$x;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
|
||||
$c[]=$x-$dx;$c[]=$y-0.87*$dy;
|
||||
$c[]=$x+$dx;$c[]=$y-0.87*$dy;
|
||||
$c[]=$x;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
|
||||
$pts=4;
|
||||
break;
|
||||
case MARK_DIAMOND:
|
||||
$c[]=$x;$c[]=$y+$dy;
|
||||
$c[]=$x-$dx;$c[]=$y;
|
||||
$c[]=$x;$c[]=$y-$dy;
|
||||
$c[]=$x+$dx;$c[]=$y;
|
||||
$c[]=$x;$c[]=$y+$dy;
|
||||
$pts=5;
|
||||
break;
|
||||
case MARK_LEFTTRIANGLE:
|
||||
$c[]=$x;$c[]=$y;
|
||||
$c[]=$x;$c[]=$y+2*$dy;
|
||||
$c[]=$x+$dx*2;$c[]=$y;
|
||||
$c[]=$x;$c[]=$y;
|
||||
$pts=4;
|
||||
break;
|
||||
case MARK_RIGHTTRIANGLE:
|
||||
$c[]=$x-$dx*2;$c[]=$y;
|
||||
$c[]=$x;$c[]=$y+2*$dy;
|
||||
$c[]=$x;$c[]=$y;
|
||||
$c[]=$x-$dx*2;$c[]=$y;
|
||||
$pts=4;
|
||||
break;
|
||||
case MARK_FLASH:
|
||||
$dy *= 2;
|
||||
$c[]=$x+$dx/2; $c[]=$y-$dy;
|
||||
$c[]=$x-$dx+$dx/2; $c[]=$y+$dy*0.7-$dy;
|
||||
$c[]=$x+$dx/2; $c[]=$y+$dy*1.3-$dy;
|
||||
$c[]=$x-$dx+$dx/2; $c[]=$y+2*$dy-$dy;
|
||||
$img->SetLineWeight($weight);
|
||||
$img->SetColor($color);
|
||||
$img->Polygon($c);
|
||||
$img->SetLineWeight(1);
|
||||
$this->AddCSIMPoly($c);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($pts>0) {
|
||||
$this->AddCSIMPoly($c);
|
||||
|
|
@ -467,7 +467,7 @@ class PlotMark
|
|||
$img->Line($x-$dx-1, $y, $x+$dx+1, $y);
|
||||
$this->AddCSIMCircle($x, $y, $dx+$dy);
|
||||
}
|
||||
|
||||
|
||||
// Stroke title
|
||||
$this->title->Align("center", "center");
|
||||
$this->title->Stroke($img, $x, $y);
|
||||
|
|
@ -483,13 +483,19 @@ class PlotMark
|
|||
//========================================================================
|
||||
class ImgData
|
||||
{
|
||||
protected $name = ''; // Each subclass gives a name
|
||||
protected $an = array(); // Data array names
|
||||
protected $colors = array(); // Available colors
|
||||
protected $index = array(); // Index for colors
|
||||
protected $maxidx = 0 ; // Max color index
|
||||
protected $name = ''; // Each subclass gives a name
|
||||
protected $an = array(); // Data array names
|
||||
protected $colors = array(); // Available colors
|
||||
protected $index = array(); // Index for colors
|
||||
protected $maxidx = 0 ; // Max color index
|
||||
protected $anchor_x=0.5;
|
||||
protected $anchor_y=0.5 ; // Where is the center of the image
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
// Create a GD image from the data and return a GD handle
|
||||
public function GetImg($aMark, $aIdx)
|
||||
{
|
||||
|
|
@ -507,6 +513,7 @@ class ImgData
|
|||
}
|
||||
return Image::CreateFromString(base64_decode($this->{$n}[$idx][1]));
|
||||
}
|
||||
|
||||
public function GetAnchor()
|
||||
{
|
||||
return array($this->anchor_x,$this->anchor_y);
|
||||
|
|
@ -516,10 +523,10 @@ class ImgData
|
|||
|
||||
// Keep a global flag cache to reduce memory usage
|
||||
$_gFlagCache=array(
|
||||
1 => null,
|
||||
2 => null,
|
||||
3 => null,
|
||||
4 => null,
|
||||
1 => null,
|
||||
2 => null,
|
||||
3 => null,
|
||||
4 => null,
|
||||
);
|
||||
// Only supposed to b called as statics
|
||||
class FlagCache
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue