Draw each visible mesh in the scene from the perspective of the scene's camera and lit by its light.
551912
def draw(self, clear=True):
        """"""
        if clear:
            self.clear()

        with self.gl_states, self.camera, self.light:
            for mesh in self.meshes:
                try:
                    mesh.draw()
                except AttributeError:
                    pass
246058
def render(self):
        
        self.screen.reset()
        self.screen.blit(self.corners)
        self.screen.blit(self.lines, (1, 1))
        self.screen.blit(self.rects, (int(self.screen.width / 2) + 1, 1))
        self.screen.blit(self.circle, (0, int(self.screen.height / 2) + 1))
        self.screen.blit(self.filled, (int(self.screen.width / 2) + 1,
                                       int(self.screen.height / 2) + 1))

        self.screen.update()
        self.clock.tick()
765633
function ( renderer, scene, camera, geometry, material, group ) {

				if ( material.isGLTFSpecularGlossinessMaterial !== true ) {

					return;

				}

				var uniforms = material.uniforms;
				var defines = material.defines;

				uniforms.opacity.value = material.opacity;

				uniforms.diffuse.value.copy( material.color );
				uniforms.emissive.value.copy( material.emissive ).multiplyScalar( material.emissiveIntensity );

				uniforms.map.value = material.map;
				uniforms.specularMap.value = material.specularMap;
				uniforms.alphaMap.value = material.alphaMap;

				uniforms.lightMap.value = material.lightMap;
				uniforms.lightMapIntensity.value = material.lightMapIntensity;

				uniforms.aoMap.value = material.aoMap;
				uniforms.aoMapIntensity.value = material.aoMapIntensity;

				// uv repeat and offset setting priorities
				// 1. color map
				// 2. specular map
				// 3. normal map
				// 4. bump map
				// 5. alpha map
				// 6. emissive map

				var uvScaleMap;

				if ( material.map ) {

					uvScaleMap = material.map;

				} else if ( material.specularMap ) {

					uvScaleMap = material.specularMap;

				} else if ( material.displacementMap ) {

					uvScaleMap = material.displacementMap;

				} else if ( material.normalMap ) {

					uvScaleMap = material.normalMap;

				} else if ( material.bumpMap ) {

					uvScaleMap = material.bumpMap;

				} else if ( material.glossinessMap ) {

					uvScaleMap = material.glossinessMap;

				} else if ( material.alphaMap ) {

					uvScaleMap = material.alphaMap;

				} else if ( material.emissiveMap ) {

					uvScaleMap = material.emissiveMap;

				}

				if ( uvScaleMap !== undefined ) {

					// backwards compatibility
					if ( uvScaleMap.isWebGLRenderTarget ) {

						uvScaleMap = uvScaleMap.texture;

					}

					if ( uvScaleMap.matrixAutoUpdate === true ) {

						uvScaleMap.updateMatrix();

					}

					uniforms.uvTransform.value.copy( uvScaleMap.matrix );

				}

				uniforms.envMap.value = material.envMap;
				uniforms.envMapIntensity.value = material.envMapIntensity;
				uniforms.flipEnvMap.value = ( material.envMap && material.envMap.isCubeTexture ) ? - 1 : 1;

				uniforms.refractionRatio.value = material.refractionRatio;

				uniforms.specular.value.copy( material.specular );
				uniforms.glossiness.value = material.glossiness;

				uniforms.glossinessMap.value = material.glossinessMap;

				uniforms.emissiveMap.value = material.emissiveMap;
				uniforms.bumpMap.value = material.bumpMap;
				uniforms.normalMap.value = material.normalMap;

				uniforms.displacementMap.value = material.displacementMap;
				uniforms.displacementScale.value = material.displacementScale;
				uniforms.displacementBias.value = material.displacementBias;

				if ( uniforms.glossinessMap.value !== null && defines.USE_GLOSSINESSMAP === undefined ) {

					defines.USE_GLOSSINESSMAP = '';
					// set USE_ROUGHNESSMAP to enable vUv
					defines.USE_ROUGHNESSMAP = '';

				}

				if ( uniforms.glossinessMap.value === null && defines.USE_GLOSSINESSMAP !== undefined ) {

					delete defines.USE_GLOSSINESSMAP;
					delete defines.USE_ROUGHNESSMAP;

				}

			}
