feat: dynamic arrow drawing
This commit is contained in:
parent
183df0959c
commit
017cf465da
@ -63,6 +63,7 @@ func (r *roomTableData)Tangens() float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type arrowData struct {
|
type arrowData struct {
|
||||||
|
IsVisible bool
|
||||||
Height, Width int
|
Height, Width int
|
||||||
Radius int
|
Radius int
|
||||||
StartX, StartY int
|
StartX, StartY int
|
||||||
@ -72,15 +73,21 @@ type arrowData struct {
|
|||||||
Angle2X, Angle2Y int
|
Angle2X, Angle2Y int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// arrow data - to draw SVG from current speaker to next speaker
|
||||||
func (r *roomTableData)ArrowData() arrowData {
|
func (r *roomTableData)ArrowData() arrowData {
|
||||||
// TODO take total and indexes from room data
|
// TODO figure out size to be around the people
|
||||||
// also figure out size to be around the people
|
|
||||||
// and this is somewhat a win
|
// and this is somewhat a win
|
||||||
height, width := 150.0, 150.0
|
height, width := 150.0, 150.0
|
||||||
centerX, centerY := height/2, width/2
|
centerX, centerY := height/2, width/2
|
||||||
total := 5 // 0 to 4
|
total := r.Total()
|
||||||
startSector := 1
|
// speakerIndex := slices.Index(r.Paricipants, r.CurrentSpeaker)
|
||||||
endSector := 5
|
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 {
|
if endSector < startSector {
|
||||||
endSector += total
|
endSector += total
|
||||||
}
|
}
|
||||||
@ -113,6 +120,7 @@ func (r *roomTableData)ArrowData() arrowData {
|
|||||||
largeArcFlag = 1
|
largeArcFlag = 1
|
||||||
}
|
}
|
||||||
return arrowData{
|
return arrowData{
|
||||||
|
IsVisible: true,
|
||||||
Height: int(height),
|
Height: int(height),
|
||||||
Width: int(width),
|
Width: int(width),
|
||||||
Radius: int(radius),
|
Radius: int(radius),
|
||||||
|
@ -72,11 +72,11 @@
|
|||||||
style="--tan: {{ .Tangens }}; --m: {{ .Total }};"
|
style="--tan: {{ .Tangens }}; --m: {{ .Total }};"
|
||||||
>
|
>
|
||||||
{{ with .ArrowData }}
|
{{ with .ArrowData }}
|
||||||
|
{{ if .IsVisible }}
|
||||||
<svg height="{{.Height}}" width="{{.Width}}"
|
<svg height="{{.Height}}" width="{{.Width}}"
|
||||||
class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"
|
class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"
|
||||||
>
|
>
|
||||||
<g>
|
<g>
|
||||||
<rect height="{{.Height}}" width="{{.Width}}" fill="#EEE" />
|
|
||||||
<path
|
<path
|
||||||
d="M {{.StartX}} {{.StartY}}
|
d="M {{.StartX}} {{.StartY}}
|
||||||
A {{.Radius}} {{.Radius}} 0, {{.LargeArcFlag}}, 1, {{.EndX}} {{.EndY}}"
|
A {{.Radius}} {{.Radius}} 0, {{.LargeArcFlag}}, 1, {{.EndX}} {{.EndY}}"
|
||||||
@ -90,6 +90,7 @@
|
|||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
{{ range .Persons }} {{ template "personBlocks" . }} {{ end }}
|
{{ range .Persons }} {{ template "personBlocks" . }} {{ end }}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user