[ Index ]
 

Code source de phpMyAdmin 2.10.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/pmd/scripts/ -> iecanvas.js (source)

   1  if (!window.all)  // if IE
   2  { 
   3    document.attachEvent("onreadystatechange", // document load
   4      function () 
   5      {          
   6        if (document.readyState == "complete") 
   7        {      
   8          var el  =  document.getElementById("canvas");
   9          var outerHTML = el.outerHTML;
  10          var newEl = document.createElement(outerHTML);
  11          el.parentNode.replaceChild(newEl, el);
  12          el = newEl;
  13          el.getContext = function () {
  14            if (this.cont) return this.cont;
  15            return this.cont = new PMD_2D(this);
  16          };
  17  
  18          el.style.width = el.attributes.width.nodeValue + "px";
  19          el.style.height = el.attributes.height.nodeValue + "px";
  20        } 
  21      }
  22    );
  23  
  24  //*****************************************************************************************************
  25  
  26    function convert_style(str) {
  27      var m = Array();
  28      m = str.match(/.*\((\d*),(\d*),(\d*),(\d*)\)/);
  29      for(var i = 1; i<=3; i++ )
  30        m[i] = (m[i]*1).toString(16).length < 2 ? '0' + (m[i]*1).toString(16) : (m[i]*1).toString(16);
  31      return ['#' + m[1] + m[2] + m[3], 1];
  32    }
  33  //------------------------------------------------------------------------------  
  34    function PMD_2D(th) {
  35      this.element_ = th;
  36      this.pmd_arr = Array();
  37      this.strokeStyle;
  38      this.fillStyle;
  39      this.lineWidth;
  40      
  41      this.closePath = function() {
  42        this.pmd_arr.push({type: "close"});
  43      }
  44      
  45      this.clearRect = function() {
  46        this.element_.innerHTML = "";
  47        this.pmd_arr = [];
  48      }
  49      
  50      this.beginPath = function() {
  51        this.pmd_arr = [];
  52      }
  53  
  54      this.moveTo = function(aX, aY) {
  55        this.pmd_arr.push({type: "moveTo", x: aX, y: aY});
  56      }
  57  
  58      this.lineTo = function(aX, aY) {
  59        this.pmd_arr.push({type: "lineTo", x: aX, y: aY});
  60      }
  61  
  62      this.arc = function(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {
  63        if (!aClockwise) {
  64          var t = aStartAngle;
  65          aStartAngle = aEndAngle;
  66          aEndAngle = t;
  67        }
  68  
  69        var xStart = aX + (Math.cos(aStartAngle) * aRadius);
  70        var yStart = aY + (Math.sin(aStartAngle) * aRadius);
  71  
  72        var xEnd = aX + (Math.cos(aEndAngle) * aRadius);
  73        var yEnd = aY + (Math.sin(aEndAngle) * aRadius);
  74  
  75        this.pmd_arr.push({type: "arc", x: aX, y: aY,
  76                               radius: aRadius, xStart: xStart, yStart: yStart, xEnd: xEnd, yEnd: yEnd});
  77      }
  78  
  79      this.rect = function(aX, aY, aW, aH) {
  80        this.moveTo(aX, aY);
  81        this.lineTo(aX + aW, aY);
  82        this.lineTo(aX + aW, aY + aH);
  83        this.lineTo(aX, aY + aH);
  84        this.closePath();
  85      }
  86  
  87      this.fillRect = function(aX, aY, aW, aH) {
  88        this.beginPath();
  89        this.moveTo(aX, aY);
  90        this.lineTo(aX + aW, aY);
  91        this.lineTo(aX + aW, aY + aH);
  92        this.lineTo(aX, aY + aH);
  93        this.closePath();
  94        this.stroke(true);
  95      }
  96  
  97      this.stroke = function(aFill) {
  98        var Str = Array();
  99        var a = convert_style(aFill ? this.fillStyle : this.strokeStyle);
 100        var color = a[0];
 101  
 102        Str.push('<v:shape',
 103                 ' fillcolor="', color, '"',
 104                 ' filled="', Boolean(aFill), '"',
 105                 ' style="position:absolute;width:10;height:10;"',
 106                 ' coordorigin="0 0" coordsize="10 10"',
 107                 ' stroked="', !aFill, '"',
 108                 ' strokeweight="', this.lineWidth, '"',
 109                 ' strokecolor="', color, '"',
 110                 ' path="');
 111  
 112        for (var i = 0; i < this.pmd_arr.length; i++) {
 113          var p = this.pmd_arr[i];
 114          
 115          if (p.type == "moveTo") {
 116            Str.push(" m ");
 117            Str.push(Math.floor(p.x), ",",Math.floor(p.y));
 118          } else if (p.type == "lineTo") {
 119            Str.push(" l ");
 120            Str.push(Math.floor(p.x), ",",Math.floor(p.y));
 121          } else if (p.type == "close") {
 122            Str.push(" x ");
 123          } else if (p.type == "arc") {
 124            Str.push(" ar ");
 125            Str.push(Math.floor(p.x - p.radius), ",",
 126                     Math.floor(p.y - p.radius), " ",
 127                     Math.floor(p.x + p.radius), ",",
 128                     Math.floor(p.y + p.radius), " ",
 129                     Math.floor(p.xStart), ",", Math.floor(p.yStart), " ",
 130                     Math.floor(p.xEnd), ",", Math.floor(p.yEnd));
 131          }
 132        }
 133      
 134        Str.push(' ">');
 135        Str.push("</v:shape>");
 136      
 137        this.element_.insertAdjacentHTML("beforeEnd", Str.join(""));
 138        this.pmd_arr = Array();
 139      }
 140    };
 141  }


Généré le : Mon Nov 26 15:18:20 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics