// Screenshot takes a screenshot of the first node matching the selector.
347221
func Screenshot(sel interface{}, picbuf *[]byte, opts ...QueryOption) Action {
	if picbuf == nil {
		panic("picbuf cannot be nil")
	}

	return QueryAfter(sel, func(ctx context.Context, nodes ...*cdp.Node) error {
		if len(nodes) < 1 {
			return fmt.Errorf("selector `%s` did not return any nodes", sel)
		}

		// get box model
		box, err := dom.GetBoxModel().WithNodeID(nodes[0].NodeID).Do(ctx)
		if err != nil {
			return err
		}

		// check box
		if len(box.Margin) != 8 {
			return ErrInvalidBoxModel
		}

		// scroll to node position
		var pos []int
		err = EvaluateAsDevTools(fmt.Sprintf(scrollJS, int64(box.Margin[0]), int64(box.Margin[1])), &pos).Do(ctx)
		if err != nil {
			return err
		}

		// take page screenshot
		buf, err := page.CaptureScreenshot().Do(ctx)
		if err != nil {
			return err
		}

		// load image
		img, err := png.Decode(bytes.NewReader(buf))
		if err != nil {
			return err
		}

		// crop to box model contents
		cropped := imaging.Crop(img, image.Rect(
			int(box.Margin[0])-pos[0], int(box.Margin[1])-pos[1],
			int(box.Margin[4])-pos[0], int(box.Margin[5])-pos[1],
		))

		// encode
		var croppedBuf bytes.Buffer
		if err := png.Encode(&croppedBuf, cropped); err != nil {
			return err
		}

		*picbuf = croppedBuf.Bytes()

		return nil
	}, append(opts, NodeVisible)...)
}
1223735
func (d Ploop) Snapshot() (string, error) {
	uuid, err := UUID()
	if err != nil {
		return "", err
	}

	return uuid, ploop("snapshot", "-u", uuid, d.dd)
}
790556
func (h *Client) ScreenColors(screenColors string) *Client {
	h.screenColors = screenColors
	h.screenColorsSet = true
	return h
}
519849
func (net *Network) startWithSnapshots(id enode.ID, snapshots map[string][]byte) error {
	net.lock.Lock()
	defer net.lock.Unlock()

	node := net.getNode(id)
	if node == nil {
		return fmt.Errorf("node %v does not exist", id)
	}
	if node.Up() {
		return fmt.Errorf("node %v already up", id)
	}
	log.Trace("Starting node", "id", id, "adapter", net.nodeAdapter.Name())
	if err := node.Start(snapshots); err != nil {
		log.Warn("Node startup failed", "id", id, "err", err)
		return err
	}
	node.SetUp(true)
	log.Info("Started node", "id", id)
	ev := NewEvent(node)
	net.events.Send(ev)

	// subscribe to peer events
	client, err := node.Client()
	if err != nil {
		return fmt.Errorf("error getting rpc client  for node %v: %s", id, err)
	}
	events := make(chan *p2p.PeerEvent)
	sub, err := client.Subscribe(context.Background(), "admin", events, "peerEvents")
	if err != nil {
		return fmt.Errorf("error getting peer events for node %v: %s", id, err)
	}
	go net.watchPeerEvents(id, events, sub)
	return nil
}
392617
func (c *LayerTree) LoadSnapshot(tiles []*LayerTreePictureTile) (string, error) {
	var v LayerTreeLoadSnapshotParams
	v.Tiles = tiles
	return c.LoadSnapshotWithParams(&v)
}
1361025
func (c consoleRenderer) ConsoleTable() template.HTML {
	var buffer bytes.Buffer
	// The first node is a dummy node
	for _, column := range c.Table.Children() {
		column.RenderHTML(&buffer, 1, c.MaxDepth)
	}
	return template.HTML(buffer.String())
}
705915
func CaptureScreenshot(res *[]byte) Action {
	if res == nil {
		panic("res cannot be nil")
	}

	return ActionFunc(func(ctx context.Context) error {
		var err error
		*res, err = page.CaptureScreenshot().Do(ctx)
		return err
	})
}
100458
func (remote *RemoteDebugger) SaveScreenshot(filename string, perm os.FileMode, quality int, fromSurface bool) error {
	var format string
	ext := filepath.Ext(filename)
	switch ext {
	case ".jpg":
		format = "jpeg"
	case ".png":
		format = "png"
	default:
		return errors.New("Image format not supported")
	}
	rawScreenshot, err := remote.CaptureScreenshot(format, quality, fromSurface)
	if err != nil {
		return err
	}
	return ioutil.WriteFile(filename, rawScreenshot, perm)
}
896647
def take_node_screenshot(self, element, screenshot_path):
        from PIL import Image
        

        temp_path = os.path.join(tempdir, screenshot_path)

        el_x = int(element.location['x'])
        el_y = int(element.location['y'])
        el_height = int(element.size['height'])
        el_width = int(element.size['width'])

        if el_height == 0 or el_width == 0:
            self.debug_log("take_node_screenshot cannot be taken because element width or height equal zero")  # noqa
            return False

        bounding_box = (
            el_x,
            el_y,
            (el_x + el_width),
            (el_y + el_height)
        )

        self._driver.save_screenshot(temp_path)

        base_image = Image.open(temp_path)

        cropped_image = base_image.crop(bounding_box)

        base_image = base_image.resize(cropped_image.size)

        base_image.paste(cropped_image, (0, 0))

        base_image.save(screenshot_path)

        """
        except Exception as e:
            tb = traceback.format_exc()
            print unicode(tb)
            embed()
        """