140768
def _drawLine(self, image):
        """"""
        w, h = image.size
        w *= 5
        h *= 5

        l_image = Image.new('RGBA', (w, h), (0, 0, 0, 0))
        l_draw = ImageDraw.Draw(l_image)

        x1 = int(w * random.uniform(0, 0.1))
        y1 = int(h * random.uniform(0, 1))
        x2 = int(w * random.uniform(0.9, 1))
        y2 = int(h * random.uniform(0, 1))

        # Line width modifier was chosen as an educated guess
        # based on default image area.
        l_width = round((w * h)**0.5 * 2.284e-2)

        # Draw
        l_draw.line(((x1, y1), (x2, y2)), fill=(0, 0, 0, 255), width=l_width)

        # Transform
        l_image = self._rndLineTransform(l_image)
        l_image = l_image.resize(image.size, resample=self.resample)

        # Paste onto image
        image.paste(l_image, (0, 0), l_image)
1193745
public static void drawCube(Se3_F64 targetToCamera, CameraPinholeBrown intrinsic, double width,
								double heightScale, int lineThickness, Graphics2D g2, double scale)
	{
		g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

		double r = width/2.0;
		double h = width*heightScale;

		Point3D_F64 corners[] = new Point3D_F64[8];
		corners[0] = new Point3D_F64(-r,-r,0);
		corners[1] = new Point3D_F64( r,-r,0);
		corners[2] = new Point3D_F64( r, r,0);
		corners[3] = new Point3D_F64(-r, r,0);
		corners[4] = new Point3D_F64(-r,-r,h);
		corners[5] = new Point3D_F64( r,-r,h);
		corners[6] = new Point3D_F64( r, r,h);
		corners[7] = new Point3D_F64(-r, r,h);

		Point2D_F64 pixel[] = new Point2D_F64[8];
		Point2D_F64 p = new Point2D_F64();
		WorldToCameraToPixel transform = PerspectiveOps.createWorldToPixel(intrinsic,targetToCamera);
		for (int i = 0; i < 8; i++) {
			if( !transform.transform(corners[i],p) )
				throw new RuntimeException("Crap");
			pixel[i] = p.copy();
		}

		Line2D.Double l = new Line2D.Double();
		g2.setStroke(new BasicStroke(lineThickness));
		g2.setColor(Color.RED);

		drawLine(g2,l,pixel[0].x, pixel[0].y, pixel[1].x, pixel[1].y,scale);
		drawLine(g2,l,pixel[1].x, pixel[1].y, pixel[2].x, pixel[2].y,scale);
		drawLine(g2,l,pixel[2].x, pixel[2].y, pixel[3].x, pixel[3].y,scale);
		drawLine(g2,l,pixel[3].x, pixel[3].y, pixel[0].x, pixel[0].y,scale);

		g2.setColor(Color.BLACK);
		drawLine(g2,l,pixel[0].x,pixel[0].y,pixel[4].x,pixel[4].y,scale);
		drawLine(g2,l,pixel[1].x,pixel[1].y,pixel[5].x,pixel[5].y,scale);
		drawLine(g2,l,pixel[2].x,pixel[2].y,pixel[6].x,pixel[6].y,scale);
		drawLine(g2,l,pixel[3].x,pixel[3].y,pixel[7].x,pixel[7].y,scale);

		g2.setColor(new Color(0x00,0xFF,0x00,255));
		drawLine(g2,l,pixel[4].x,pixel[4].y,pixel[5].x,pixel[5].y,scale);
		g2.setColor(new Color(0xC0,0x10,0xC0,255));
		drawLine(g2,l,pixel[5].x,pixel[5].y,pixel[6].x,pixel[6].y,scale);
		g2.setColor(new Color(0x00,0xA0,0xC0,255));
		drawLine(g2,l,pixel[6].x,pixel[6].y,pixel[7].x,pixel[7].y,scale);
		g2.setColor(Color.BLUE);
		drawLine(g2,l,pixel[7].x,pixel[7].y,pixel[4].x,pixel[4].y,scale);
	}
