fix: mark & active brick type

This commit is contained in:
efim 2023-11-23 04:15:11 +00:00
parent fad258a537
commit 3d466953d2
4 changed files with 64 additions and 42 deletions

View File

@ -39,7 +39,7 @@ type roomTableData struct {
currentPerson rooms.PersonId
}
func (room *roomTableData)Persons() []personData {
func (room *roomTableData) Persons() []personData {
total := room.Total()
persons := make([]personData, 0, total)
currentPersonIndex := slices.Index(room.Paricipants, room.currentPerson)
@ -51,10 +51,10 @@ func (room *roomTableData)Persons() []personData {
}
return persons
}
func (r *roomTableData)Total() int {
func (r *roomTableData) Total() int {
return len(r.Paricipants)
}
func (r *roomTableData)Tangens() float64 {
func (r *roomTableData) Tangens() float64 {
total := r.Total()
if total == 2 {
return 1
@ -63,18 +63,18 @@ func (r *roomTableData)Tangens() float64 {
}
type arrowData struct {
IsVisible bool
Height, Width int
Radius int
StartX, StartY int
EndX, EndY int
LargeArcFlag int
IsVisible bool
Height, Width int
Radius int
StartX, StartY int
EndX, EndY int
LargeArcFlag int
Angle1X, Angle1Y 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 figure out size to be around the people
// and this is somewhat a win
height, width := 150.0, 150.0
@ -92,8 +92,8 @@ func (r *roomTableData)ArrowData() arrowData {
endSector += total
}
radius := 50.0
startAngle := 90 + float64(startSector) * ( 360.0 / float64(total) )
endAngle := 90 + float64(endSector) * ( 360.0 / float64(total) )
startAngle := 90 + float64(startSector)*(360.0/float64(total))
endAngle := 90 + float64(endSector)*(360.0/float64(total))
// if need to draw full circle
if startSector == endSector {
startAngle += 3 // a bit forward
@ -103,42 +103,42 @@ func (r *roomTableData)ArrowData() arrowData {
endAngleRad := endAngle * (math.Pi / float64(180))
// endAngle is radius angle, so perpendicular gives direction of teh arrow
x1 := centerX + radius * math.Cos(startAngleRad)
y1 := centerY + radius * math.Sin(startAngleRad)
x2 := centerX + radius * math.Cos(endAngleRad)
y2 := centerY + radius * math.Sin(endAngleRad)
x1 := centerX + radius*math.Cos(startAngleRad)
y1 := centerY + radius*math.Sin(startAngleRad)
x2 := centerX + radius*math.Cos(endAngleRad)
y2 := centerY + radius*math.Sin(endAngleRad)
arrowAngleOffset := math.Pi / 4 // 45 degrees
arrowPointDirection := endAngleRad - math.Pi / 2
arrowPointDirection := endAngleRad - math.Pi/2
arrowheadLen := 10.0
arrowMinusAngle := arrowPointDirection - arrowAngleOffset
arrowPlusAngle := arrowPointDirection + arrowAngleOffset
arrowMinusEndX := x2 + arrowheadLen * math.Cos(arrowMinusAngle)
arrowMinusEndY := y2 + arrowheadLen * math.Sin(arrowMinusAngle)
arrowPlusEndX := x2 + arrowheadLen * math.Cos(arrowPlusAngle)
arrowPlusEndY := y2 + arrowheadLen * math.Sin(arrowPlusAngle)
arrowMinusEndX := x2 + arrowheadLen*math.Cos(arrowMinusAngle)
arrowMinusEndY := y2 + arrowheadLen*math.Sin(arrowMinusAngle)
arrowPlusEndX := x2 + arrowheadLen*math.Cos(arrowPlusAngle)
arrowPlusEndY := y2 + arrowheadLen*math.Sin(arrowPlusAngle)
// indicates that the shorter of the two possible arcs should be used.
largeArcFlag := 0
//
if endAngleRad - startAngleRad > (math.Pi) {
if endAngleRad-startAngleRad > (math.Pi) {
// specifies that the longer arc should be chosen.
largeArcFlag = 1
}
return arrowData{
IsVisible: true,
Height: int(height),
Width: int(width),
Radius: int(radius),
StartX: int(x1),
StartY: int(y1),
EndX: int(x2),
EndY: int(y2),
IsVisible: true,
Height: int(height),
Width: int(width),
Radius: int(radius),
StartX: int(x1),
StartY: int(y1),
EndX: int(x2),
EndY: int(y2),
LargeArcFlag: largeArcFlag,
Angle1X: int(arrowMinusEndX),
Angle1Y: int(arrowMinusEndY),
Angle2X: int(arrowPlusEndX),
Angle2Y: int(arrowPlusEndY),
Angle1X: int(arrowMinusEndX),
Angle1Y: int(arrowMinusEndY),
Angle2X: int(arrowPlusEndX),
Angle2Y: int(arrowPlusEndY),
}
}
@ -169,7 +169,7 @@ func personDataFromRoom(room *roomTableData, pId rooms.PersonId) personData {
}
}
func (pData personData)BricksForPerson() []brickState {
func (pData personData) BricksForPerson() []brickState {
var result = make([]brickState, 5)
for gesture := rooms.ChangeTopic; gesture <= rooms.Meta; gesture++ {
// for index := rooms.Meta; index >= rooms.ChangeTopic; index-- {
@ -177,6 +177,8 @@ func (pData personData)BricksForPerson() []brickState {
// this results in iteration 4,3,2,1,0,255 wow
templateType := "inactiveBrick"
switch {
case pData.IsRaised && pData.IsMark && gesture == pData.Raised:
templateType = "markAndRaisedBrick"
case pData.IsMark && gesture == pData.Mark:
templateType = "markBrick"
case pData.IsSpeaker && gesture == pData.Raised:
@ -225,6 +227,10 @@ func roomTemplatesPreview(
Id: rooms.PersonId(300),
Name: "test person name 3",
}
var person4 = rooms.Person{
Id: rooms.PersonId(400),
Name: "test person name 4",
}
aRoom := rooms.Room{
Name: "test",
CurrentSpeaker: person3.Id,
@ -232,18 +238,22 @@ func roomTemplatesPreview(
person1.Id: person1,
person2.Id: person2,
person3.Id: person3,
person4.Id: person4,
},
Paricipants: []rooms.PersonId{
person1.Id,
person2.Id,
person3.Id,
person4.Id,
},
ParticipantHands: map[rooms.PersonId]rooms.HandGesture{
person3.Id: rooms.ClarifyingQ,
person2.Id: rooms.Meta,
person4.Id: rooms.ChangeTopic,
},
Marks: map[rooms.HandGesture]rooms.PersonId{
rooms.Expand: person1.Id,
rooms.Expand: person1.Id,
rooms.ChangeTopic: person4.Id,
},
}
@ -282,8 +292,8 @@ func roomTemplatesPreview(
},
},
TestPerson: testPersonData,
ARoom: &roomTableData{
Room: &aRoom,
ARoom: &roomTableData{
Room: &aRoom,
currentPerson: aRoom.Paricipants[0],
},
}

View File

@ -628,8 +628,8 @@ video {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-cols-5 {
grid-template-columns: repeat(5, minmax(0, 1fr));
.grid-cols-6 {
grid-template-columns: repeat(6, minmax(0, 1fr));
}
.grid-rows-\[auto\2c 1fr\] {

View File

@ -26,6 +26,14 @@
X
</div>
{{ end }}
{{ define "markAndRaisedBrick" }}
<div
class="h-[var(--brick-height)] w-20 border-[hsl(var(--brick-color))] border bg-[hsl(var(--brick-color))]/25 grid place-content-center font-bold text-[hsl(var(--brick-color))]/50"
style="--brick-color: var({{.}}); --brick-height: calc(var(--d)/5)"
>
X
</div>
{{ end }}
<h2>Now for BrickData taking parametrized template name</h2>
{{ define "brick" }}
@ -37,6 +45,8 @@
{{ template "speakerBrick" .ColorClass }}
{{ else if eq .TemplateType "markBrick" }}
{{ template "markBrick" .ColorClass }}
{{ else if eq .TemplateType "markAndRaisedBrick" }}
{{ template "markAndRaisedBrick" .ColorClass }}
{{ end }}
{{end}}

View File

@ -1,19 +1,21 @@
{{define "main-content"}}
<div style="--d: 10rem">
<div style="--d: 10rem;">
<h2>For each type</h2>
<section class="grid grid-cols-5 border-4 gap-4">
<section class="grid grid-cols-6 border-4 gap-4">
<p>types:</p>
<p> inactive </p>
<p> raised </p>
<p> speaker </p>
<p> mark </p>
<p> mark and active </p>
{{ range .Bricks }}
<div class="border-2">for {{ .Name }}</div>
<div>{{ template "inactiveBrick" .ColorClass }}</div>
<div>{{ template "raisedBrick" .ColorClass }}</div>
<div>{{ template "speakerBrick" .ColorClass }}</div>
<div>{{ template "markBrick" .ColorClass }}</div>
<div>{{ template "markAndRaisedBrick" .ColorClass }}</div>
{{ end }}
</section>