553327
func (fsm *SimpleFSM) Snapshot() (raft.FSMSnapshot, error) {
	fsm.mu.Lock()
	defer fsm.mu.Unlock()
	copied := make([][]byte, len(fsm.logs))
	copy(copied, fsm.logs)
	return &SimpleSnapshot{copied, len(copied)}, nil
}
175531
func (t *StandardTimer) Snapshot() Timer {
	t.mutex.Lock()
	defer t.mutex.Unlock()
	return &TimerSnapshot{
		histogram: t.histogram.Snapshot().(*HistogramSnapshot),
		meter:     t.meter.Snapshot().(*MeterSnapshot),
	}
}
734983
func (s *Store) Snapshot() (snapshot *Store) {
	coll := copyColl(*(*map[string]*Collection)(atomic.LoadPointer(&s.coll)))
	res := &Store{
		coll:      unsafe.Pointer(&coll),
		file:      s.file,
		size:      atomic.LoadInt64(&s.size),
		readOnly:  true,
		callbacks: s.callbacks,
	}
	for _, name := range collNames(coll) {
		collOrig := coll[name]
		coll[name] = &Collection{
			store:    res,
			compare:  collOrig.compare,
			rootLock: collOrig.rootLock,
			root:     collOrig.rootAddRef(),
		}
	}
	return res
}
216601
func (rs *RaftStorage) Snapshot() raftpb.Snapshot {
	sn, _ := rs.ram.Snapshot() // Snapshot always returns nil error
	return sn
}
806530
func (s *ExpDecaySample) Snapshot() Sample {
	s.mutex.Lock()
	defer s.mutex.Unlock()
	vals := s.values.Values()
	values := make([]int64, len(vals))
	for i, v := range vals {
		values[i] = v.v
	}
	return &SampleSnapshot{
		count:  s.count,
		values: values,
	}
}
248162
func (kvm *Clone) Snapshot(wr io.Writer) error {
	kvm.mu.RLock()
	defer kvm.mu.RUnlock()
	data, err := json.Marshal(kvm.keys)
	if err != nil {
		return err
	}
	if _, err := wr.Write(data); err != nil {
		return err
	}
	return nil
}
1061245
func (buf *Buffer) ClsScreen() error {
	var written uint32
	coords := new(coord)

	csbi := new(consoleScreenBufferInfo)
	ret, _, err := getConsoleScreenBufferInfo.Call(buf.Out.Fd(),
		uintptr(unsafe.Pointer(csbi)))
	if ret == 0 {
		return err
	}

	// Clear everything from 0,0.
	ret, _, err = fillConsoleOutputCharacter.Call(buf.Out.Fd(), uintptr(' '),
		uintptr(csbi.size.x*csbi.size.y), uintptr(*(*int32)(unsafe.Pointer(coords))),
		uintptr(unsafe.Pointer(&written)))
	if ret == 0 {
		return err
	}

	// Set cursor at 0,0.
	ret, _, err = setConsoleCursorPosition.Call(buf.Out.Fd(),
		uintptr(*(*int32)(unsafe.Pointer(coords))))
	if ret == 0 {
		return err
	}

	return buf.Refresh()
}
494086
func (c LoginClient) LoginOneshot(ctx context.Context, __arg LoginOneshotArg) (err error) {
	err = c.Cli.Call(ctx, "keybase.1.login.loginOneshot", []interface{}{__arg}, nil)
	return
}