1058099
def _draw(self, context, opacity):
        """"""

        # if we have been moved around, we should update bounds
        fresh_draw = len(self.__new_instructions or []) > 0
        if fresh_draw: #new stuff!
            self.paths = []
            self.__instruction_cache = self.__new_instructions
            self.__new_instructions = []
        else:
            if not self.__instruction_cache:
                return

        for instruction, args in self.__instruction_cache:
            if fresh_draw:
                if instruction in ("new_path", "stroke", "fill", "clip"):
                    self.paths.append((instruction, "path", context.copy_path()))

                elif instruction in ("save", "restore", "translate", "scale", "rotate"):
                    self.paths.append((instruction, "transform", args))

            if instruction == "set_color":
                self._set_color(context, args[0], args[1], args[2], args[3] * opacity)
            elif instruction == "show_layout":
                self._show_layout(context, *args)
            elif opacity < 1 and instruction == "paint":
                context.paint_with_alpha(opacity)
            else:
                getattr(context, instruction)(*args)
130568
def draw(self, surfaceObj):
        """"""
        if self._visible:
            if self.buttonDown:
                surfaceObj.blit(self.surfaceDown, self._rect)
            elif self.mouseOverButton:
                surfaceObj.blit(self.surfaceHighlight, self._rect)
            else:
                surfaceObj.blit(self.surfaceNormal, self._rect)
