Creates the canvas that sits on top of the game's canvas and
holds game controls
511677
function() {
			var _this = this;
			this.canvas = document.createElement('canvas');
			// Scale to same size as original canvas
			this.resize(true);
			document.body.appendChild(this.canvas);
			this.ctx = this.canvas.getContext( '2d');
			window.addEventListener( 'resize', function() {
				setTimeout(function(){ GameController.resize.call(_this); }, 10);
			});

			// Set the touch events for this new canvas
			this.setTouchEvents();

			// Load in the initial UI elements
			this.loadSide('left');
			this.loadSide('right');

			// Starts up the rendering / drawing
			this.render();

			// pause until a touch event
			if( !this.touches || !this.touches.length ) this.paused = true;
		}
732449
function createCanvas (element) {
  const canvas = document.createElement('canvas');

  canvas.style.display = 'block';
  canvas.classList.add(CANVAS_CSS_CLASS);
  element.appendChild(canvas);

  return canvas;
}
1350221
function() {

        me.game.reset();

        // add the background & foreground
        // add the foreground
        var background_sprite10 = new me.Sprite (0, 0,   {image: me.loader.getImage("background")});
        var grass_upper_1       = new me.Sprite (0, 0,   {image: me.loader.getImage("grass_upper")});

        var background_sprite11 = new me.Sprite (0, 127, {image: me.loader.getImage("background")});
        var grass_lower_1       = new me.Sprite (0, 127, {image: me.loader.getImage("grass_lower")});

        var background_sprite20 = new me.Sprite (0, 255, {image: me.loader.getImage("background")});
        var grass_upper_2       = new me.Sprite (0, 255, {image: me.loader.getImage("grass_upper")});

        var background_sprite21 = new me.Sprite (0, 383, {image: me.loader.getImage("background")});
        var grass_lower_2       = new me.Sprite (0, 383, {image: me.loader.getImage("grass_lower")});

        var background_sprite30 = new me.Sprite (0, 511, {image: me.loader.getImage("background")});
        var grass_upper_3       = new me.Sprite (0, 511, {image: me.loader.getImage("grass_upper")});

        var background_sprite31 = new me.Sprite (0, 639, {image: me.loader.getImage("background")});
        var grass_lower_3       = new me.Sprite (0, 639, {image: me.loader.getImage("grass_lower")});


        // use top left coordinates for positioning
        background_sprite10.anchorPoint.set(0, 0);
        grass_upper_1.anchorPoint.set(0, 0);

        background_sprite11.anchorPoint.set(0, 0);
        grass_lower_1.anchorPoint.set(0, 0);

        background_sprite20.anchorPoint.set(0, 0);
        grass_upper_2.anchorPoint.set(0, 0);

        background_sprite21.anchorPoint.set(0, 0);
        grass_lower_2.anchorPoint.set(0, 0);

        background_sprite30.anchorPoint.set(0, 0);
        grass_upper_3.anchorPoint.set(0, 0);

        background_sprite31.anchorPoint.set(0, 0);
        grass_lower_3.anchorPoint.set(0, 0);

        // instantiate teh mole Manager
        var moleManager = new game.MoleManager(0, 0);

        // add all objects
        me.game.world.addChild (background_sprite10, 0);
        me.game.world.addChild (background_sprite11, 0);
        me.game.world.addChild (background_sprite20, 0);
        me.game.world.addChild (background_sprite21, 0);
        me.game.world.addChild (background_sprite30, 0);
        me.game.world.addChild (background_sprite31, 0);

        me.game.world.addChild (grass_upper_1, 10);
        me.game.world.addChild (grass_lower_1, 20);
        me.game.world.addChild (grass_upper_2, 30);
        me.game.world.addChild (grass_lower_2, 40);
        me.game.world.addChild (grass_upper_3, 50);
        me.game.world.addChild (grass_lower_3, 60);
        me.game.world.addChild (moleManager, 0);

        // add our HUD (scores/hiscore)
        this.HUD = new game.HUD.Container();
        me.game.world.addChild(this.HUD);

        // start the main soundtrack
        me.audio.playTrack("whack");
    }
