Skip to content

Commit

Permalink
LineWidth field names adjusted
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Bios-Marcel committed Nov 17, 2024
1 parent f7e78a3 commit f688fb5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 51 deletions.
20 changes: 11 additions & 9 deletions internal/frontend/templates/lobby.html
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,9 @@
} else if (parsed.type === "non-guessing-player-message") {
appendMessage("non-guessing-player-message", parsed.data.author, parsed.data.content);
} else if (parsed.type === "line") {
drawLine(context, parsed.data.fromX, parsed.data.fromY, parsed.data.toX, parsed.data.toY, parsed.data.color, parsed.data.lineWidth);
drawLine(context, parsed.data.x, parsed.data.y,
parsed.data.x2, parsed.data.y2, parsed.data.color,
parsed.data.width);
} else if (parsed.type === "fill") {
if (floodfillUint8ClampedArray(
imageData.data,
Expand Down Expand Up @@ -1773,10 +1775,10 @@
imageData.width, imageData.height);
} else if (drawElement.type === "line") {
_drawLine(
drawData.fromX, drawData.fromY,
drawData.toX, drawData.toY,
drawData.x, drawData.y,
drawData.x2, drawData.y2,
drawData.color,
drawData.lineWidth);
drawData.width);
} else {
console.log("Unknown draw element type: " + drawData.type);
}
Expand Down Expand Up @@ -2001,12 +2003,12 @@
const drawInstruction = {
type: "line",
data: {
fromX: x1Scaled,
fromY: y1Scaled,
toX: x2Scaled,
toY: y2Scaled,
x: x1Scaled,
y: y1Scaled,
x2: x2Scaled,
y2: y2Scaled,
color: color,
lineWidth: localLineWidth,
width: localLineWidth,
}
};
socket.send(JSON.stringify(drawInstruction));
Expand Down
8 changes: 4 additions & 4 deletions internal/game/lobby.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ func (lobby *Lobby) HandleEvent(eventType string, payload []byte, player *Player

// In case the line is too big, we overwrite the data of the event.
// This will prevent clients from lagging due to too thick lines.
if line.Data.LineWidth > MaxBrushSize {
line.Data.LineWidth = MaxBrushSize
} else if line.Data.LineWidth < MinBrushSize {
line.Data.LineWidth = MinBrushSize
if line.Data.Width > MaxBrushSize {
line.Data.Width = MaxBrushSize
} else if line.Data.Width < MinBrushSize {
line.Data.Width = MinBrushSize
}

now := time.Now()
Expand Down
12 changes: 6 additions & 6 deletions internal/game/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ type RGBColor struct {
type LineEvent struct {
Type string `json:"type"`
Data struct {
FromX int16 `json:"fromX"`
FromY int16 `json:"fromY"`
ToX int16 `json:"toX"`
ToY int16 `json:"toY"`
Color RGBColor `json:"color"`
LineWidth uint8 `json:"lineWidth"`
X int16 `json:"x"`
Y int16 `json:"y"`
X2 int16 `json:"x2"`
Y2 int16 `json:"y2"`
Color RGBColor `json:"color"`
Width uint8 `json:"width"`
} `json:"data"`
}

Expand Down
64 changes: 32 additions & 32 deletions internal/game/shared_easyjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f688fb5

Please sign in to comment.