803026
def draw(self):
        """"""
        # update or particle positions by calling the OpenCL kernel
        # self.cle.execute(10)
        OpenGL.GL.glFlush()

        OpenGL.GL.glClear(
            OpenGL.GL.GL_COLOR_BUFFER_BIT | OpenGL.GL.GL_DEPTH_BUFFER_BIT
        )
        if self.white == -1:
            OpenGL.GL.glClearColor(1, 1, 1, 1)
        else:
            OpenGL.GL.glClearColor(0, 0, 0, 0)
        OpenGL.GL.glMatrixMode(OpenGL.GL.GL_MODELVIEW)
        OpenGL.GL.glLoadIdentity()

        # handle mouse transformations
        OpenGL.GL.glTranslatef(
            self.initrans.x, self.initrans.y, self.initrans.z
        )
        OpenGL.GL.glRotatef(self.rotate.x, 1, 0, 0)
        OpenGL.GL.glRotatef(
            self.rotate.y, 0, 1, 0
        )  # we switched around the axis so make this rotate_z
        OpenGL.GL.glTranslatef(
            self.translate.x, self.translate.y, self.translate.z
        )

        # render the matrix
        self.render_image()
        # render the particles
        self.render()

        # draw the x, y and z axis as lines
        glutil.draw_axes()
        # enable 2d display #
        OpenGL.GL.glMatrixMode(OpenGL.GL.GL_PROJECTION)
        OpenGL.GL.glPushMatrix()
        OpenGL.GL.glLoadIdentity()
        OpenGL.GL.glOrtho(0.0, self.width, self.height, 0.0, -1.0, 10.0)
        OpenGL.GL.glMatrixMode(OpenGL.GL.GL_MODELVIEW)
        # glPushMatrix()        ----Not sure if I need this
        OpenGL.GL.glLoadIdentity()
        OpenGL.GL.glDisable(OpenGL.GL.GL_CULL_FACE)

        OpenGL.GL.glClear(OpenGL.GL.GL_DEPTH_BUFFER_BIT)

        # glBegin(GL_LINES)
        # glColor3f(0.0, 1.0, 0.0)
        # glVertex2f(0.0, 0.0)
        # glVertex2f(100.0, 0.0)
        # glVertex2f(100.0, 100.0)
        # glVertex2f(0.0, 100.0)
        # glEnd()

        if self.white == 1:
            self.glut_print(
                10,
                15,
                OpenGL.GLUT.GLUT_BITMAP_9_BY_15,
                self.str_curr_cycle,
                0.0,
                1.0,
                0.0,
                1.0,
            )
            self.glut_print(
                10,
                30,
                OpenGL.GLUT.GLUT_BITMAP_9_BY_15,
                self.str_curr_temp,
                0.0,
                1.0,
                0.0,
                1.0,
            )
            self.glut_print(
                10,
                45,
                OpenGL.GLUT.GLUT_BITMAP_9_BY_15,
                self.str_curr_id_frag,
                0.0,
                1.0,
                0.0,
                1.0,
            )
            self.glut_print(
                10,
                60,
                OpenGL.GLUT.GLUT_BITMAP_9_BY_15,
                self.str_likelihood,
                0.0,
                1.0,
                0.0,
                1.0,
            )
            self.glut_print(
                10,
                75,
                OpenGL.GLUT.GLUT_BITMAP_9_BY_15,
                self.str_n_contigs,
                0.0,
                1.0,
                0.0,
                1.0,
            )
            self.glut_print(
                10,
                90,
                OpenGL.GLUT.GLUT_BITMAP_9_BY_15,
                self.str_curr_dist,
                0.0,
                1.0,
                0.0,
                1.0,
            )
        else:
            self.glut_print(
                10,
                15,
                OpenGL.GLUT.GLUT_BITMAP_9_BY_15,
                self.str_curr_cycle,
                0.0,
                0.0,
                0.0,
                1.0,
            )
            self.glut_print(
                10,
                30,
                OpenGL.GLUT.GLUT_BITMAP_9_BY_15,
                self.str_curr_temp,
                0.0,
                0.0,
                0.0,
                1.0,
            )
            self.glut_print(
                10,
                45,
                OpenGL.GLUT.GLUT_BITMAP_9_BY_15,
                self.str_curr_id_frag,
                0.0,
                0.0,
                0.0,
                1.0,
            )
            self.glut_print(
                10,
                60,
                OpenGL.GLUT.GLUT_BITMAP_9_BY_15,
                self.str_likelihood,
                0.0,
                0.0,
                0.0,
                1.0,
            )
            self.glut_print(
                10,
                75,
                OpenGL.GLUT.GLUT_BITMAP_9_BY_15,
                self.str_n_contigs,
                0.0,
                0.0,
                0.0,
                1.0,
            )
            self.glut_print(
                10,
                90,
                OpenGL.GLUT.GLUT_BITMAP_9_BY_15,
                self.str_curr_dist,
                0.0,
                0.0,
                0.0,
                1.0,
            )

        # self.glut_print( 10 , 15 , GLUT_BITMAP_9_BY_15 , self.str_curr_cycle
        # , 1.0 , 1.0 , 1.0 , 1.0) self.glut_print( 10 , 30 ,
        # GLUT_BITMAP_9_BY_15 , self.str_curr_temp , 1.0 , 1.0 , 1.0 , 1.0)
        # self.glut_print( 10 , 45 , GLUT_BITMAP_9_BY_15 ,
        # self.str_curr_id_frag , 1.0 , 1.0 , 1.0 , 1.0) self.glut_print( 10 ,
        # 60 , GLUT_BITMAP_9_BY_15 , self.str_likelihood , 1.0 , 1.0 , 1.0 ,
        # 1.0) self.glut_print( 10.1 , 60.1 , GLUT_BITMAP_9_BY_15 ,
        # self.str_likelihood , 1.0 , 1.0 , 1.0 , 1.0) self.glut_print( 9.9 ,
        # 59.9, GLUT_BITMAP_9_BY_15 , self.str_likelihood , 1.0 , 1.0 , 1.0 ,
        # 1.0) self.glut_print( 10 , 75 , GLUT_BITMAP_9_BY_15 ,
        # self.str_n_contigs , 1.0 , 1.0 , 1.0 , 1.0) self.glut_print( 10 , 90
        # , GLUT_BITMAP_9_BY_15 , self.str_curr_dist , 1.0 , 1.0 , 1.0 , 1.0)

        # self.glut_print( 10 , 15 , GLUT_BITMAP_9_BY_15 , self.str_curr_cycle
        # , 0.0 , 0.0 , 0.0 , 1.0) self.glut_print( 10 , 30 ,
        # GLUT_BITMAP_9_BY_15 , self.str_curr_temp , 0.0 , 0.0 , 0.0 , 1.0)
        # self.glut_print( 10 , 45 , GLUT_BITMAP_9_BY_15 ,
        # self.str_curr_id_frag , 0.0 , 0.0 , 0.0 , 1.0) self.glut_print( 10 ,
        # 60 , GLUT_BITMAP_9_BY_15 , self.str_likelihood , 0.0 , 0.0 , 0.0 ,
        # 1.0) self.glut_print( 10 , 75 , GLUT_BITMAP_9_BY_15 ,
        # self.str_n_contigs , 0.0 , 0.0 , 0.0 , 1.0) self.glut_print( 10 , 90
        # , GLUT_BITMAP_9_BY_15 , self.str_curr_dist , 0.0 , 0.0 , 0.0 , 1.0)

        # Making sure we can render 3d again
        OpenGL.GL.glMatrixMode(OpenGL.GL.GL_PROJECTION)
        OpenGL.GL.glPopMatrix()
        OpenGL.GL.glMatrixMode(OpenGL.GL.GL_MODELVIEW)
        # glPopMatrix()##        ----and this?

        #############
        OpenGL.GLUT.glutSwapBuffers()
