Documentation
¶
Overview ¶
Package protocol is spec's eval protocol in tutor's code: the package novatrail.eval.v1, whose messages Sample and Report are the sample file and the runner's report. It reads and writes their files, folds a history of writing into the strokes a sheet shows, and holds the rules of a workbook's boxes and of snapping that the device and the runner share. The groups of strokes and the crop are internal/lines' and internal/render's, and their tests pass spec's vectors too.
The messages are the generated code of the module github.com/altnovatrail/spec/contracts, at the tag of the spec submodule: code on Go takes a contract from it and generates none of its own. Whether a file keeps the rules of the protocol is spec's check sample-check to say, and tutor writes no check of its own: this package reads a file strictly, as spec's contracts text asks, and no more.
Index ¶
- Constants
- func BoxOf(points []*evalv1.FinalPoint, boxes []*evalv1.PageBox) int
- func ByEraser(e *evalv1.HistoryEvent) bool
- func ErasureEvents(h *evalv1.History) []*evalv1.HistoryEvent
- func Final(strokes []*evalv1.FinalStroke) []sample.Stroke
- func FinalOf(f Folded) []*evalv1.FinalStroke
- func MarshalReport(r *evalv1.Report) ([]byte, error)
- func MarshalSample(s *evalv1.Sample) ([]byte, error)
- func ReadReport(r io.Reader) (*evalv1.Report, error)
- func ReadSample(r io.Reader) (*evalv1.Sample, error)
- func Snap(set *evalv1.CropSet, crop *evalv1.Crop, box *observationv1.CropBox, ...) ([]int32, *evalv1.TenthsBox)
- func StrokeID(id int32) string
- func StrokeNumber(id string) (int32, error)
- func StrokeStyleOf(st *sample.Style) *evalv1.StrokeStyle
- func StyleOf(st *evalv1.StrokeStyle) *sample.Style
- func Table(strokes []*evalv1.FinalStroke, boxes []*evalv1.PageBox) []*evalv1.FilledBox
- type Folded
Constants ¶
const ( BoxMargin = 120 BoxLimit = 1600 SnapMargin = 250 SnapAbove = 2 SnapBelow = 3 )
The numbers of the rules of boxes and of snapping, as the vectors repeat them. A stroke's box is no wider and no taller than BoxLimit thousandths of a box of the page that holds it, and its middle lies in the box widened by BoxMargin thousandths of the box's size. A box of a model, widened by SnapMargin thousandths of the height of the digits drawn, takes a stroke when it holds SnapAbove / SnapBelow of its points or more. The margin and the share are parameters of eval, which eval may choose anew by its own data, and a new choice comes in a new package.
const Protocol = "novatrail.eval.v1"
Protocol is what a file of the protocol names in its field "protocol": the package, whose last component is the version of the contract.
Variables ¶
This section is empty.
Functions ¶
func BoxOf ¶
func BoxOf(points []*evalv1.FinalPoint, boxes []*evalv1.PageBox) int
BoxOf is the box of a workbook's page that a stroke of these points fills, by the rule of boxes: its index in the page's boxes, in the task's order, or −1 when no box holds the stroke and it is the draft. A box holds the stroke when its size and its middle do; of those, the stroke's is the one with the most of its points in the box widened, and of those the earliest.
func ByEraser ¶ added in v0.1.64
func ByEraser(e *evalv1.HistoryEvent) bool
ByEraser reports whether an event is a move of the eraser: an erase, which takes strokes whole, or a cut, which takes only what it passes over.
func ErasureEvents ¶ added in v0.1.10
func ErasureEvents(h *evalv1.History) []*evalv1.HistoryEvent
ErasureEvents are the events of a history that Ink's erasures come from, one to each in its order: an erase, a cut, a clear or an undo. The record mode tells by them a move of the eraser (ByEraser) from a slip, which Undo and Clear make.
func Final ¶
func Final(strokes []*evalv1.FinalStroke) []sample.Stroke
Final are the strokes of a final geometry as tutor's code takes the strokes of a sheet: their points along each, with no time, and their style.
func FinalOf ¶ added in v0.1.7
func FinalOf(f Folded) []*evalv1.FinalStroke
FinalOf are the strokes a folded history shows at the end as strokes of a final geometry, in the order they were written: each with its ID, its points, with no time, and its style. The table of boxes of a workbook takes them (Table), since the rule of boxes takes a stroke's points alone.
func MarshalReport ¶
MarshalReport writes a runner's report as MarshalSample writes a sample file.
func MarshalSample ¶
MarshalSample writes a sample file as spec's contracts text has it: the protobuf names, and every field, its zero too. It is indented by two spaces and ends with a newline, as spec's examples are, and the same message gives the same bytes on every build. spec's check compares the values a file holds, not its bytes.
func ReadReport ¶
ReadReport reads a runner's report as ReadSample reads a sample file.
func ReadSample ¶
ReadSample reads a sample file: its protocol first, and a file of any other refused, and then the message strictly, a field the message does not have refused. An error of the protocol is a *sample.FormatError at the path "protocol".
func Snap ¶
func Snap(set *evalv1.CropSet, crop *evalv1.Crop, box *observationv1.CropBox, strokes []*evalv1.FinalStroke) ([]int32, *evalv1.TenthsBox)
Snap is what a box of a model on a crop of the work takes: the IDs of the strokes it takes, ascending, and the box of their points in tenths; or none, nil and nil, when it takes no stroke. The crop is one of the set, and the strokes are those its set was drawn of. The box is widened first by SnapMargin thousandths of the crop's height drawn and takes a stroke when it holds k of its n points, k ≥ 1 and SnapBelow × k ≥ SnapAbove × n. In eval, the strokes are those a history of writing shows, never a sample's final geometry, whose points may be other than those that came.
func StrokeID ¶
StrokeID is a stroke's ID of the protocol as tutor's code names a stroke: its number in decimal digits, so that the strokes of a sample and of a group keep the order of their IDs when they are compared as numbers.
func StrokeNumber ¶
StrokeNumber is the stroke's ID of the protocol that StrokeID spells: decimal digits alone, a whole number from 1 that an int32 holds.
func StrokeStyleOf ¶ added in v0.1.64
func StrokeStyleOf(st *sample.Style) *evalv1.StrokeStyle
StrokeStyleOf is a style of tutor's code as the protocol writes it, or nil for none: StyleOf back.
func StyleOf ¶ added in v0.1.64
func StyleOf(st *evalv1.StrokeStyle) *sample.Style
StyleOf is a stroke's style of the protocol as tutor's code takes it, or nil for none. A kind of pen the protocol does not name is PenNone, which the crop refuses.
Types ¶
type Folded ¶
Folded is a history of writing folded into the strokes the sheet shows at the end: every stroke written, in the order of its event, and the IDs of those shown at the end and of those written and not shown, each ascending.
func Fold ¶
Fold folds a history by adding and taking off IDs alone, with no rule of the stack of undo: write adds its stroke, erase and clear take off the strokes they name, cut takes off the strokes it names and adds its pieces, each a stroke written, and undo takes off the strokes it removed and adds back those it restored. Whether a history keeps the rules of a sample file — strokes written once, taken off only while shown — is sample-check's to say; Fold folds any.
func Ink ¶
Ink is a history as tutor's code takes the strokes of a sheet (internal/sample): every stroke written, a piece of a cut too, in the order of its event, with its points and their times and its style, and the erasures — at each event that took off a stroke the sheet does not show at the end for the last time, those strokes, in the event's order. So a stroke the eraser took off and an undo put back is in no erasure, and an undo that took off a stroke just written is an erasure of it: the strokes shown and those not shown are the fold's, and the moment each went is the one the sheet last lost it. A point has no pressure: the protocol holds none.
A piece of a cut comes onto the sheet at its cut, its Since, though its points keep the times of the stroke it was cut of, by which the rule of groups takes it.
It gives the fold too, whose IDs say which strokes the sheet shows at the end.
What Ink gives is no sample of tutor-sample v0, and its check does not hold it: a stroke of a history may end while another action lands.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package protocoltest gives tests spec's examples of the eval protocol: the synthetic sample files and reports of contracts/examples/eval/v1/.
|
Package protocoltest gives tests spec's examples of the eval protocol: the synthetic sample files and reports of contracts/examples/eval/v1/. |