Add code components 366-385; ScrollArea Follow, editor sync
A terminal with history, a Go-colored code block, a log viewer that follows, a hex viewer, a memory map, a JSON tree, a line diff, a GAME OVER crash screen, an FPS meter, profiler bars, breakpoints, variables, command history, a shortcut list, a debug grid, a pixel editor that exports string art, a palette editor, a sprite sheet, a glyph map and a 6502 register view. layout.ScrollArea takes Follow, and ChatLog now uses it. data.TreeNode takes a Value drawn in its Slot. pixel gains Has, and Sprite.Art writes MustSprite art. pixel.Editor takes the caller's value at each input event, so a value changed between frames is never typed onto.
This commit is contained in:
42 files changed
+3415
-37
No files matched your search
@@ -107,6 +107,30 @@ func SpriteOf(w, h int, at func(x, y int) (Slot, bool)) *Sprite {
|
||||
return &Sprite{W: w, H: h, frames: [][]int8{px}}
|
||||
}
|
||||
|
||||
// Art writes s as MustSprite reads it, frames apart.
|
||||
func (s *Sprite) Art() string {
|
||||
var b strings.Builder
|
||||
for f, px := range s.frames {
|
||||
if f > 0 {
|
||||
b.WriteByte('\n')
|
||||
}
|
||||
for y := range s.H {
|
||||
for _, v := range px[y*s.W : (y+1)*s.W] {
|
||||
switch v {
|
||||
case cellClear:
|
||||
b.WriteByte('.')
|
||||
case cellInk:
|
||||
b.WriteByte('#')
|
||||
default:
|
||||
b.WriteByte(artSlots[v])
|
||||
}
|
||||
}
|
||||
b.WriteByte('\n')
|
||||
}
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// Mirror returns s flipped left to right.
|
||||
func (s *Sprite) Mirror() *Sprite {
|
||||
m := &Sprite{W: s.W, H: s.H}
|
||||
|
||||
Reference in new issue
Block a user