Make a screenshot of the current view. You can tweak the
    resolution up to what your GPU memory supports.
    
    By defaults it uses the current window resolution.
    
    Example::

      screenshot('screen.png', 1200, 1200)
491306
def screenshot(filename, width=None, height=None):
    '''
    
    '''
    width = width or viewer.widget.width()
    height = height or viewer.widget.height()
    
    img = viewer.widget.toimage(width, height)
    img.save(filename)
729765
def update_screen(self):
        """"""
        self.clock.tick(self.FPS)
        pygame.display.update()
1130911
def screen_resolution():
    
    w = 0
    h = 0
    try:
        # Windows
        import ctypes
        user32 = ctypes.windll.user32
        w, h = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
    except AttributeError:
        try:
            # Mac OS X
            import AppKit
            size = AppKit.NSScreen.screens()[0].frame().size
            w, h = int(size.width), int(size.height)
        except ImportError:
            try:
                # Linux
                import Xlib
                import Xlib.display
                display = Xlib.display.Display()
                root = display.screen().root
                size = root.get_geometry()
                w, h = size.width, size.height
            except ImportError:
                w = 1920
                h = 1080

    return w, h
1372149
def display(self):
        """"""
        if self.data is None:
            return

        if self.scene is not None:
            self.y_scrollbar_value = self.verticalScrollBar().value()
            self.scene.clear()

        self.create_chan_labels()
        self.create_time_labels()

        window_start = self.parent.value('window_start')
        window_length = self.parent.value('window_length')

        time_height = max([x.boundingRect().height() for x in self.idx_time])
        label_width = window_length * self.parent.value('label_ratio')
        scene_height = (len(self.idx_label) * self.parent.value('y_distance') +
                        time_height)

        self.scene = QGraphicsScene(window_start - label_width,
                                    0,
                                    window_length + label_width,
                                    scene_height)
        self.setScene(self.scene)

        self.idx_markers = []
        self.idx_annot = []
        self.idx_annot_labels = []

        self.add_chan_labels()
        self.add_time_labels()
        self.add_traces()
        self.display_grid()
        self.display_markers()
        self.display_annotations()

        self.resizeEvent(None)
        self.verticalScrollBar().setValue(self.y_scrollbar_value)
        self.parent.info.display_view()
        self.parent.overview.display_current()
708024
def fit_to_window(self):
        ''''''
        state = self.state
        self.dragpos = wx.Point(0, 0)
        client_area = state.frame.GetClientSize()
        self.zoom = min(float(client_area.x) / self.img.GetWidth(),
                        float(client_area.y) / self.img.GetHeight())
        self.need_redraw = True
102630
def from_size(cls, data, width, height):
        # type: (bytearray, int, int) -> ScreenShot
        

        monitor = {"left": 0, "top": 0, "width": width, "height": height}
        return cls(data, monitor)
1164364
def world_to_view(v):
    """"""
    return v.x * config.scale_x, v.y * config.scale_y
944556
function() {
        // set world size
        me.game.viewport.bounds.resize(2000, 2000);

        // add background to the game world
        me.game.world.addChild(new me.ImageLayer(0, 0, {image:"grid", z:1}));

        var leftContainer = document.querySelector("#leftPanel .controls");
        var rightContainer = document.querySelector("#rightPanel .controls");
        var controller = game.EmitterController = new game.ParticleEditor.EmitterController(rightContainer);
        var emitterList = game.EmitterList = new game.ParticleEditor.EmitterList(controller, leftContainer);
        game.CodeGenerator = new game.ParticleEditor.CodeGenerator(controller, leftContainer);

        // start the default emitter example
        game.changeEmitter();

        // enable the keyboard
        me.input.bindKey(me.input.KEY.X, "moveEmitter", false, false);
        me.input.bindKey(me.input.KEY.C, "moveViewport", false, false);

        // map the left button click on the enter key
        me.input.bindPointer(me.input.pointer.LEFT, me.input.KEY.X);
        me.input.bindPointer(me.input.pointer.MIDDLE, me.input.KEY.C);

        // flush cached html layout after we added the editor elements
        me.video.onresize();

        // listen to mouse movement
        var viewport = me.game.viewport;
        var mousepos = me.input.pointer.pos;
        var lastX = mousepos.x, lastY = mousepos.y;
        me.event.subscribe(me.event.POINTERMOVE, function() {
            if (me.input.isKeyPressed("moveEmitter")) {
                var pos;
                for ( var emitters = emitterList.emitters, i = emitters.length, obj; i--, (obj = emitters[i]);) {
                    if (!obj.floating) {
                        pos = viewport.localToWorld(mousepos.x, mousepos.y);
                    } else {
                        pos = mousepos;
                    }
                    obj.pos.x = pos.x - obj.width / 2;
                    obj.pos.y = pos.y - obj.height / 2;
                }

                me.event.publish("propertyChanged", [ game.EmitterController.emitter ]);
            }
            if (me.input.isKeyPressed("moveViewport")) {
                viewport.move(lastX - mousepos.x, lastY - mousepos.y);
            }
            lastX = mousepos.x;
            lastY = mousepos.y;
        });
    }