1141755
function Viewport(inspector) {
  // Initialize raycaster and picking in differentpmodule.
  const mouseCursor = initRaycaster(inspector);
  const sceneEl = inspector.sceneEl;

  let originalCamera = inspector.cameras.original;
  sceneEl.addEventListener('camera-set-active', event => {
    // If we're in edit mode, save the newly active camera and activate when exiting.
    if (inspector.opened) {
      originalCamera = event.detail.cameraEl;
    }
  });

  // Helpers.
  const sceneHelpers = inspector.sceneHelpers;
  const grid = new THREE.GridHelper(30, 60, 0xaaaaaa, 0x262626);
  sceneHelpers.add(grid);

  const selectionBox = new THREE.BoxHelper();
  selectionBox.material.depthTest = false;
  selectionBox.material.transparent = true;
  selectionBox.material.color.set(0x1faaf2);
  selectionBox.visible = false;
  sceneHelpers.add(selectionBox);

  function updateHelpers(object) {
    object.traverse(node => {
      if (inspector.helpers[node.uuid]) {
        inspector.helpers[node.uuid].update();
      }
    });
  }

  const camera = inspector.camera;
  const transformControls = new THREE.TransformControls(
    camera,
    inspector.container
  );
  transformControls.size = 0.75;
  transformControls.addEventListener('objectChange', evt => {
    const object = transformControls.object;
    if (object === undefined) {
      return;
    }

    selectionBox.setFromObject(object).update();

    updateHelpers(object);

    Events.emit('refreshsidebarobject3d', object);

    // Emit update event for watcher.
    let component;
    let value;
    if (evt.mode === 'translate') {
      component = 'position';
      value = `${object.position.x} ${object.position.y} ${object.position.z}`;
    } else if (evt.mode === 'rotate') {
      component = 'rotation';
      const d = THREE.Math.radToDeg;
      value = `${d(object.rotation.x)} ${d(object.rotation.y)} ${d(
        object.rotation.z
      )}`;
    } else if (evt.mode === 'scale') {
      component = 'scale';
      value = `${object.scale.x} ${object.scale.y} ${object.scale.z}`;
    }
    Events.emit('entityupdate', {
      component: component,
      entity: transformControls.object.el,
      property: '',
      value: value
    });

    Events.emit('entitytransformed', transformControls.object.el);
  });

  transformControls.addEventListener('mouseDown', () => {
    controls.enabled = false;
  });

  transformControls.addEventListener('mouseUp', () => {
    controls.enabled = true;
  });

  sceneHelpers.add(transformControls);

  Events.on('entityupdate', detail => {
    if (inspector.selectedEntity.object3DMap['mesh']) {
      selectionBox.update(inspector.selected);
    }
  });

  // Controls need to be added *after* main logic.
  const controls = new THREE.EditorControls(camera, inspector.container);
  controls.center.set(0, 1.6, 0);
  controls.rotationSpeed = 0.0035;
  controls.zoomSpeed = 0.05;
  controls.setAspectRatio(sceneEl.canvas.width / sceneEl.canvas.height);

  Events.on('cameratoggle', data => {
    controls.setCamera(data.camera);
    transformControls.setCamera(data.camera);
  });

  function disableControls() {
    mouseCursor.disable();
    transformControls.dispose();
    controls.enabled = false;
  }

  function enableControls() {
    mouseCursor.enable();
    transformControls.activate();
    controls.enabled = true;
  }
  enableControls();

  Events.on('inspectorcleared', () => {
    controls.center.set(0, 0, 0);
  });

  Events.on('transformmodechange', mode => {
    transformControls.setMode(mode);
  });

  Events.on('snapchanged', dist => {
    transformControls.setTranslationSnap(dist);
  });

  Events.on('transformspacechanged', space => {
    transformControls.setSpace(space);
  });

  Events.on('objectselect', object => {
    selectionBox.visible = false;
    transformControls.detach();
    if (object && object.el) {
      if (object.el.getObject3D('mesh')) {
        selectionBox.setFromObject(object).update();
        selectionBox.visible = true;
      }

      transformControls.attach(object);
    }
  });

  Events.on('objectfocus', object => {
    controls.focus(object);
    transformControls.update();
  });

  Events.on('geometrychanged', object => {
    if (object !== null) {
      selectionBox.setFromObject(object).update();
    }
  });

  Events.on('entityupdate', detail => {
    const object = detail.entity.object3D;
    if (inspector.selected === object) {
      // Hack because object3D always has geometry :(
      if (
        object.geometry &&
        ((object.geometry.vertices && object.geometry.vertices.length > 0) ||
          (object.geometry.attributes &&
            object.geometry.attributes.position &&
            object.geometry.attributes.position.array.length))
      ) {
        selectionBox.setFromObject(object).update();
      }
    }

    transformControls.update();
    if (object instanceof THREE.PerspectiveCamera) {
      object.updateProjectionMatrix();
    }

    updateHelpers(object);
  });

  Events.on('windowresize', () => {
    camera.aspect =
      inspector.container.offsetWidth / inspector.container.offsetHeight;
    camera.updateProjectionMatrix();
  });

  Events.on('gridvisibilitychanged', showGrid => {
    grid.visible = showGrid;
  });

  Events.on('togglegrid', () => {
    grid.visible = !grid.visible;
  });

  Events.on('inspectortoggle', active => {
    if (active) {
      enableControls();
      AFRAME.scenes[0].camera = inspector.camera;
      Array.prototype.slice
        .call(document.querySelectorAll('.a-enter-vr,.rs-base'))
        .forEach(element => {
          element.style.display = 'none';
        });
    } else {
      disableControls();
      inspector.cameras.original.setAttribute('camera', 'active', 'true');
      AFRAME.scenes[0].camera = inspector.cameras.original.getObject3D('camera');
      Array.prototype.slice
        .call(document.querySelectorAll('.a-enter-vr,.rs-base'))
        .forEach(element => {
          element.style.display = 'block';
        });
    }
    ga('send', 'event', 'Viewport', 'toggleEditor', active);
  });
}
168845
def from_scene_coords(self, x=0, y=0):
        """"""
        matrix = self.get_matrix()
        matrix.invert()
        return matrix.transform_point(x, y)
