Skip to content

Commit 029f2d5

Browse files
dmullisdmullis
authored andcommitted
Refactor for readability; comments
1 parent c789d45 commit 029f2d5

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

canvas.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ type (
1212

1313
// Characters where more than one line segment can come together.
1414
var jointRunes = []rune{
15-
'.',
16-
'\'',
15+
'.', // possible ... top corner of a 90 degree angle, or curve
16+
'\'', // possible ... bottom corner of a 90 degree angle, or curve
1717
'+',
1818
'*',
1919
'o',
@@ -84,7 +84,7 @@ func isJoint(r rune) bool {
8484
return contains(jointRunes, r)
8585
}
8686

87-
// XX rename 'isCircle()'?
87+
// XX rename 'isSpot()'?
8888
func isDot(r rune) bool {
8989
return r == 'o' || r == '*'
9090
}

drawable.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,19 +372,20 @@ func (c *Canvas) getLinesForSegment(segment rune) []Line {
372372
return nil
373373
}
374374

375-
return c.getLines(iter, segment, passThroughs, orientation)
375+
return c.getLines(segment, iter, orientation, passThroughs)
376376
}
377377

378-
// ci: the order that we traverse locations on the canvas.
379-
// segment: the primary character we're tracking for this line.
380-
// passThroughs: characters the line segment is allowed to be drawn underneath
381-
// (without terminating the line).
378+
// segment: the primary character expected along a continuing Line
379+
// ci: the order that the loop below traverse locations on the canvas.
382380
// orientation: the orientation for this line.
381+
// passThroughs: characters that will produce a mark that the line segment
382+
// is allowed to be drawn either through or, in the case of 'o', "underneath" --
383+
// without terminating the line.
383384
func (c *Canvas) getLines(
384-
ci canvasIterator,
385385
segment rune,
386-
passThroughs []rune,
386+
ci canvasIterator,
387387
o Orientation,
388+
passThroughs []rune,
388389
) (lines []Line) {
389390
// Helper to throw the current line we're tracking on to the slice and
390391
// start a new one.
@@ -401,6 +402,7 @@ func (c *Canvas) getLines(
401402
currentLine := Line{orientation: o}
402403
lastSeenRune := ' '
403404

405+
// X Purpose of the '+1' overscan is to reset lastSeenRune to ' ' upon wrapping the minor axis.
404406
for idx := range ci(c.Width+1, c.Height+1) {
405407
r := c.runeAt(idx)
406408

0 commit comments

Comments
 (0)