1284671
def addFrame(self):
        """"""
        fr = "/tmp/vpvid/" + str(len(self.frames)) + ".png"
        screenshot(fr)
        self.frames.append(fr)
618844
def display_view(self):
        """"""
        self.idx_start.setText(str(self.parent.value('window_start')))
        self.idx_length.setText(str(self.parent.value('window_length')))
        self.idx_scaling.setText(str(self.parent.value('y_scale')))
        self.idx_distance.setText(str(self.parent.value('y_distance')))
870176
def draw_screen(self, size):
        
        self.tui.clear()
        canvas = self.top.render(size, focus=True)
        self.tui.draw_screen(size, canvas)
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;
		}
	}
550608
def render_scene(self):
        ""
        self.init_gl()
        glfw.MakeContextCurrent(self.window)
        self.renderer.render_scene()
        glfw.SwapBuffers(self.window)
        glfw.PollEvents()
353167
def display(self, image):
        
        assert(image.size == self.size)
        self._last_image = image

        surface = self.to_surface(self.preprocess(image), alpha=self._contrast)
        rawbytes = self._pygame.image.tostring(surface, "RGB", False)
        image = Image.frombytes("RGB", surface.get_size(), rawbytes)

        scr_width = self._terminal_size()[1]
        scale = float(scr_width) / image.width

        self._CSI('1;1H')  # Move to top/left

        for (fg, bg) in self._generate_art(image, int(image.width * scale), int(image.height * scale)):
            self._CSI('38;5;{0};48;5;{1}m'.format(fg, bg))
            sys.stdout.write('▄')

        self._CSI('0m')
        sys.stdout.flush()
456142
def screenshot(self, scale=None, quality=None):
        
        output_dir = BuiltIn().get_variable_value('${OUTPUTDIR}')
        ts = time.time()
        st = datetime.datetime.fromtimestamp(ts).strftime('%Y%m%d%H%M%S')
        screenshot_path = '%s%s%s.png' % (output_dir, os.sep, st)
        self.device.screenshot(screenshot_path, scale, quality)
        logger.info('\n<a href="%s">%s</a><br><img src="%s">' % (screenshot_path, st, screenshot_path), html=True)
662157
function screenSize() {
        // Viewport width
        var iw = win.innerWidth || html.clientWidth,
            ow = win.outerWidth || win.screen.width;
        
        api.screen['innerWidth'] = iw;
        api.screen['outerWidth'] = ow;
        

        // START old code
        var w = win.outerWidth || html.clientWidth;

        // remove earlier widths
        html.className = html.className.replace(/ (w|lt|portrait|no-portrait|landscape|no-landscape)-\d+/g, "");

        // add new ones
        pushClass("w-" + Math.round(w / 100) * 100);

        each(conf.screens, function (width) {
            if (w <= width) {
                pushClass("lt-" + width);
            }
        });
        // END old code

        // Viewport height
        var ih = win.innerHeight || html.clientHeight,
            oh = win.outerHeight || win.screen.height;

        api.screen['innerHeight'] = ih;
        api.screen['outerHeight'] = oh;
        
        // no need for onChange event to detect this
        api.feature("portrait" , (ih > iw));
        api.feature("landscape", (ih < iw));
    }
727977
def render_scene(self):
        ""
        self.init_gl() # should be a no-op after the first frame is rendered
        glfw.make_context_current(self.window)
        self.renderer.render_scene()
        # Done rendering
        # glfw.swap_buffers(self.window) # avoid double buffering to avoid stalling
        glFlush() # single buffering
        glfw.poll_events()