"use strict";
class TWO {
  constructor(canvas,mode) {
    this.a = canvas;
    this.m = mode; // switch between `2d` and `webgl`
    this.c = canvas.getContext(mode);
  }
  clear() {
    if (this.m === '2d')
      this.c.clearRect(0, 0, this.c.canvas.width, this.c.canvas.height);
    if (this.m === 'webgl') {
      this.g.clearColor(0.0, 0.0, 0.0, 0.0);
      this.g.clearDepth(1.0);
      this.g.enable(this.g.DEPTH_TEST);
    }
  }
  draw(s, m, c, x, y, p1, p2) {
    this.c.beginPath();
    switch (s) {
      case 'rect': this.c.rect(x, y, p1, p2); break;
      default:
        console.error('Invalid shape to draw: ' + s);
    }
    switch (m) {
      case 'fill':   this.c.fillStyle = c;   this.c.fill();   break;
      case 'stroke': this.c.strokeStyle = c; this.c.stroke(); break;
      // no default for non-fill/stroke shapes
    }
    this.c.closePath();
  }

  // // // //

  // draws a rectangle
  // color, x, y, width, height
  fillRect(c, x, y, w, h) {
    this.c.fillStyle = c;
    this.c.fillRect(x,y,w,h);
  };
  // draw text on the screen
  drawText(color, x, y, text) {
    this.c.fillStyle = color;
    this.c.fillText(text, x, y);
  };
  // draw an image to the screen
  drawImage(img, a, b, c, d, e, f, g, h) {
    // error prevention
    if (img !== null) {
      // make it one big function by scanning for parameters
      switch (arguments.length) {
        case 3:
          // image, x, y
          this.c.drawImage(img, a, b);
          break;
        case 5:
          // image, x, y, w, h
          this.c.drawImage(img, a, b, c, d);
          break;
        case 9:
          // image, sx, sy, sw, sh, dx, dy, dw, dh
          this.c.drawImage(img, a,b,c,d,e,f,g,h);
          break;
        default:
          console.error("Invalid amount of parameters: " + arguments.length);
      }
    }
  }
}

@@ -312,25 +312,25 @@
 %0A      this.
-g
+c
 .clearColor(
@@ -361,17 +361,17 @@
    this.
-g
+c
 .clearDe
@@ -391,17 +391,17 @@
    this.
-g
+c
 .enable(
@@ -420,16 +420,126 @@
 _TEST);%0A
+      this.c.depthFunc(this.g.LEQUAL);%0A      this.c.clear(this.g.COLOR_BUFFER_BIT %7C this.g.DEPTH_BUFFER_BIT);%0A
     %7D%0A  
@@ -568,24 +568,53 @@
 , p1, p2) %7B%0A
+    if (this.m === '2d') %7B%0A  
     this.c.b
@@ -625,24 +625,26 @@
 Path();%0A    
+ 
+ 
 switch (s) %7B
@@ -640,24 +640,26 @@
 witch (s) %7B%0A
+  
       case '
@@ -701,24 +701,26 @@
 reak;%0A      
+ 
+ 
 default:%0A   
@@ -708,32 +708,34 @@
        default:%0A
+  
         console.
@@ -772,26 +772,30 @@
 ' + s);%0A    
-%7D%0A
+  %7D%0A  
     switch (
@@ -801,24 +801,26 @@
 (m) %7B%0A      
+ 
+ 
 case 'fill':
@@ -866,24 +866,26 @@
 );   break;%0A
+  
       case '
@@ -947,16 +947,18 @@
 ;%0A      
+ 
+ 
 // no de
@@ -990,16 +990,18 @@
  shapes%0A
+  
     %7D%0A  
@@ -998,24 +998,26 @@
       %7D%0A    
+  
 this.c.close
@@ -1024,20 +1024,94 @@
 Path();%0A
+    %7D%0A    if (this.m === 'webgl') // TODO%0A      console.log(arguments);%0A
   %7D%0A
+  
 %0A  // //
@@ -1117,16 +1117,18 @@
 / // //%0A
+  
 %0A  // dr
@@ -1133,82 +1133,89 @@
 draw
-s a rectangle%0A  // color, x, y, width, height%0A  fillRect(c, x, y, w, h
+ text on the screen%0A  drawText(color, x, y, text) %7B%0A    if (this.m === '2d'
 ) %7B%0A
+  
     
@@ -1234,18 +1234,24 @@
 tyle = c
-;%0A
+olor;%0A  
     this
@@ -1261,149 +1261,95 @@
 fill
-Rect(x,y,w,h);%0A  %7D;%0A  // draw text on the screen%0A  drawText(color, x, y, text) %7B%0A    this.c.fillStyle = color;%0A    this.c.fillText(text, x, y
+Text(text, x, y);%0A    %7D%0A    if (this.m === 'webgl') // TODO%0A      console.log(arguments
 );%0A 
@@ -1424,24 +1424,51 @@
  f, g, h) %7B%0A
+    if (this.m === '2d') %7B%0A
     // error
@@ -2043,18 +2043,90 @@
     %7D%0A    %7D%0A
+    %7D%0A    if (this.m === 'webgl') // TODO%0A      console.log(arguments);%0A
   %7D%0A%7D%0A

Update Two.js