794826
def preserve_current_canvas():
    
    old = ROOT.gPad
    try:
        yield
    finally:
        if old:
            old.cd()
        elif ROOT.gPad:
            # Put things back how they were before.
            with invisible_canvas():
                # This is a round-about way of resetting gPad to None.
                # No other technique I tried could do it.
                pass
995879
function() {
			//merge initial options
			_opt = merge(_def, opt);
			_opt.bgColor = hexToRgb(_opt.bgColor);
			_opt.textColor = hexToRgb(_opt.textColor);
			_opt.position = _opt.position.toLowerCase();
			_opt.animation = (animation.types['' + _opt.animation]) ? _opt.animation : _def.animation;

			var isUp = _opt.position.indexOf('up') > -1;
			var isLeft = _opt.position.indexOf('left') > -1;

			//transform animation
			if (isUp || isLeft) {
				for (var i = 0; i < animation.types['' + _opt.animation].length; i++) {
					var step = animation.types['' + _opt.animation][i];

					if (isUp) {
						if (step.y < 0.6) {
							step.y = step.y - 0.4;
						} else {
							step.y = step.y - 2 * step.y + (1 - step.w);
						}
					}

					if (isLeft) {
						if (step.x < 0.6) {
							step.x = step.x - 0.4;
						} else {
							step.x = step.x - 2 * step.x + (1 - step.h);
						}
					}

					animation.types['' + _opt.animation][i] = step;
				}
			}
			_opt.type = (type['' + _opt.type]) ? _opt.type : _def.type;
			try {
				_orig = link.getIcon();
				//create temp canvas
				_canvas = document.createElement('canvas');
				//create temp image
				_img = document.createElement('img');
				if (_orig.hasAttribute('href')) {
					_img.setAttribute('src', _orig.getAttribute('href'));
					//get width/height
					_img.onload = function() {
						_h = (_img.height > 0) ? _img.height : 32;
						_w = (_img.width > 0) ? _img.width : 32;
						_canvas.height = _h;
						_canvas.width = _w;
						_context = _canvas.getContext('2d');
						icon.ready();
					};
				} else {
					_img.setAttribute('src', '');
					_h = 32;
					_w = 32;
					_img.height = _h;
					_img.width = _w;
					_canvas.height = _h;
					_canvas.width = _w;
					_context = _canvas.getContext('2d');
					icon.ready();
				}
			} catch(e) {
				throw 'Error initializing favico. Message: ' + e.message;
			}

		}
