// NewFrame returns a new frame around the given primitive. The primitive's
// size will be changed to fit within this frame.
199355
func NewFrame(primitive Primitive) *Frame {
	box := NewBox()

	f := &Frame{
		Box:       box,
		primitive: primitive,
		top:       1,
		bottom:    1,
		header:    1,
		footer:    1,
		left:      1,
		right:     1,
	}

	f.focus = f

	return f
}
129900
func (s *RedisDeviceStore) Frames(appEUI types.AppEUI, devEUI types.DevEUI) (FrameHistory, error) {
	return &RedisFrameHistory{
		appEUI: appEUI,
		devEUI: devEUI,
		store:  s.frameStore,
	}, nil
}
1366377
func New(path string) (*Framework, error) {
	conf, err := config.NewConfig(path)
	if err != nil {
		return nil, err
	}

	return NewWithConfig(conf)
}
587641
func NewFrameReader(frames <-chan *StreamFrame, errCh <-chan error, cancelCh chan struct{}) *FrameReader {
	return &FrameReader{
		frames:   frames,
		errCh:    errCh,
		cancelCh: cancelCh,
	}
}
810116
func NewBuffer(size int64) (*Buffer, error) {
	if size <= 0 {
		return nil, fmt.Errorf("Size must be positive")
	}

	b := &Buffer{
		size: size,
		data: make([]byte, size),
	}
	return b, nil
}
822091
func NewBox(top, left, right, bottom int) Box {
	return Box{
		IsSet:  true,
		Top:    top,
		Left:   left,
		Right:  right,
		Bottom: bottom,
	}
}
358228
func NewBox(pos vect.Vect, w, h vect.Float) *Shape {
	shape := newShape()

	box := &BoxShape{
		Polygon:  &PolygonShape{Shape: shape},
		Width:    w,
		Height:   h,
		Position: pos,
		Shape:    shape,
	}

	hw := w / 2.0
	hh := h / 2.0

	if hw < 0 {
		hw = -hw
	}
	if hh < 0 {
		hh = -hh
	}

	box.verts = [4]vect.Vect{
		{-hw, -hh},
		{-hw, hh},
		{hw, hh},
		{hw, -hh},
	}

	poly := box.Polygon
	poly.SetVerts(box.verts[:], box.Position)

	shape.ShapeClass = box
	return shape
}
791313
func WriteFrame(w io.Writer, frame []byte) (int, error) {
	count, err := writeFrameHeader(w, uint64(len(frame)))
	if err != nil {
		return count, err
	}

	amount, err := w.Write(frame)
	count += amount
	if err != nil {
		return count, err
	}

	return count, nil
}
469148
func NewPosition(StartLine int, EndLine int, StartPos int, EndPos int) *Position {
	return &Position{
		StartLine: StartLine,
		EndLine:   EndLine,
		StartPos:  StartPos,
		EndPos:    EndPos,
	}
}
510404
func (f *framer) readFrame(head *frameHeader) error {
	if head.length < 0 {
		return fmt.Errorf("frame body length can not be less than 0: %d", head.length)
	} else if head.length > maxFrameSize {
		// need to free up the connection to be used again
		_, err := io.CopyN(ioutil.Discard, f.r, int64(head.length))
		if err != nil {
			return fmt.Errorf("error whilst trying to discard frame with invalid length: %v", err)
		}
		return ErrFrameTooBig
	}

	if cap(f.readBuffer) >= head.length {
		f.rbuf = f.readBuffer[:head.length]
	} else {
		f.readBuffer = make([]byte, head.length)
		f.rbuf = f.readBuffer
	}

	// assume the underlying reader takes care of timeouts and retries
	n, err := io.ReadFull(f.r, f.rbuf)
	if err != nil {
		return fmt.Errorf("unable to read frame body: read %d/%d bytes: %v", n, head.length, err)
	}

	if head.flags&flagCompress == flagCompress {
		if f.compres == nil {
			return NewErrProtocol("no compressor available with compressed frame body")
		}

		f.rbuf, err = f.compres.Decode(f.rbuf)
		if err != nil {
			return err
		}
	}

	f.header = head
	return nil
}
202628
func MustCompileFrame(f Frame) []byte {
	bts, err := CompileFrame(f)
	if err != nil {
		panic(err)
	}
	return bts
}
1109875
func (t *Trace) Frames() []Frame {
	if t.frames == nil {
		t.frames = make([]Frame, len(t.stack))

		for i, pc := range t.stack {
			t.frames[i] = NewFrame(pc)
		}
	}

	return t.frames
}
598846
func (e *EncodeSession) ReadFrame() (frame []byte, err error) {
	f := <-e.frameChannel
	if f == nil {
		return nil, io.EOF
	}

	return f.data, nil
}
1068797
func NewButtonBlockElement(actionID, value string, text *TextBlockObject) *ButtonBlockElement {
	return &ButtonBlockElement{
		Type:     metButton,
		ActionID: actionID,
		Text:     text,
		Value:    value,
	}
}
234639
func (rf *RawFrame) ToFrame(out *Frame) error {
	if err := ParseTelemetry(rf[:], &out.Status); err != nil {
		return err
	}

	rawPix := rf[telemetryPacketCount*vospiDataSize:]
	i := 0
	for y := 0; y < FrameRows; y++ {
		for x := 0; x < FrameCols; x++ {
			out.Pix[y][x] = binary.BigEndian.Uint16(rawPix[i : i+2])
			i += 2
		}
	}
	return nil
}
1326183
func (buf *FloatBuffer) NumFrames() int {
	if buf == nil || buf.Format == nil {
		return 0
	}
	numChannels := buf.Format.NumChannels
	if numChannels == 0 {
		numChannels = 1
	}

	return len(buf.Data) / numChannels
}
288476
func NewReader(read io.Reader, opt ...Opt) framing.Reader {
	debug.Log("new frame reader")
	r := &reader{Scanner: bufio.NewScanner(read)}
	r.Split(func(data []byte, atEOF bool) (int, []byte, error) {
		// Scanner panics if we invoke Split after scanning has started,
		// use this proxy func as a work-around.
		return r.splitf(data, atEOF)
	})
	buf := make([]byte, 16*1024)
	r.Buffer(buf, 1<<22) // 1<<22 == max protobuf size
	r.splitf = r.splitSize
	// apply options
	for _, f := range opt {
		if f != nil {
			f(r)
		}
	}
	return r
}