Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cut ¶
Cut removes a piece of the cast event stream as specified by `from` and `to`.
It assumes that the provided `cast` is entirely valid (see `github.com/gvcgo/asciinema-edit/cast#Validate`).
If `from == to`:
the exact timestamp is removed.
If `from < to`:
all timestamps from `from` to `to` are removed (both included).
1. search a time that is close to `from`; then 2. search a time that is close to `to`; then 3. remove all in between; then 4. adjust the time of the remaining.
func Quantize ¶
func Quantize(c *cast.Cast, ranges []QuantizeRange) (err error)
Quantize constraints a set of inputs that lie in a range to a single value that corresponds to the lower bound of such range.
For instance, consider the following timestamps:
1 2 5 9 10 11
Assuming that we quantize over [2,6), we'd cut any delays between 2 and 6 seconds to 2 second:
1 2 4 6 7 8
This can be more easily visualized by looking at the delay quantization:
delta = 1.000000 | qdelta = 1.000000 delta = 3.000000 | qdelta = 2.000000 delta = 4.000000 | qdelta = 2.000000 delta = 1.000000 | qdelta = 1.000000 delta = 1.000000 | qdelta = 1.000000
The euristic is:
- capture all delays
- for each delay, check if it's within an acceptable delay range
- if it fits, reduce the delay to the maximum allowed (floor of the quantization range).
- adjust the rest of the event stream.
Types ¶
type QuantizeRange ¶
type QuantizeRange struct { // From indicates the start of the range From float64 // To indicates the end of the range To float64 }
QuantizeRange describes a quantization range.
When applied to a quantization function, any values that lie in the range are trimmed to `from`.
func (*QuantizeRange) InRange ¶
func (q *QuantizeRange) InRange(value float64) bool
InRange verifies whether a given value lies within the quantization range.
func (*QuantizeRange) RangeOverlaps ¶
func (q *QuantizeRange) RangeOverlaps(another QuantizeRange) bool
Overlaps verifies whether a given range (`another`) overlaps with this range.