Skip to content

Commit f688fb5

Browse files
committed
LineWidth field names adjusted
Names are now shorter and more consistent with the fill event. Also, lines don't have a concrete start / end, so the names didn't really make sense anyway.
1 parent f7e78a3 commit f688fb5

File tree

4 files changed

+53
-51
lines changed

4 files changed

+53
-51
lines changed

internal/frontend/templates/lobby.html

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,9 @@
12411241
} else if (parsed.type === "non-guessing-player-message") {
12421242
appendMessage("non-guessing-player-message", parsed.data.author, parsed.data.content);
12431243
} else if (parsed.type === "line") {
1244-
drawLine(context, parsed.data.fromX, parsed.data.fromY, parsed.data.toX, parsed.data.toY, parsed.data.color, parsed.data.lineWidth);
1244+
drawLine(context, parsed.data.x, parsed.data.y,
1245+
parsed.data.x2, parsed.data.y2, parsed.data.color,
1246+
parsed.data.width);
12451247
} else if (parsed.type === "fill") {
12461248
if (floodfillUint8ClampedArray(
12471249
imageData.data,
@@ -1773,10 +1775,10 @@
17731775
imageData.width, imageData.height);
17741776
} else if (drawElement.type === "line") {
17751777
_drawLine(
1776-
drawData.fromX, drawData.fromY,
1777-
drawData.toX, drawData.toY,
1778+
drawData.x, drawData.y,
1779+
drawData.x2, drawData.y2,
17781780
drawData.color,
1779-
drawData.lineWidth);
1781+
drawData.width);
17801782
} else {
17811783
console.log("Unknown draw element type: " + drawData.type);
17821784
}
@@ -2001,12 +2003,12 @@
20012003
const drawInstruction = {
20022004
type: "line",
20032005
data: {
2004-
fromX: x1Scaled,
2005-
fromY: y1Scaled,
2006-
toX: x2Scaled,
2007-
toY: y2Scaled,
2006+
x: x1Scaled,
2007+
y: y1Scaled,
2008+
x2: x2Scaled,
2009+
y2: y2Scaled,
20082010
color: color,
2009-
lineWidth: localLineWidth,
2011+
width: localLineWidth,
20102012
}
20112013
};
20122014
socket.send(JSON.stringify(drawInstruction));

internal/game/lobby.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ func (lobby *Lobby) HandleEvent(eventType string, payload []byte, player *Player
117117

118118
// In case the line is too big, we overwrite the data of the event.
119119
// This will prevent clients from lagging due to too thick lines.
120-
if line.Data.LineWidth > MaxBrushSize {
121-
line.Data.LineWidth = MaxBrushSize
122-
} else if line.Data.LineWidth < MinBrushSize {
123-
line.Data.LineWidth = MinBrushSize
120+
if line.Data.Width > MaxBrushSize {
121+
line.Data.Width = MaxBrushSize
122+
} else if line.Data.Width < MinBrushSize {
123+
line.Data.Width = MinBrushSize
124124
}
125125

126126
now := time.Now()

internal/game/shared.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ type RGBColor struct {
104104
type LineEvent struct {
105105
Type string `json:"type"`
106106
Data struct {
107-
FromX int16 `json:"fromX"`
108-
FromY int16 `json:"fromY"`
109-
ToX int16 `json:"toX"`
110-
ToY int16 `json:"toY"`
111-
Color RGBColor `json:"color"`
112-
LineWidth uint8 `json:"lineWidth"`
107+
X int16 `json:"x"`
108+
Y int16 `json:"y"`
109+
X2 int16 `json:"x2"`
110+
Y2 int16 `json:"y2"`
111+
Color RGBColor `json:"color"`
112+
Width uint8 `json:"width"`
113113
} `json:"data"`
114114
}
115115

internal/game/shared_easyjson.go

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)