lines

package
v0.1.74 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lines finds the lines of a sheet: the strokes that stand at one height, told apart by the gaps between them down the sheet. The record mode of the board proposes a sheet's lines with it and finds on which line an erasure took its strokes, and the journal of the writing process groups with it all the strokes of a sheet, the erased ones too (internal/journal).

It also finds the groups of strokes a device finds, by the eval protocol's rule of groups, and where an erasure stood on the plane on a sheet whose markup is made of parts. A free-form solution — a number line, a drawing, a note at the side — has no lines down the sheet, so that is what its sheets go by.

Index

Constants

View Source
const (
	GroupPause  = 2000 // milliseconds
	GroupAcross = 50   // sheet units
	GroupDown   = 50   // sheet units
)

The rule of stroke groups of the eval protocol, canvas's as it is, with no merge of tutor's own: two strokes are neighbours when no more than GroupPause milliseconds lie between them, from the end of the earlier to the start of the later, and the boxes of their points come within GroupAcross units of each other across the sheet and within GroupDown units down it. Each bound is included. A group is the strokes a chain of neighbours joins.

View Source
const Gap = 12

Gap is the least step, in the sheet's logical units, from the middle of one stroke to the middle of the next one down the sheet that starts a new line. Group raises it to half the height of a typical stroke of the sheet, so that it follows the size of the handwriting. It is a guess made before any sheet was written, and the journal of the writing process may tune it; the markup of a sheet already saved does not change.

Variables

This section is empty.

Functions

func Band

func Band(strokes ...sample.Stroke) (top, bottom float64, ok bool)

Band returns the band of the sheet strokes take together, from their highest point down to their lowest; ok is false when they have no points.

func ErasureLine

func ErasureLine(s *sample.Sample, e sample.Erasure) int

ErasureLine is the number of the line of a sample's markup that most of an erasure's strokes stood on, by the bands of the lines, the higher on the sheet of two that hold as many, or 0 when none of them stood on a line. The markup's lines need not stand in order down the sheet.

func ErasurePart

func ErasurePart(s *sample.Sample, e sample.Erasure) int

ErasurePart is the place of an erasure on the plane, for a sheet whose markup is made of parts, as a plan of version 1 makes it: the number of the part most of the erasure's strokes stood on, the earlier in the markup of two that hold as many, or 0 when none of them stood on a part. Where a stroke stood is PartsTaken's.

func Neighbours

func Neighbours(a, b sample.Stroke) bool

Neighbours reports whether two strokes are neighbours by the rule of groups. A stroke without points is no stroke's neighbour.

func On

func On(top, bottom float64, ls []Line, gap float64) int

On returns the index of the line a band of the sheet stands on: the line it overlaps the most, or else the nearest one, less than gap away; -1 when it stands on none. Of two lines it overlaps as much, the higher one is taken.

func Tenths

func Tenths(v float64) int64

Tenths is a place in whole tenths of a unit, as a sample file keeps them, rounded half up: 100.05 units are 1000.5 tenths, which make 1001. The product is rounded on its own, float64(…), so that it fuses with nothing (see internal/synth). The groups and the crop (internal/render) count in them, as canvas's do.

Types

type Line

type Line struct {
	Strokes     []string
	Top, Bottom float64
}

Line is one line that Group finds: its strokes, in the order they were written, and the band of the sheet it takes, from its highest point down to its lowest.

func Group

func Group(strokes []sample.Stroke, gap float64) []Line

Group finds the lines of a sheet's strokes, top to bottom. A stroke stands at the middle of its band, from its highest point down to its lowest. Down the sheet, a step between the middles of two strokes of at least gap, or of half the median height of the sheet's strokes if that is more, starts a new line. The middles, not the ends, decide: a tall digit or a long tail of a letter reaches towards the next line, but its middle stays on its own. A line of small strokes near a line of the writing joins it, as below. A stroke without points is on no line. The strokes come in the order they were written, as a sample keeps them, and each line keeps that order; a line's band runs over all of its strokes, so two bands may overlap.

type StrokeGroup

type StrokeGroup struct {
	// Label is the group's label by place, as a device gives it: A to Z, then AA, AB and on, by
	// the top of its rectangle, then its left, its bottom and its right, then its earliest start.
	Label string
	// Strokes are its strokes, in the order they were written.
	Strokes []string
	// Erased are the erased strokes that would be neighbours of its strokes, in the order they
	// were written. An erased stroke is of every group that holds one: of two groups, or of none.
	Erased []string
	// Top, Left, Bottom and Right are its rectangle around the points of its strokes, in sheet
	// units. Erased strokes change neither the rectangle nor the label.
	Top, Left, Bottom, Right float64
}

StrokeGroup is one group of the strokes a sheet shows, as a device groups them. A part of a sheet's plan is one group or several: a drawing redrawn after a pause is two.

func Groups

func Groups(strokes []sample.Stroke, erasures []sample.Erasure) []StrokeGroup

Groups finds the groups of the strokes a sheet shows: the strokes no erasure took, in the order their first strokes were written. It counts as canvas counts, so that a device and the runner find the same groups to the bit: places in whole tenths of a unit, rounded half up, and times in whole milliseconds, and then it only subtracts and compares. A stroke without points is of no group.

type Taken

type Taken struct {
	From map[int]int
	Line int
}

Taken is what an erasure took from the lines or the parts of a sheet: how many of its strokes stood on each, by its number, and the one most of them stood on — of two that hold as many, the higher line or the earlier part — or 0 when none of them stood on one.

func PartsTaken

func PartsTaken(s *sample.Sample, erasures []sample.Erasure) []Taken

PartsTaken finds what each erasure took from the parts of a sample's markup, by the place of the strokes on the plane, as ErasurePart names its part: of two parts that hold as many of its strokes, the earlier in the markup is its Line. An erased stroke stood on the part that holds the stroke on the sheet nearest to it, when their boxes come within the rule of groups' place, GroupAcross across and GroupDown down. Near is the larger of the two gaps between the boxes, and of two parts as near, the earlier in the markup takes it: an axis, an arc, a bar or a brace touches more than one part. The rule's time does not count, as a part written again after a pause has no neighbours in time, and strokes of no part do not count either.

func TakenFrom

func TakenFrom(byID map[string]sample.Stroke, erasures []sample.Erasure, found []Line) []Taken

TakenFrom finds what each erasure took from lines that stand top to bottom, as Group gives them. A stroke stood on the line its band stands on (On), and a stroke of an ID the strokes do not hold stood on none.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL