From 017cf465da4e12f1970bacba066d4d8586eb5d81 Mon Sep 17 00:00:00 2001 From: efim Date: Tue, 21 Nov 2023 19:21:36 +0000 Subject: [PATCH] feat: dynamic arrow drawing --- routes/room_page_templates_preview.go | 18 +++++++++++++----- routes/templates/tableTemplates.gohtml | 3 ++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/routes/room_page_templates_preview.go b/routes/room_page_templates_preview.go index c0fabec..3ef963d 100644 --- a/routes/room_page_templates_preview.go +++ b/routes/room_page_templates_preview.go @@ -63,6 +63,7 @@ func (r *roomTableData)Tangens() float64 { } type arrowData struct { + IsVisible bool Height, Width int Radius int StartX, StartY int @@ -72,15 +73,21 @@ type arrowData struct { Angle2X, Angle2Y int } +// arrow data - to draw SVG from current speaker to next speaker func (r *roomTableData)ArrowData() arrowData { - // TODO take total and indexes from room data - // also figure out size to be around the people + // TODO figure out size to be around the people // and this is somewhat a win height, width := 150.0, 150.0 centerX, centerY := height/2, width/2 - total := 5 // 0 to 4 - startSector := 1 - endSector := 5 + total := r.Total() + // speakerIndex := slices.Index(r.Paricipants, r.CurrentSpeaker) + currentPersonIndex := slices.Index(r.Paricipants, r.currentPerson) + nextSpeakerIndex, found, countedFromIndex := r.NextSpeakerIndex() + if !found { + return arrowData{} + } + startSector := countedFromIndex + total - currentPersonIndex + endSector := nextSpeakerIndex + total - currentPersonIndex if endSector < startSector { endSector += total } @@ -113,6 +120,7 @@ func (r *roomTableData)ArrowData() arrowData { largeArcFlag = 1 } return arrowData{ + IsVisible: true, Height: int(height), Width: int(width), Radius: int(radius), diff --git a/routes/templates/tableTemplates.gohtml b/routes/templates/tableTemplates.gohtml index 4778fa1..c6d7e13 100644 --- a/routes/templates/tableTemplates.gohtml +++ b/routes/templates/tableTemplates.gohtml @@ -72,11 +72,11 @@ style="--tan: {{ .Tangens }}; --m: {{ .Total }};" > {{ with .ArrowData }} + {{ if .IsVisible }} - {{ end }} + {{ end }} {{ range .Persons }} {{ template "personBlocks" . }} {{ end }} {{end}}