MCPcopy Create free account
hub / github.com/B33pBeeps/redthread / NewNote

Method NewNote

internal/app/notes.go:440–462  ·  view source on GitHub ↗

NewNote places a note at screen-centre converted to world coords, so it appears centred at whatever zoom level the user is on.

(screenW, screenH int)

Source from the content-addressed store, hash-verified

438// NewNote places a note at screen-centre converted to world coords, so it
439// appears centred at whatever zoom level the user is on.
440func (b *Board) NewNote(screenW, screenH int) *Note {
441 now := time.Now().UTC()
442 tint := TintOrder[len(b.Notes)%len(TintOrder)]
443 d := DimsFor(b.Zoom)
444 screenCx := screenW/2 - d.W/2
445 screenCy := screenH/2 - d.H/2
446 offset := (len(b.Notes) % 5) * 2
447 worldX := WorldX(screenCx+offset, b.Zoom)
448 worldY := WorldY(screenCy+offset, b.Zoom)
449 n := &Note{
450 ID: genID(),
451 Title: "",
452 Body: "",
453 X: worldX,
454 Y: worldY,
455 Tint: tint,
456 Created: now,
457 Updated: now,
458 }
459 b.Notes = append(b.Notes, n)
460 b.Selected = n.ID
461 return n
462}
463
464func (b *Board) Delete(id string) {
465 for i, n := range b.Notes {

Callers 1

handleBoardKeyMethod · 0.80

Calls 4

DimsForFunction · 0.85
WorldXFunction · 0.85
WorldYFunction · 0.85
genIDFunction · 0.85

Tested by

no test coverage detected