Skip to content

Commit f4a2357

Browse files
Merge branch 'update-line-width-api' into 'master'
[FIX][SDK] remove method that tried to keep all lines at least 1 pixel wide See merge request codingame/game-engine!262
2 parents c1b748a + 8181312 commit f4a2357

File tree

9 files changed

+14
-19
lines changed

9 files changed

+14
-19
lines changed

engine/modules/entities/src/main/java/com/codingame/gameengine/module/entities/Shape.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
*/
1010
public abstract class Shape<T extends BlendableEntity<?>> extends BlendableEntity<T> implements Mask {
1111

12-
private int lineColor = 0x0, lineWidth = 0, fillColor = 0xffffff;
13-
private double fillAlpha = 1, lineAlpha = 1;
12+
private int lineColor = 0x0, fillColor = 0xffffff;
13+
private double fillAlpha = 1, lineAlpha = 1, lineWidth = 0;
1414

1515
Shape() {
1616
super();
@@ -150,7 +150,7 @@ public double getLineAlpha() {
150150
* the width for the border of this <code>Shape</code>.
151151
* @return this <code>Shape</code>.
152152
*/
153-
public T setLineWidth(int lineWidth) {
153+
public T setLineWidth(double lineWidth) {
154154
return setLineWidth(lineWidth, null);
155155
}
156156

@@ -166,7 +166,7 @@ public T setLineWidth(int lineWidth) {
166166
* the transition to animate between values of this property.
167167
* @return this <code>Shape</code>.
168168
*/
169-
public T setLineWidth(int lineWidth, Curve curve) {
169+
public T setLineWidth(double lineWidth, Curve curve) {
170170
this.lineWidth = lineWidth;
171171
set("lineWidth", lineWidth, curve);
172172
return self();
@@ -175,11 +175,11 @@ public T setLineWidth(int lineWidth, Curve curve) {
175175
/**
176176
* Returns the width of the border of this <code>Shape</code> in world units.
177177
* <p>
178-
* Default is 1.
178+
* Default is 0.
179179
*
180180
* @return the width of the border of this <code>Shape</code>.
181181
*/
182-
public int getLineWidth() {
182+
public double getLineWidth() {
183183
return lineWidth;
184184
}
185185

engine/modules/entities/src/main/resources/view/entity-module/Circle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class Circle extends Shape {
3232
if (state.fillColor !== null) {
3333
this.graphics.beginFill(state.fillColor, state.fillAlpha)
3434
}
35-
this.graphics.lineStyle(globalData.atLeastOnePixel(state.lineWidth), state.lineColor)
35+
this.graphics.lineStyle(state.lineWidth, state.lineColor)
3636
this.graphics.drawCircle(0, 0, state.radius * globalData.toWorldUnits)
3737
if (state.fillColor !== null) {
3838
this.graphics.endFill()

engine/modules/entities/src/main/resources/view/entity-module/GraphicEntityModule.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ export class GraphicEntityModule {
1919
maskUpdates: {},
2020
updatedBuffers: [],
2121
players: [],
22-
instanceCount: 0,
23-
atLeastOnePixel: function (width) {
24-
if (width > 0 && width < this.toPixel) {
25-
return this.toPixel
26-
}
27-
return width
28-
}
22+
instanceCount: 0
2923
}
3024

3125
api.entities = this.entities

engine/modules/entities/src/main/resources/view/entity-module/Line.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default class Line extends Shape {
2424
changed.x2 ||
2525
changed.y2) {
2626
this.graphics.clear()
27-
this.graphics.lineStyle(globalData.atLeastOnePixel(state.lineWidth), state.lineColor, state.lineAlpha)
27+
this.graphics.lineStyle(state.lineWidth, state.lineColor, state.lineAlpha)
2828
this.graphics.moveTo(0, 0)
2929
this.graphics.lineTo(-this.container.x + state.x2 * globalData.toWorldUnits, -this.container.y + state.y2 * globalData.toWorldUnits)
3030
}

engine/modules/entities/src/main/resources/view/entity-module/Polygon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class Polygon extends Shape {
2525
this.graphics.beginFill(state.fillColor, state.fillAlpha)
2626
}
2727

28-
this.graphics.lineStyle(globalData.atLeastOnePixel(state.lineWidth), state.lineColor, state.lineAlpha)
28+
this.graphics.lineStyle(state.lineWidth, state.lineColor, state.lineAlpha)
2929
this.graphics.drawPolygon(state.points.map(coord => coord * globalData.toWorldUnits))
3030
if (state.fillColor !== null) {
3131
this.graphics.endFill()

engine/modules/entities/src/main/resources/view/entity-module/Rectangle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class Rectangle extends Shape {
3232
this.graphics.beginFill(state.fillColor, state.fillAlpha)
3333
}
3434

35-
this.graphics.lineStyle(globalData.atLeastOnePixel(state.lineWidth), state.lineColor, state.lineAlpha)
35+
this.graphics.lineStyle(state.lineWidth, state.lineColor, state.lineAlpha)
3636
this.graphics.drawRect(0, 0, state.width * globalData.toWorldUnits, state.height * globalData.toWorldUnits)
3737
if (state.fillColor !== null) {
3838
this.graphics.endFill()

engine/modules/entities/src/main/resources/view/entity-module/RoundedRectangle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class RoundedRectangle extends Shape {
3838
this.graphics.beginFill(state.fillColor, state.fillAlpha)
3939
}
4040

41-
this.graphics.lineStyle(globalData.atLeastOnePixel(state.lineWidth), state.lineColor, state.lineAlpha)
41+
this.graphics.lineStyle(state.lineWidth, state.lineColor, state.lineAlpha)
4242
this.graphics.drawRoundedRect(0, 0,
4343
state.width * globalData.toWorldUnits,
4444
state.height * globalData.toWorldUnits,

engine/modules/entities/src/main/resources/view/entity-module/Text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class Text extends TextureBasedEntity {
3333
this.graphics.text = state.text
3434
this.graphics.style.align = state.textAlign
3535
this.graphics.style.stroke = state.strokeColor
36-
this.graphics.style.strokeThickness = globalData.atLeastOnePixel(state.strokeThickness)
36+
this.graphics.style.strokeThickness = state.strokeThickness
3737
this.graphics.style.fill = state.fillColor
3838
this.graphics.style.fontSize = state.fontSize || 1
3939
this.graphics.style.fontFamily = state.fontFamily

playground/misc/misc-3-release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The CodinGame SDK is regularly updated and improved. This document lets you know
88

99
- Fixed choppy animation when launching games with a `stepByStepAnimateSpeed`
1010
- Fixed situations in which stepping through a game with a `stepByStepAnimateSpeed` would not be animated.
11+
- Remove faulty code that was supposed to ensure all lines were at least 1 pixel thick. User now has greater control over line thickness.
1112

1213
## 3.11.0
1314

0 commit comments

Comments
 (0)