Commits

Benoît Allard  committed 8569ca9

Improve Opera support

  • Participants
  • Parent commits ff040a3

Comments (0)

Files changed (3)

 <div id=page>
  <h1>Harvester simulation <span class=small>(harvesim)</span></h1>
 
+ <p class=opera>WARNING: There are some drawing troubles with
+ Opera. This should'nt affect the simulation though.</p>
+
  <div id=stack>
   <canvas width=760 height=760 id=harvester></canvas>
   <canvas width=760 height=760 id=field>
     context.beginPath();
 
     context.translate(cx-rx, cy-ry);
-    context.rotate(angle);
+    if( typeof(angle) != 'undefined'){
+        context.rotate(angle);
+    }
     context.scale(rx, ry);
-    context.arc(1, 1, 1, 0, 2 * Math.PI, false);
+    if (window.opera){
+        context.moveTo(-rx, 0)
+        context.bezierCurveTo(
+            -rx, ry,
+            -ry, rx,
+            0, rx
+        );
+        context.bezierCurveTo(
+            ry, rx,
+            rx, ry,
+            rx, 0
+        );
+        context.bezierCurveTo(
+            rx, -ry,
+            ry, -rx,
+            0, -rx
+        );
+        context.bezierCurveTo(
+                -ry, -rx,
+                -rx, -ry,
+                -rx, 0
+        );
+    } else {
+        context.arc(1, 1, 1, 0, 2 * Math.PI, false);
+    }
     context.closePath();
     context.restore(); // restore to original state
     context.stroke();
 };
 
-
 function init(){
     // init the interface
     document.getElementById("pauseBtn").disabled = true;
 
         ellipse(this.context,
                 this.length/4, this.width/3,
-                this.length*3/16, this.width/12,
-                0);
+                this.length*3/16, this.width/12);
         ellipse(this.context,
                 this.length/4, -this.width/3,
-                this.length*3/16, this.width/12,
-                0);
+                this.length*3/16, this.width/12);
 
         this.context.save();
         this.context.lineWidth = .1;
         // We need to probe the field in front of the working stuff on the left
         // side ahead of the harvester, and try to anticipate changement of direction
 
+        // the beauty of closures ...
         var probe = function(r, a){
             var pt = harvester.getPt(harvester.length/2 + r*Math.cos(a),
                                      -harvester.width/2 + r*Math.sin(a));
   font-family: sans-serif;
 }
 
+.opera {
+  display: none;
+}
+
+noindex:-o-prefocus, .opera{
+  display: block;
+}
 
 .small {
   font-size: 60%;