1300002
def update_shadow_camera(camera, light)
      shadow_camera = light.shadow_camera
      points_frustum = light.pointa_frustum
      points_world = light.points_world

      @min.set(Float::INFINITY, Float::INFINITY, Float::INFINITY)
      @max.set(-Float::INFINITY, -Float::INFINITY, -Float::INFINITY)

      8.times do |i|
        p = points_world[i]

        p.copy(points_frustum[i])
        p.unproject(camera)

        p.apply_matrix4(shadow_camera.matrix_world_inverse)

        @min.x = p.x if (p.x < @min.x)
        @max.x = p.x if (p.x > @max.x)

        @min.y = p.y if (p.y < @min.y)
        @max.y = p.y if (p.y > @max.y)

        @min.z = p.z if (p.z < @min.z)
        @max.z = p.z if (p.z > @max.z)
      end

      shadow_camera.left = @min.x
      shadow_camera.right = @max.x
      shadow_camera.top = @max.y
      shadow_camera.bottom = @min.y

      # can't really fit near/far
      # shadow_camera.near = @min.x
      # shadow_camera.far = @max.z

      shadow_camera.update_projection_matrix
    end
1169304
function draw(canvas, ctx, data, params, layer) {

		// If width and sWidth are not defined, use image width
		if (params.width === null && params.sWidth === null) {
			params.width = params.sWidth = img.width;
		}
		// If width and sHeight are not defined, use image height
		if (params.height === null && params.sHeight === null) {
			params.height = params.sHeight = img.height;
		}

		// Ensure image layer's width and height are accurate
		if (layer) {
			layer.width = params.width;
			layer.height = params.height;
		}

		// Only crop image if all cropping properties are given
		if (params.sWidth !== null && params.sHeight !== null && params.sx !== null && params.sy !== null) {

			// If width is not defined, use the given sWidth
			if (params.width === null) {
				params.width = params.sWidth;
			}
			// If height is not defined, use the given sHeight
			if (params.height === null) {
				params.height = params.sHeight;
			}

			// Optionally crop from top-left corner of region
			if (params.cropFromCenter) {
				params.sx += params.sWidth / 2;
				params.sy += params.sHeight / 2;
			}

			// Ensure cropped region does not escape image boundaries

			// Top
			if ((params.sy - (params.sHeight / 2)) < 0) {
				params.sy = (params.sHeight / 2);
			}
			// Bottom
			if ((params.sy + (params.sHeight / 2)) > img.height) {
				params.sy = img.height - (params.sHeight / 2);
			}
			// Left
			if ((params.sx - (params.sWidth / 2)) < 0) {
				params.sx = (params.sWidth / 2);
			}
			// Right
			if ((params.sx + (params.sWidth / 2)) > img.width) {
				params.sx = img.width - (params.sWidth / 2);
			}

			_transformShape(canvas, ctx, params, params.width, params.height);
			_setGlobalProps(canvas, ctx, params);

			// Draw image
			ctx.drawImage(
				img,
				params.sx - (params.sWidth / 2),
				params.sy - (params.sHeight / 2),
				params.sWidth,
				params.sHeight,
				params.x - (params.width / 2),
				params.y - (params.height / 2),
				params.width,
				params.height
			);

		} else {
			// Show entire image if no crop region is defined

			_transformShape(canvas, ctx, params, params.width, params.height);
			_setGlobalProps(canvas, ctx, params);

			// Draw image on canvas
			ctx.drawImage(
				img,
				params.x - (params.width / 2),
				params.y - (params.height / 2),
				params.width,
				params.height
			);

		}

		// Draw invisible rectangle to allow for events and masking
		ctx.beginPath();
		ctx.rect(
			params.x - (params.width / 2),
			params.y - (params.height / 2),
			params.width,
			params.height
		);
		// Check for jCanvas events
		_detectEvents(canvas, ctx, params);
		// Close path and configure masking
		ctx.closePath();
		_restoreTransform(ctx, params);
		_enableMasking(ctx, data, params);
	}
