[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/mambots/editors/mostlyce/jscripts/tiny_mce/filemanager/js/ -> wz_jsgraphics.js (source)

   1  /*
   2   * FCKeditor - The text editor for internet
   3   * Copyright (C) 2003-2005 Frederico Caldeira Knabben
   4   * 
   5   * Licensed under the terms of the GNU Lesser General Public License:
   6   *         http://www.opensource.org/licenses/lgpl-license.php
   7   * 
   8   * For further information visit:
   9   *         http://www.fckeditor.net/
  10   * 
  11   * File Name: wz_jsgraphics.js
  12   *     Javascript Graphics.
  13   * 
  14   * File Authors:
  15   *         Grant French (grant@mcpuk.net)
  16   */
  17  /***********************************************************************
  18  ** Title.........:  Javascript Graphics
  19  ** Version.......:  1.0
  20  ** Author........:  Xiang Wei ZHUO <wei@zhuo.org>
  21  ** Filename......:  wz_jsgraphics.js
  22  ** Last changed..:  31 Aug 2003  
  23  ** Notes.........:  Modified for Image Editor, added extra commands
  24  **/ 
  25  
  26  /* This notice must be untouched at all times.
  27  
  28  wz_jsgraphics.js    v. 2.03
  29  The latest version is available at
  30  http://www.walterzorn.com
  31  or http://www.devira.com
  32  or http://www.walterzorn.de
  33  
  34  Copyright (c) 2002-2003 Walter Zorn. All rights reserved.
  35  Created 3. 11. 2002 by Walter Zorn <walter@kreuzotter.de>
  36  Last modified: 11. 6. 2003
  37  
  38  High Performance JavaScript Graphics Library.
  39  Provides methods
  40  - to draw lines, rectangles, ellipses, polygons
  41    with specifiable line thickness,
  42  - to fill rectangles and ellipses
  43  - to draw text.
  44  NOTE: Operations, functions and branching have rather been optimized
  45  to efficiency and speed than to shortness of source code.
  46  
  47  This program is free software;
  48  you can redistribute it and/or modify it under the terms of the
  49  GNU General Public License as published by the Free Software Foundation;
  50  either version 2 of the License, or (at your option) any later version.
  51  This program is distributed in the hope that it will be useful,
  52  but WITHOUT ANY WARRANTY;
  53  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  54  See the GNU General Public License
  55  at http://www.opensource.org/licenses/gpl-2.0.php for more details.
  56  */
  57  
  58  var jg_ihtm, jg_ie, jg_dom,
  59  jg_n4 = (document.layers && typeof document.classes != "undefined");
  60  
  61  function chkDHTM(x, i)
  62  {
  63      x = document.body || null;
  64      jg_ie = (x && typeof x.insertAdjacentHTML != "undefined");
  65      jg_dom = (x && !jg_ie &&
  66          typeof x.appendChild != "undefined" &&
  67          typeof document.createRange != "undefined" &&
  68          typeof (i = document.createRange()).setStartBefore != "undefined" &&
  69          typeof i.createContextualFragment != "undefined");
  70      jg_ihtm = (!jg_ie && !jg_dom && x && typeof x.innerHTML != "undefined");
  71  }
  72  
  73  
  74  
  75  
  76  
  77  function pntDoc()
  78  {
  79      this.wnd.document.write(this.htm);
  80      this.htm = '';
  81  }
  82  
  83  
  84  
  85  
  86  
  87  function pntCnvDom()
  88  {
  89      var x = document.createRange();
  90      x.setStartBefore(this.cnv);
  91      x = x.createContextualFragment(this.htm);
  92      this.cnv.appendChild(x);
  93      this.htm = '';
  94  }
  95  
  96  
  97  
  98  
  99  
 100  function pntCnvIe()
 101  {
 102      this.cnv.insertAdjacentHTML("BeforeEnd", this.htm);
 103      this.htm = '';
 104  }
 105  
 106  
 107  
 108  
 109  
 110  function pntCnvIhtm()
 111  {
 112      this.cnv.innerHTML += this.htm;
 113      this.htm = '';
 114  }
 115  
 116  
 117  
 118  
 119  
 120  function pntCnv()
 121  {
 122      this.htm = '';
 123  }
 124  
 125  
 126  
 127  
 128  
 129  function mkDiv(x, y, w, h)
 130  {
 131      this.htm += '<div style="position:absolute;'+
 132          'left:' + x + 'px;'+
 133          'top:' + y + 'px;'+
 134          'width:' + w + 'px;'+
 135          'height:' + h + 'px;'+
 136          'clip:rect(0,'+w+'px,'+h+'px,0);'+
 137          'overflow:hidden;background-color:' + this.color + ';'+
 138          '"><\/div>';
 139  
 140      //alert(this.htm);
 141  }
 142  
 143  
 144  
 145  
 146  function mkDivPrint(x, y, w, h)
 147  {
 148      this.htm += '<div style="position:absolute;'+
 149          'border-left:' + w + 'px solid ' + this.color + ';'+
 150          'left:' + x + 'px;'+
 151          'top:' + y + 'px;'+
 152          'width:' + w + 'px;'+
 153          'height:' + h + 'px;'+
 154          'clip:rect(0,'+w+'px,'+h+'px,0);'+
 155          'overflow:hidden;background-color:' + this.color + ';'+
 156          '"><\/div>';
 157  }
 158  
 159  
 160  
 161  
 162  
 163  function mkLyr(x, y, w, h)
 164  {
 165      this.htm += '<layer '+
 166          'left="' + x + '" '+
 167          'top="' + y + '" '+
 168          'width="' + w + '" '+
 169          'height="' + h + '" '+
 170          'bgcolor="' + this.color + '"><\/layer>\n';
 171  }
 172  
 173  
 174  
 175  
 176  
 177  function mkLbl(txt, x, y)
 178  {
 179      this.htm += '<div style="position:absolute;white-space:nowrap;'+
 180          'left:' + x + 'px;'+
 181          'top:' + y + 'px;'+
 182          'font-family:' +  this.ftFam + ';'+
 183          'font-size:' + this.ftSz + ';'+
 184          'color:' + this.color + ';' + this.ftSty + '">'+
 185          txt +
 186          '<\/div>';
 187  }
 188  
 189  
 190  
 191  
 192  
 193  function mkLin(x1, y1, x2, y2)
 194  {
 195      if (x1 > x2)
 196      {
 197          var _x2 = x2;
 198          var _y2 = y2;
 199          x2 = x1;
 200          y2 = y1;
 201          x1 = _x2;
 202          y1 = _y2;
 203      }
 204      var dx = x2-x1, dy = Math.abs(y2-y1),
 205      x = x1, y = y1,
 206      yIncr = (y1 > y2)? -1 : 1;
 207  
 208      if (dx >= dy)
 209      {
 210          var pr = dy<<1,
 211          pru = pr - (dx<<1),
 212          p = pr-dx,
 213          ox = x;
 214          while ((dx--) > 0)
 215          {
 216              ++x;
 217              if (p > 0)
 218              {
 219                  this.mkDiv(ox, y, x-ox, 1);
 220                  y += yIncr;
 221                  p += pru;
 222                  ox = x;
 223              }
 224              else p += pr;
 225          }
 226          this.mkDiv(ox, y, x2-ox+1, 1);
 227      }
 228  
 229      else
 230      {
 231          var pr = dx<<1,
 232          pru = pr - (dy<<1),
 233          p = pr-dy,
 234          oy = y;
 235          if (y2 <= y1)
 236          {
 237              while ((dy--) > 0)
 238              {
 239                  if (p > 0)
 240                  {
 241                      this.mkDiv(x++, y, 1, oy-y+1);
 242                      y += yIncr;
 243                      p += pru;
 244                      oy = y;
 245                  }
 246                  else
 247                  {
 248                      y += yIncr;
 249                      p += pr;
 250                  }
 251              }
 252              this.mkDiv(x2, y2, 1, oy-y2+1);
 253          }
 254          else
 255          {
 256              while ((dy--) > 0)
 257              {
 258                  y += yIncr;
 259                  if (p > 0)
 260                  {
 261                      this.mkDiv(x++, oy, 1, y-oy);
 262                      p += pru;
 263                      oy = y;
 264                  }
 265                  else p += pr;
 266              }
 267              this.mkDiv(x2, oy, 1, y2-oy+1);
 268          }
 269      }
 270  }
 271  
 272  
 273  
 274  
 275  
 276  function mkLin2D(x1, y1, x2, y2)
 277  {
 278      if (x1 > x2)
 279      {
 280          var _x2 = x2;
 281          var _y2 = y2;
 282          x2 = x1;
 283          y2 = y1;
 284          x1 = _x2;
 285          y1 = _y2;
 286      }
 287      var dx = x2-x1, dy = Math.abs(y2-y1),
 288      x = x1, y = y1,
 289      yIncr = (y1 > y2)? -1 : 1;
 290  
 291  
 292      var s = this.stroke;
 293      if (dx >= dy)
 294      {
 295          if (s-0x3 > 0)
 296          {
 297              var _s = (s*dx*Math.sqrt(1+dy*dy/(dx*dx))-dx-(s>>1)*dy) / dx;
 298              _s = (!(s-0x4)? Math.ceil(_s) : Math.round(_s)) + 1;
 299          }
 300          else var _s = s;
 301          var ad = Math.ceil(s/2);
 302  
 303          var pr = dy<<1,
 304          pru = pr - (dx<<1),
 305          p = pr-dx,
 306          ox = x;
 307          while ((dx--) > 0)
 308          {
 309              ++x;
 310              if (p > 0)
 311              {
 312                  this.mkDiv(ox, y, x-ox+ad, _s);
 313                  y += yIncr;
 314                  p += pru;
 315                  ox = x;
 316              }
 317              else p += pr;
 318          }
 319          this.mkDiv(ox, y, x2-ox+ad+1, _s);
 320      }
 321  
 322      else
 323      {
 324          if (s-0x3 > 0)
 325          {
 326              var _s = (s*dy*Math.sqrt(1+dx*dx/(dy*dy))-(s>>1)*dx-dy) / dy;
 327              _s = (!(s-0x4)? Math.ceil(_s) : Math.round(_s)) + 1;
 328          }
 329          else var _s = s;
 330          var ad = Math.round(s/2);
 331  
 332          var pr = dx<<1,
 333          pru = pr - (dy<<1),
 334          p = pr-dy,
 335          oy = y;
 336          if (y2 <= y1)
 337          {
 338              ++ad;
 339              while ((dy--) > 0)
 340              {
 341                  if (p > 0)
 342                  {
 343                      this.mkDiv(x++, y, _s, oy-y+ad);
 344                      y += yIncr;
 345                      p += pru;
 346                      oy = y;
 347                  }
 348                  else
 349                  {
 350                      y += yIncr;
 351                      p += pr;
 352                  }
 353              }
 354              this.mkDiv(x2, y2, _s, oy-y2+ad);
 355          }
 356          else
 357          {
 358              while ((dy--) > 0)
 359              {
 360                  y += yIncr;
 361                  if (p > 0)
 362                  {
 363                      this.mkDiv(x++, oy, _s, y-oy+ad);
 364                      p += pru;
 365                      oy = y;
 366                  }
 367                  else p += pr;
 368              }
 369              this.mkDiv(x2, oy, _s, y2-oy+ad+1);
 370          }
 371      }
 372  }
 373  
 374  
 375  
 376  
 377  
 378  function mkLinDott(x1, y1, x2, y2)
 379  {
 380      if (x1 > x2)
 381      {
 382          var _x2 = x2;
 383          var _y2 = y2;
 384          x2 = x1;
 385          y2 = y1;
 386          x1 = _x2;
 387          y1 = _y2;
 388      }
 389      var dx = x2-x1, dy = Math.abs(y2-y1),
 390      x = x1, y = y1,
 391      yIncr = (y1 > y2)? -1 : 1,
 392      drw = true;
 393      if (dx >= dy)
 394      {
 395          var pr = dy<<1,
 396          pru = pr - (dx<<1),
 397          p = pr-dx;
 398          while ((dx--) > 0)
 399          {
 400              if (drw) this.mkDiv(x, y, 1, 1);
 401              drw = !drw;
 402              if (p > 0)
 403              {
 404                  y += yIncr;
 405                  p += pru;
 406              }
 407              else p += pr;
 408              ++x;
 409          }
 410          if (drw) this.mkDiv(x, y, 1, 1);
 411      }
 412  
 413      else
 414      {
 415          var pr = dx<<1,
 416          pru = pr - (dy<<1),
 417          p = pr-dy;
 418          while ((dy--) > 0)
 419          {
 420              if (drw) this.mkDiv(x, y, 1, 1);
 421              drw = !drw;
 422              y += yIncr;
 423              if (p > 0)
 424              {
 425                  ++x;
 426                  p += pru;
 427              }
 428              else p += pr;
 429          }
 430          if (drw) this.mkDiv(x, y, 1, 1);
 431      }
 432  }
 433  
 434  
 435  
 436  
 437  
 438  function mkOv(left, top, width, height)
 439  {
 440      var a = width>>1, b = height>>1,
 441      wod = width&1, hod = (height&1)+1,
 442      cx = left+a, cy = top+b,
 443      x = 0, y = b,
 444      ox = 0, oy = b,
 445      aa = (a*a)<<1, bb = (b*b)<<1,
 446      st = (aa>>1)*(1-(b<<1)) + bb,
 447      tt = (bb>>1) - aa*((b<<1)-1),
 448      w, h;
 449      while (y > 0)
 450      {
 451          if (st < 0)
 452          {
 453              st += bb*((x<<1)+0x3);
 454              tt += (bb<<1)*(++x);
 455          }
 456          else if (tt < 0)
 457          {
 458              st += bb*((x<<1)+0x3) - (aa<<1)*(y-1);
 459              tt += (bb<<1)*(++x) - aa*(((y--)<<1)-0x3);
 460              w = x-ox;
 461              h = oy-y;
 462              if (w&0x2 && h&0x2)
 463              {
 464                  this.mkOvQds(cx, cy, -x+0x2, ox+wod, -oy, oy-1+hod, 1, 1);
 465                  this.mkOvQds(cx, cy, -x+1, x-1+wod, -y-1, y+hod, 1, 1);
 466              }
 467              else this.mkOvQds(cx, cy, -x+1, ox+wod, -oy, oy-h+hod, w, h);
 468              ox = x;
 469              oy = y;
 470          }
 471          else
 472          {
 473              tt -= aa*((y<<1)-0x3);
 474              st -= (aa<<1)*(--y);
 475          }
 476      }
 477      this.mkDiv(cx-a, cy-oy, a-ox+1, (oy<<1)+hod);
 478      this.mkDiv(cx+ox+wod, cy-oy, a-ox+1, (oy<<1)+hod);
 479  }
 480  
 481  
 482  
 483  
 484  
 485  function mkOv2D(left, top, width, height)
 486  {
 487      var s = this.stroke;
 488      width += s-1;
 489      height += s-1;
 490      var a = width>>1, b = height>>1,
 491      wod = width&1, hod = (height&1)+1,
 492      cx = left+a, cy = top+b,
 493      x = 0, y = b,
 494      aa = (a*a)<<1, bb = (b*b)<<1,
 495      st = (aa>>1)*(1-(b<<1)) + bb,
 496      tt = (bb>>1) - aa*((b<<1)-1);
 497  
 498  
 499      if (s-0x4 < 0 && (!(s-0x2) || width-0x33 > 0 && height-0x33 > 0))
 500      {
 501          var ox = 0, oy = b,
 502          w, h,
 503          pxl, pxr, pxt, pxb, pxw;
 504          while (y > 0)
 505          {
 506              if (st < 0)
 507              {
 508                  st += bb*((x<<1)+0x3);
 509                  tt += (bb<<1)*(++x);
 510              }
 511              else if (tt < 0)
 512              {
 513                  st += bb*((x<<1)+0x3) - (aa<<1)*(y-1);
 514                  tt += (bb<<1)*(++x) - aa*(((y--)<<1)-0x3);
 515                  w = x-ox;
 516                  h = oy-y;
 517  
 518                  if (w-1)
 519                  {
 520                      pxw = w+1+(s&1);
 521                      h = s;
 522                  }
 523                  else if (h-1)
 524                  {
 525                      pxw = s;
 526                      h += 1+(s&1);
 527                  }
 528                  else pxw = h = s;
 529                  this.mkOvQds(cx, cy, -x+1, ox-pxw+w+wod, -oy, -h+oy+hod, pxw, h);
 530                  ox = x;
 531                  oy = y;
 532              }
 533              else
 534              {
 535                  tt -= aa*((y<<1)-0x3);
 536                  st -= (aa<<1)*(--y);
 537              }
 538          }
 539          this.mkDiv(cx-a, cy-oy, s, (oy<<1)+hod);
 540          this.mkDiv(cx+a+wod-s+1, cy-oy, s, (oy<<1)+hod);
 541      }
 542  
 543  
 544      else
 545      {
 546          var _a = (width-((s-1)<<1))>>1,
 547          _b = (height-((s-1)<<1))>>1,
 548          _x = 0, _y = _b,
 549          _aa = (_a*_a)<<1, _bb = (_b*_b)<<1,
 550          _st = (_aa>>1)*(1-(_b<<1)) + _bb,
 551          _tt = (_bb>>1) - _aa*((_b<<1)-1),
 552  
 553          pxl = new Array(),
 554          pxt = new Array(),
 555          _pxb = new Array();
 556          pxl[0] = 0;
 557          pxt[0] = b;
 558          _pxb[0] = _b-1;
 559          while (y > 0)
 560          {
 561              if (st < 0)
 562              {
 563                  st += bb*((x<<1)+0x3);
 564                  tt += (bb<<1)*(++x);
 565                  pxl[pxl.length] = x;
 566                  pxt[pxt.length] = y;
 567              }
 568              else if (tt < 0)
 569              {
 570                  st += bb*((x<<1)+0x3) - (aa<<1)*(y-1);
 571                  tt += (bb<<1)*(++x) - aa*(((y--)<<1)-0x3);
 572                  pxl[pxl.length] = x;
 573                  pxt[pxt.length] = y;
 574              }
 575              else
 576              {
 577                  tt -= aa*((y<<1)-0x3);
 578                  st -= (aa<<1)*(--y);
 579              }
 580  
 581              if (_y > 0)
 582              {
 583                  if (_st < 0)
 584                  {
 585                      _st += _bb*((_x<<1)+0x3);
 586                      _tt += (_bb<<1)*(++_x);
 587                      _pxb[_pxb.length] = _y-1;
 588                  }
 589                  else if (_tt < 0)
 590                  {
 591                      _st += _bb*((_x<<1)+0x3) - (_aa<<1)*(_y-1);
 592                      _tt += (_bb<<1)*(++_x) - _aa*(((_y--)<<1)-0x3);
 593                      _pxb[_pxb.length] = _y-1;
 594                  }
 595                  else
 596                  {
 597                      _tt -= _aa*((_y<<1)-0x3);
 598                      _st -= (_aa<<1)*(--_y);
 599                      _pxb[_pxb.length-1]--;
 600                  }
 601              }
 602          }
 603  
 604          var ox = 0, oy = b,
 605          _oy = _pxb[0],
 606          l = pxl.length,
 607          w, h;
 608          for (var i = 0; i < l; i++)
 609          {
 610              if (typeof _pxb[i] != "undefined")
 611              {
 612                  if (_pxb[i] < _oy || pxt[i] < oy)
 613                  {
 614                      x = pxl[i];
 615                      this.mkOvQds(cx, cy, -x+1, ox+wod, -oy, _oy+hod, x-ox, oy-_oy);
 616                      ox = x;
 617                      oy = pxt[i];
 618                      _oy = _pxb[i];
 619                  }
 620              }
 621              else
 622              {
 623                  x = pxl[i];
 624                  this.mkDiv(cx-x+1, cy-oy, 1, (oy<<1)+hod);
 625                  this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
 626                  ox = x;
 627                  oy = pxt[i];
 628              }
 629          }
 630          this.mkDiv(cx-a, cy-oy, 1, (oy<<1)+hod);
 631          this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
 632      }
 633  }
 634  
 635  
 636  
 637  
 638  
 639  function mkOvDott(left, top, width, height)
 640  {
 641      var a = width>>1, b = height>>1,
 642      wod = width&1, hod = height&1,
 643      cx = left+a, cy = top+b,
 644      x = 0, y = b,
 645      aa2 = (a*a)<<1, aa4 = aa2<<1, bb = (b*b)<<1,
 646      st = (aa2>>1)*(1-(b<<1)) + bb,
 647      tt = (bb>>1) - aa2*((b<<1)-1),
 648      drw = true;
 649      while (y > 0)
 650      {
 651          if (st < 0)
 652          {
 653              st += bb*((x<<1)+0x3);
 654              tt += (bb<<1)*(++x);
 655          }
 656          else if (tt < 0)
 657          {
 658              st += bb*((x<<1)+0x3) - aa4*(y-1);
 659              tt += (bb<<1)*(++x) - aa2*(((y--)<<1)-0x3);
 660          }
 661          else
 662          {
 663              tt -= aa2*((y<<1)-0x3);
 664              st -= aa4*(--y);
 665          }
 666          if (drw) this.mkOvQds(cx, cy, -x, x+wod, -y, y+hod, 1, 1);
 667          drw = !drw;
 668      }
 669  }
 670  
 671  
 672  
 673  
 674  
 675  function mkRect(x, y, w, h)
 676  {
 677      var s = this.stroke;
 678      this.mkDiv(x, y, w, s);
 679      this.mkDiv(x+w, y, s, h);
 680      this.mkDiv(x, y+h, w+s, s);
 681      this.mkDiv(x, y+s, s, h-s);
 682  }
 683  
 684  
 685  
 686  
 687  
 688  function mkRectDott(x, y, w, h)
 689  {
 690      this.drawLine(x, y, x+w, y);
 691      this.drawLine(x+w, y, x+w, y+h);
 692      this.drawLine(x, y+h, x+w, y+h);
 693      this.drawLine(x, y, x, y+h);
 694  }
 695  
 696  
 697  
 698  
 699  
 700  function jsgFont()
 701  {
 702      this.PLAIN = 'font-weight:normal;';
 703      this.BOLD = 'font-weight:bold;';
 704      this.ITALIC = 'font-style:italic;';
 705      this.ITALIC_BOLD = this.ITALIC + this.BOLD;
 706      this.BOLD_ITALIC = this.ITALIC_BOLD;
 707  }
 708  var Font = new jsgFont();
 709  
 710  
 711  
 712  
 713  
 714  function jsgStroke()
 715  {
 716      this.DOTTED = -1;
 717  }
 718  var Stroke = new jsgStroke();
 719  
 720  
 721  
 722  
 723  
 724  function jsGraphics(id, wnd)
 725  {
 726      this.setColor = new Function('arg', 'this.color = arg;');
 727  
 728  
 729      this.getColor = new Function('return this.color');
 730  
 731      this.setStroke = function(x)
 732      {
 733          this.stroke = x;
 734          if (!(x+1))
 735          {
 736              this.drawLine = mkLinDott;
 737              this.mkOv = mkOvDott;
 738              this.drawRect = mkRectDott;
 739          }
 740          else if (x-1 > 0)
 741          {
 742              this.drawLine = mkLin2D;
 743              this.mkOv = mkOv2D;
 744              this.drawRect = mkRect;
 745          }
 746          else
 747          {
 748              this.drawLine = mkLin;
 749              this.mkOv = mkOv;
 750              this.drawRect = mkRect;
 751          }
 752      };
 753  
 754  
 755  
 756      this.setPrintable = function(arg)
 757      {
 758          this.printable = arg;
 759          this.mkDiv = jg_n4? mkLyr : arg? mkDivPrint : mkDiv;
 760      };
 761  
 762  
 763  
 764      this.setFont = function(fam, sz, sty)
 765      {
 766          this.ftFam = fam;
 767          this.ftSz = sz;
 768          this.ftSty = sty || Font.PLAIN;
 769      };
 770  
 771  
 772  
 773      this.drawPolyline = this.drawPolyLine = function(x, y, s)
 774      {
 775          var i = x.length-1; while (i >= 0)
 776              this.drawLine(x[i], y[i], x[--i], y[i]);
 777      };
 778  
 779  
 780  
 781      this.fillRect = function(x, y, w, h)
 782      {
 783          this.mkDiv(x, y, w, h);
 784      };
 785  
 786  
 787      this.fillRectPattern = function(x, y, w, h, url)
 788      {
 789          this.htm += '<div style="position:absolute;'+
 790              'left:' + x + 'px;'+
 791              'top:' + y + 'px;'+
 792              'width:' + w + 'px;'+
 793              'height:' + h + 'px;'+
 794              'clip:rect(0,'+w+'px,'+h+'px,0);'+
 795              'overflow:hidden;'+
 796              //'background-color:' + this.color + ';'+
 797              "background-image: url('" + url + "');"+
 798              "layer-background-image: url('" + url + "');"+
 799              'z-index:100;"><\/div>';
 800          //alert(this.htm);
 801      }
 802  
 803      this.drawHandle = function(x, y, w, h, cursor)
 804      {
 805          
 806          this.htm += '<div style="position:absolute;'+
 807          'left:' + x + 'px;'+
 808          'top:' + y + 'px;'+
 809          'width:' + w + 'px;'+
 810          'height:' + h + 'px;'+
 811          'clip:rect(0,'+w+'px,'+h+'px,0);'+
 812          'padding: 2px;overflow:hidden;'+
 813          "cursor: '" + cursor + "';"+
 814          '" class="handleBox" id="' + cursor + '" ><\/div>';
 815      }
 816  
 817      this.drawHandleBox = function(x, y, w, h, cursor)
 818      {
 819          
 820          this.htm += '<div style="position:absolute;'+
 821          'left:' + x + 'px;'+
 822          'top:' + y + 'px;'+
 823          'width:' + w + 'px;'+
 824          'height:' + h + 'px;'+
 825          'clip:rect(0,'+(w+2)+'px,'+(h+2)+'px,0);'+
 826          'overflow:hidden; border: solid 1px '+ this.color+';'+
 827          "cursor: '" + cursor + "';"+
 828          '" class="handleBox" id="' + cursor + '" ><\/div>';
 829  
 830          
 831      }
 832  
 833      this.drawPolygon = function(x, y)
 834      {
 835          this.drawPolyline(x, y);
 836          this.drawLine(x[x.length-1], y[x.length-1], x[0], y[0]);
 837      };
 838  
 839  
 840  
 841      this.drawEllipse = this.drawOval = function(x, y, w, h)
 842      {
 843          this.mkOv(x, y, w, h);
 844      };
 845  
 846  
 847  
 848      this.fillEllipse = this.fillOval = function(left, top, w, h)
 849      {
 850          var a = (w -= 1)>>1, b = (h -= 1)>>1,
 851          wod = (w&1)+1, hod = (h&1)+1,
 852          cx = left+a, cy = top+b,
 853          x = 0, y = b,
 854          ox = 0, oy = b,
 855          aa2 = (a*a)<<1, aa4 = aa2<<1, bb = (b*b)<<1,
 856          st = (aa2>>1)*(1-(b<<1)) + bb,
 857          tt = (bb>>1) - aa2*((b<<1)-1),
 858          pxl, dw, dh;
 859          if (w+1) while (y > 0)
 860          {
 861              if (st < 0)
 862              {
 863                  st += bb*((x<<1)+0x3);
 864                  tt += (bb<<1)*(++x);
 865              }
 866              else if (tt < 0)
 867              {
 868                  st += bb*((x<<1)+0x3) - aa4*(y-1);
 869                  pxl = cx-x;
 870                  dw = (x<<1)+wod;
 871                  tt += (bb<<1)*(++x) - aa2*(((y--)<<1)-0x3);
 872                  dh = oy-y;
 873                  this.mkDiv(pxl, cy-oy, dw, dh);
 874                  this.mkDiv(pxl, cy+oy-dh+hod, dw, dh);
 875                  ox = x;
 876                  oy = y;
 877              }
 878              else
 879              {
 880                  tt -= aa2*((y<<1)-0x3);
 881                  st -= aa4*(--y);
 882              }
 883          }
 884          this.mkDiv(cx-a, cy-oy, w+1, (oy<<1)+hod);
 885      };
 886  
 887  
 888  
 889      this.drawString = mkLbl;
 890  
 891  
 892  
 893      this.clear = function()
 894      {
 895          this.htm = "";
 896          if (this.cnv) this.cnv.innerHTML = this.defhtm;
 897          
 898      };
 899  
 900  
 901  
 902      this.mkOvQds = function(cx, cy, xl, xr, yt, yb, w, h)
 903      {
 904          this.mkDiv(xr+cx, yt+cy, w, h);
 905          this.mkDiv(xr+cx, yb+cy, w, h);
 906          this.mkDiv(xl+cx, yb+cy, w, h);
 907          this.mkDiv(xl+cx, yt+cy, w, h);
 908      };
 909  
 910  
 911      this.setStroke(1);
 912      this.setPrintable(false);
 913      this.setFont('verdana,geneva,helvetica,sans-serif', String.fromCharCode(0x31, 0x32, 0x70, 0x78), Font.PLAIN);
 914      this.color = '#000000';
 915      this.htm = '';
 916      this.wnd = wnd || window;
 917  
 918  
 919      if (!(jg_ie || jg_dom || jg_ihtm)) chkDHTM();
 920      if (typeof id != 'string' || !id) this.paint = pntDoc;
 921      else
 922      {
 923          this.cnv = document.all? (this.wnd.document.all[id] || null)
 924              : document.getElementById? (this.wnd.document.getElementById(id) || null)
 925              : null;
 926          this.defhtm = (this.cnv && this.cnv.innerHTML)? this.cnv.innerHTML : '';
 927          this.paint = jg_dom? pntCnvDom : jg_ie? pntCnvIe : jg_ihtm? pntCnvIhtm : pntCnv;
 928      }
 929  }