1134842
function drawScene() {
  // Clear the canvas before we start drawing on it.
  gl.clearColor(0, 0, 0, 1);
  gl.clearDepth(1.0);
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);

  // Establish the perspective with which we want to view the
  // scene. Our field of view is 45 degrees, with a width/height
  // ratio of 640:480, and we only want to see objects between 0.1 units
  // and 100 units away from the camera.

  perspectiveMatrix = makePerspective(45, 640.0/480.0, 0.1, 100.0);

  // Set the drawing position to the "identity" point, which is
  // the center of the scene.

  loadIdentity();

  // Now move the drawing position a bit to where we want to start
  // drawing the cube.

  mvTranslate([-0.0, 0.0, -6.0]);

  // Save the current matrix, then rotate before we draw.

  mvPushMatrix();
  mvRotate(cubeRotation, [1, 0, 1]);
  mvTranslate([cubeXOffset, cubeYOffset, cubeZOffset]);

  // Draw the cube by binding the array buffer to the cube's vertices
  // array, setting attributes, and pushing it to GL.

  gl.bindBuffer(gl.ARRAY_BUFFER, cubeVerticesBuffer);
  gl.vertexAttribPointer(vertexPositionAttribute, 3, gl.FLOAT, false, 0, 0);

  // Draw the cube.

  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, cubeVerticesIndexBuffer);
  setMatrixUniforms();

  var pUniform = gl.getUniformLocation(shaderProgram, "uniformArray");
  gl.uniform2fv(pUniform, new Float32Array([1,0.2,0.4,1]));

  gl.drawElements(gl.TRIANGLES, 36, gl.UNSIGNED_SHORT, 0);

  // Restore the original matrix

  mvPopMatrix();

  // Update the rotation for the next draw, if it's time to do so.

  var currentTime = (new Date).getTime();
  if (lastCubeUpdateTime) {
    var delta = currentTime - lastCubeUpdateTime;

    cubeRotation += (30 * delta) / 1000.0;
    cubeXOffset += xIncValue * ((30 * delta) / 1000.0);
    cubeYOffset += yIncValue * ((30 * delta) / 1000.0);
    cubeZOffset += zIncValue * ((30 * delta) / 1000.0);

    if (Math.abs(cubeYOffset) > 2.5) {
      xIncValue = -xIncValue;
      yIncValue = -yIncValue;
      zIncValue = -zIncValue;
    }
  }

  lastCubeUpdateTime = currentTime;

  window.requestAnimationFrame(function() {
        drawScene();
  });
}
1270274
def show(self):
        
        self._toplevel = tk.Toplevel(self.master)
        self._canvas = tk.Canvas(self._toplevel, background=self.__background)
        self.header_label = ttk.Label(self._canvas, text=self.__headertext, background=self.__background,
                                      image=self._photo_image, compound=tk.LEFT)
        self.text_label = ttk.Label(self._canvas, text=self.__text, wraplength=self.__width,
                                    background=self.__background)
        self._toplevel.attributes("-topmost", True)
        self._toplevel.overrideredirect(True)
        self._grid_widgets()
        x, y = self.master.winfo_pointerxy()
        self._canvas.update()
        # Update the Geometry of the Toplevel to update its position and size
        self._toplevel.geometry("{0}x{1}+{2}+{3}".format(self._canvas.winfo_width(), self._canvas.winfo_height(),
                                                         x + 2, y + 2))
111501
function () {
            this.sbIndex = 0;
            this.length = 0;

            var samplers = [];

            // WebGL context
            this.gl = this.renderer.gl;

            this.flush();

            this.setProjection(this.gl.canvas.width, this.gl.canvas.height);

            this.setViewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);

            // Initialize clear color
            this.gl.clearColor(0.0, 0.0, 0.0, 1.0);

            for (var i = 0; i < this.maxTextures; i++) {
                this.units[i] = false;
                samplers[i] = i;
            }
            // set the quad shader as the default program
            this.useShader(this.quadShader);
            this.quadShader.uniforms.uSampler = samplers;
        }
1366570
function() {
		var gl = this.gl;

		var fragmentShaderSource = [
			"precision mediump float;",
			"uniform sampler2D bgTexture;",
			"uniform sampler2D spriteTexture;",
			"uniform sampler2D prioTexture;",
			"uniform sampler2D paletteTexture;",
			"uniform vec4 bgColor;",
			"varying vec2 texCoord;",

			"void main(void) {",
				"float bgIndex = texture2D(bgTexture, texCoord).r;",
				"float spriteIndex = texture2D(spriteTexture, texCoord).r;",
				"float prioIndex = texture2D(prioTexture, texCoord).r;",
				"float colorIndex = ((spriteIndex > 0.0 && (prioIndex == 0.0 || bgIndex == 0.0)) ? spriteIndex : bgIndex);",
				"vec4 color = texture2D(paletteTexture, vec2( colorIndex * 4.0 + 0.0078, 0.5));", // 0.0078 == ( 0.5 * 3 / 192 ) === ( 0.5 * [RGB colors] / [palette width] )
				"if ( colorIndex > 0.0 ) {",
					"gl_FragColor = color;",
				"} else {",
					"gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);",
					"gl_FragColor = bgColor;",
				"}",
			"}"
		].join("\n");

		var vertexShaderSource = [
			"attribute vec2 vertCoord;",
			"varying vec2 texCoord;",

			"void main() {",
				"gl_Position = vec4(vertCoord, 0, 1);",
				"texCoord = vec2( 0.5 * ( vertCoord.x + 1.0 ), 0.5 * (1.0 - vertCoord.y));",
			"}"
		].join("");

		this.fragmentShader = compileShader( gl.FRAGMENT_SHADER, fragmentShaderSource );
		this.vertexShader = compileShader( gl.VERTEX_SHADER, vertexShaderSource );

		function compileShader( shaderType, shaderSource ) {
			var shader = gl.createShader( shaderType );
			gl.shaderSource( shader, shaderSource );
			gl.compileShader( shader );

			if ( !gl.getShaderParameter( shader, gl.COMPILE_STATUS ) ) {  
				throw ( "An error occurred compiling the shaders: " + gl.getShaderInfoLog( shader ) );
			}

			return shader;
		}
	}