89254
void setPerspShadowMatrix(Matrix4f modelMtx, GVRLight light)
    {
        GVRPerspectiveCamera camera = (GVRPerspectiveCamera) getCamera();

        if (camera == null)
        {
            return;
        }
        float angle = light.getFloat("outer_cone_angle");
        float near = camera.getNearClippingDistance();
        float far = camera.getFarClippingDistance();

        angle = (float) Math.acos(angle) * 2.0f;
        modelMtx.invert();
        modelMtx.get(mTempMtx);
        camera.setViewMatrix(mTempMtx);
        camera.setFovY((float) Math.toDegrees(angle));
        mShadowMatrix.setPerspective(angle, 1.0f, near, far);
        mShadowMatrix.mul(modelMtx);
        sBiasMatrix.mul(mShadowMatrix, mShadowMatrix);
        mShadowMatrix.getColumn(0, mTemp);
        light.setVec4("sm0", mTemp.x, mTemp.y, mTemp.z, mTemp.w);
        mShadowMatrix.getColumn(1, mTemp);
        light.setVec4("sm1", mTemp.x, mTemp.y, mTemp.z, mTemp.w);
        mShadowMatrix.getColumn(2, mTemp);
        light.setVec4("sm2", mTemp.x, mTemp.y, mTemp.z, mTemp.w);
        mShadowMatrix.getColumn(3, mTemp);
        light.setVec4("sm3", mTemp.x, mTemp.y, mTemp.z, mTemp.w);
    }
