~ubuntu-branches/ubuntu/trusty/picolisp/trusty-proposed

« back to all changes in this revision

Viewing changes to .pc/picolisp_sync_to_tip.patch/lib/canvas.js

  • Committer: Package Import Robot
  • Author(s): Kan-Ru Chen (陳侃如)
  • Date: 2014-01-15 22:59:02 UTC
  • Revision ID: package-import@ubuntu.com-20140115225902-b0c3cqq4ulvdkykv
Tags: 3.1.5.2-2
* Sync to tip.
* debian/picolisp.install:
  - Include lib/phone.css
  - Install arch-indep files under /usr/share/picolisp
* debian/source/lintian-overrides:
  - Override unknown architectures armel and armhf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 04jan14abu
 
2
 * (c) Software Lab. Alexander Burger
 
3
 */
 
4
 
 
5
function drawCanvas(id, dly, x, y) {
 
6
   var req = new XMLHttpRequest();
 
7
 
 
8
   try {
 
9
      req.open("POST",
 
10
         document.getElementsByTagName("BASE")[0].href + SesId +
 
11
         "!jsDraw?" + id + "&+" + dly +
 
12
         (y? "&+" + x + "&+" + y : x? "&" + x : "") );
 
13
      req.responseType = "arraybuffer";
 
14
   }
 
15
   catch (e) {return true;}
 
16
   req.onload = function() {
 
17
      var lst = plio(new Uint8Array(req.response));
 
18
      var ele = document.getElementById(id);
 
19
      var cmd, i, j;
 
20
 
 
21
      if (lst) {
 
22
         var ctx = ele.getContext("2d");
 
23
 
 
24
         for (i = 0; i < lst.length; ++i) {
 
25
            switch ((cmd = lst[i])[0]) {  // In sync with "@lib/canvas.l"
 
26
            /*** Functions ***/
 
27
            case 1:
 
28
               ctx.fillText(cmd[1], cmd[2], cmd[3]);
 
29
               break;
 
30
            case 2:
 
31
               ctx.beginPath();
 
32
               ctx.moveTo(cmd[1], cmd[2]);
 
33
               ctx.lineTo(cmd[3], cmd[4]);
 
34
               ctx.closePath();
 
35
               ctx.stroke();
 
36
               break;
 
37
            case 3:
 
38
               ctx.clearRect(cmd[1], cmd[2], cmd[3], cmd[4]);
 
39
               break;
 
40
            case 4:
 
41
               ctx.strokeRect(cmd[1], cmd[2], cmd[3], cmd[4]);
 
42
               break;
 
43
            case 5:
 
44
               ctx.fillRect(cmd[1], cmd[2], cmd[3], cmd[4]);
 
45
               break;
 
46
            case 6:
 
47
               ctx.beginPath();
 
48
               break;
 
49
            case 7:
 
50
               ctx.closePath();
 
51
               break;
 
52
            case 8:
 
53
               ctx.moveTo(cmd[1], cmd[2]);
 
54
               break;
 
55
            case 9:
 
56
               ctx.lineTo(cmd[1], cmd[2]);
 
57
               break;
 
58
            case 10:
 
59
               ctx.bezierCurveTo(cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6]);
 
60
               break;
 
61
            case 11:
 
62
               ctx.moveTo(cmd[1], cmd[2]);
 
63
               ctx.lineTo(cmd[3], cmd[4]);
 
64
               break;
 
65
            case 12:
 
66
               ctx.rect(cmd[1], cmd[2], cmd[3], cmd[4]);
 
67
               break;
 
68
            case 13:
 
69
               ctx.arc(cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6]);
 
70
               break;
 
71
            case 14:
 
72
               ctx.stroke();
 
73
               break;
 
74
            case 15:
 
75
               ctx.fill();
 
76
               break;
 
77
            case 16:
 
78
               ctx.clip();
 
79
               break;
 
80
            case 17:
 
81
               if (cmd[3])
 
82
                  for (j = 0; j < cmd[3].length; j += 2)
 
83
                     ctx.fillRect(cmd[3][j], cmd[3][j+1], cmd[1], cmd[2]);
 
84
               break;
 
85
            case 18:
 
86
               ctx.drawImage(cmd[1], cmd[2], cmd[3]);
 
87
               break;
 
88
            case 19:
 
89
               ctx.translate(cmd[1], cmd[2]);
 
90
               break;
 
91
            case 20:
 
92
               ctx.rotate(cmd[1]);
 
93
               break;
 
94
            case 21:
 
95
               ctx.scale(cmd[1], cmd[2]);
 
96
               break;
 
97
            case 22:
 
98
               ctx.save();
 
99
               break;
 
100
            case 23:
 
101
               ctx.restore();
 
102
               break;
 
103
            /*** Variables ***/
 
104
            case 24:
 
105
               ctx.fillStyle = cmd[1];
 
106
               break;
 
107
            case 25:
 
108
               ctx.strokeStyle = cmd[1];
 
109
               break;
 
110
            case 26:
 
111
               ctx.globalAlpha = cmd[1];
 
112
               break;
 
113
            case 27:
 
114
               ctx.lineWidth = cmd[1];
 
115
               break;
 
116
            case 28:
 
117
               ctx.lineCap = cmd[1];
 
118
               break;
 
119
            case 29:
 
120
               ctx.lineJoin = cmd[1];
 
121
               break;
 
122
            case 30:
 
123
               ctx.miterLimit = cmd[1];
 
124
               break;
 
125
            case 31:
 
126
               ctx.globalCompositeOperation = cmd[1];
 
127
               break;
 
128
            }
 
129
         }
 
130
      }
 
131
      if (y)
 
132
         while (ele = ele.parentNode) {
 
133
            if (ele.tagName == "FORM") {
 
134
               post(ele, false, null, null);
 
135
               break;
 
136
            }
 
137
         }
 
138
      // if (dly == 0)
 
139
      //    requestAnimationFrame(function() {drawCanvas(id, dly)});
 
140
      // else if (dly > 0)
 
141
      //    setTimeout(function() {drawCanvas(id, dly)}, dly);
 
142
      if (dly >= 0)
 
143
         setTimeout(function() {drawCanvas(id, dly)}, dly);
 
144
   }
 
145
   try {req.send(null);}
 
146
   catch (e) {
 
147
      req.abort();
 
148
      return true;
 
149
   }
 
150
   return false;
 
151
}