839192
function(x, y){
            var pos = this.canvas.getBoundingClientRect(),
                mx = x - pos.left,
                my = y - pos.top;
            return this.pixelToTileCoords(mx, my);
        }
1021627
function (projection) {
    var params = this.setCapture(projection);
    this.renderCapture(params.camera, params.size, params.projection);
    return this.canvas;
  }
1165689
function() {
		var gl = this.gl,
		      program = this.program;


		// initialize pixel textures
		this.bgTexture = createTexture( 0, "bgTexture" );
		this.spriteTexture = createTexture( 1, "spriteTexture" );
		this.prioTexture = createTexture( 2, "prioTexture" );

		// initialize palette texture
		this.paletteTexture = createTexture( 3, "paletteTexture" );
		gl.texImage2D( gl.TEXTURE_2D, 0, gl.RGB, 64, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, palette );

		function createTexture( index, name ) {
			var texture = gl.createTexture();
			gl.bindTexture(gl.TEXTURE_2D, texture);

			gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
			gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
			gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
			gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);

			gl.uniform1i(gl.getUniformLocation(program, name), index);

			return texture;
		}
	}
747385
def drawOverlay(self, painter, option, rect, icon):
        
        if icon and not icon.isNull():
            painter.drawPixmap(rect, icon.pixmap(rect.width(), rect.height()))
264255
function () {
        var gamepads = navigator.getGamepads();
        var e = {};

        // Trigger button bindings
        Object.keys(bindings).forEach(function (index) {
            var gamepad = gamepads[index];
            if (!gamepad) {
                return;
            }

            var mapping = null;
            if (gamepad.mapping !== "standard") {
                mapping = remap.get(gamepad.id);
            }

            var binding = bindings[index];

            // Iterate all buttons that have active bindings
            Object.keys(binding.buttons).forEach(function (button) {
                var last = binding.buttons[button];
                var mapped_button = button;
                var mapped_axis = -1;

                // Remap buttons if necessary
                if (mapping) {
                    mapped_button = mapping.buttons[button];
                    mapped_axis = mapping.analog[button];
                    if (mapped_button < 0 && mapped_axis < 0) {
                        // Button is not mapped
                        return;
                    }
                }

                // Get mapped button
                var current = gamepad.buttons[mapped_button] || {};

                // Remap an axis to an analog button
                if (mapping) {
                    if (mapped_axis >= 0) {
                        var value = mapping.normalize_fn(gamepad.axes[mapped_axis], -1, +button);

                        // Create a new object, because GamepadButton is read-only
                        current = {
                            "value" : value,
                            "pressed" : current.pressed || (Math.abs(value) >= deadzone)
                        };
                    }
                }

                me.event.publish(me.event.GAMEPAD_UPDATE, [ index, "buttons", +button, current ]);

                // Edge detection
                if (!last.pressed && current.pressed) {
                    api._keydown(e, last.keyCode, mapped_button + 256);
                }
                else if (last.pressed && !current.pressed) {
                    api._keyup(e, last.keyCode, mapped_button + 256);
                }

                // Update last button state
                last.value = current.value;
                last.pressed = current.pressed;
            });

            // Iterate all axes that have active bindings
            Object.keys(binding.axes).forEach(function (axis) {
                var last = binding.axes[axis];
                var mapped_axis = axis;

                // Remap buttons if necessary
                if (mapping) {
                    mapped_axis = mapping.axes[axis];
                    if (mapped_axis < 0) {
                        // axe is not mapped
                        return;
                    }
                }

                // retrieve the current value and normalize if necessary
                var value = gamepad.axes[mapped_axis];
                if (typeof(value) === "undefined") {
                    return;
                }
                if (mapping) {
                    value = mapping.normalize_fn(value, +axis, -1);
                }
                // normalize value into a [-1, 1] range value (treat 0 as positive)
                var range = Math.sign(value) || 1;
                if (last[range].keyCode === 0) {
                    return;
                }
                var pressed = (Math.abs(value) >= (deadzone + Math.abs(last[range].threshold)));

                me.event.publish(me.event.GAMEPAD_UPDATE, [ index, "axes", +axis, value ]);

                // Edge detection
                if (!last[range].pressed && pressed) {
                    // Release the opposite direction, if necessary
                    if (last[-range].pressed) {
                        api._keyup(e, last[-range].keyCode, mapped_axis + 256);
                        last[-range].value = 0;
                        last[-range].pressed = false;
                    }

                    api._keydown(e, last[range].keyCode, mapped_axis + 256);
                }
                else if ((last[range].pressed || last[-range].pressed) && !pressed) {
                    range = last[range].pressed ? range : -range;
                    api._keyup(e, last[range].keyCode, mapped_axis + 256);
                }

                // Update last axis state
                last[range].value = value;
                last[range].pressed = pressed;
            });
        });
    }
