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)
| 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. |
| 440 | func (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 | |
| 464 | func (b *Board) Delete(id string) { |
| 465 | for i, n := range b.Notes { |
no test coverage detected