1087416
def matte_point(x, y)
      f = copy
      f.opacity = OpaqueOpacity unless f.alpha?
      pixel = f.pixel_color(x, y)
      pixel.opacity = TransparentOpacity
      f.pixel_color(x, y, pixel)
      f
    end
1191163
def draw(self):
        '''
        
        '''
        observed_arr = self.noise_sampler.generate()
        _ = self.__encoder_decoder_controller.encoder.inference(observed_arr)
        arr = self.__encoder_decoder_controller.encoder.get_feature_points()
        return arr
215666
def draw(self):
        """"""

        # Lines should have a square cap to avoid ugly edges
        self.context.set_line_cap(cairo.LINE_CAP_SQUARE)

        self.context.save()
        self.context.rectangle(*self.rect)
        self.context.clip()

        cell_borders = CellBorders(self.cell_attributes, self.key, self.rect)
        borders = list(cell_borders.gen_all())
        borders.sort(key=attrgetter('width', 'color'))
        for border in borders:
            border.draw(self.context)

        self.context.restore()
356457
function () {
    var cameraEl = this.cameraEl;
    var headMesh;
    var leftEyeMesh;
    var rightEyeMesh;
    var leftEyeBallMesh;
    var rightEyeBallMesh;

    if (cameraEl.getObject3D('mesh') || cameraEl.getObject3D('replayerMesh')) { return; }

    // Head.
    headMesh = new THREE.Mesh();
    headMesh.geometry = new THREE.BoxBufferGeometry(0.3, 0.3, 0.2);
    headMesh.material = new THREE.MeshStandardMaterial({color: 'pink'});
    headMesh.visible = this.data.spectatorMode;

    // Left eye.
    leftEyeMesh = new THREE.Mesh();
    leftEyeMesh.geometry = new THREE.SphereBufferGeometry(0.05);
    leftEyeMesh.material = new THREE.MeshBasicMaterial({color: 'white'});
    leftEyeMesh.position.x -= 0.1;
    leftEyeMesh.position.y += 0.1;
    leftEyeMesh.position.z -= 0.1;
    leftEyeBallMesh = new THREE.Mesh();
    leftEyeBallMesh.geometry = new THREE.SphereBufferGeometry(0.025);
    leftEyeBallMesh.material = new THREE.MeshBasicMaterial({color: 'black'});
    leftEyeBallMesh.position.z -= 0.04;
    leftEyeMesh.add(leftEyeBallMesh);
    headMesh.add(leftEyeMesh);

    // Right eye.
    rightEyeMesh = new THREE.Mesh();
    rightEyeMesh.geometry = new THREE.SphereBufferGeometry(0.05);
    rightEyeMesh.material = new THREE.MeshBasicMaterial({color: 'white'});
    rightEyeMesh.position.x += 0.1;
    rightEyeMesh.position.y += 0.1;
    rightEyeMesh.position.z -= 0.1;
    rightEyeBallMesh = new THREE.Mesh();
    rightEyeBallMesh.geometry = new THREE.SphereBufferGeometry(0.025);
    rightEyeBallMesh.material = new THREE.MeshBasicMaterial({color: 'black'});
    rightEyeBallMesh.position.z -= 0.04;
    rightEyeMesh.add(rightEyeBallMesh);
    headMesh.add(rightEyeMesh);

    cameraEl.setObject3D('replayerMesh', headMesh);
  }