864938
function pongIOrenderImg( ctx, def ) {
	log( "pong-io", "pongIOrenderImg '"+def.id );
	var background = new Image();	
	if ( def.imgURL && def.pos && def.pos.x && def.pos.y ) {
		background.src = def.imgURL;
		background.onload = function() {
			if ( def.width && def.height ) {
				ctx.drawImage( background, def.pos.x, def.pos.y, def.width, def.height ); 
			} else {
				ctx.drawImage( background, def.pos.x, def.pos.y ); 				
			}
	    };
	}
	log( "pong-io", "pongIOrenderImg end.");
}
155471
def draw_grid(self):
        """"""
        self.screen.fill((0xbb, 0xad, 0xa0), self.origin + (self.game_width, self.game_height))
        for y, row in enumerate(self.grid):
            for x, cell in enumerate(row):
                self.screen.blit(self.tiles[cell], self.get_tile_location(x, y))
1029941
function () {
    var controller = this.controller;
    var data = this.data;
    var object3D = this.el.object3D;
    var pose;
    var vrDisplay = this.system.vrDisplay;
    var standingMatrix;

    if (!controller) { return; }

    // Compose pose from Gamepad.
    pose = controller.pose;

    if (pose.position) {
      object3D.position.fromArray(pose.position);
    } else {
      // Controller not 6DOF, apply arm model.
      if (data.armModel) { this.applyArmModel(object3D.position); }
    }

    if (pose.orientation) {
      object3D.quaternion.fromArray(pose.orientation);
    }

    // Apply transforms, if 6DOF and in VR.
    if (vrDisplay && pose.position) {
      standingMatrix = this.el.sceneEl.renderer.vr.getStandingMatrix();
      object3D.matrix.compose(object3D.position, object3D.quaternion, object3D.scale);
      object3D.matrix.multiplyMatrices(standingMatrix, object3D.matrix);
      object3D.matrix.decompose(object3D.position, object3D.quaternion, object3D.scale);
    }

    object3D.rotateX(this.data.orientationOffset.x * THREE.Math.DEG2RAD);
    object3D.rotateY(this.data.orientationOffset.y * THREE.Math.DEG2RAD);
    object3D.rotateZ(this.data.orientationOffset.z * THREE.Math.DEG2RAD);
  }