fredsa / playn

Cross platform game library for N≥4 platforms
0 stars 1 forks source link

Canvas.restore() doesn't restore strokeWidth on Android (v1.7) #240

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
To reproduce, compile something like the following for Java and Android:

CanvasImage image = graphics().createImage(100, 100);
Canvas canvas = image.canvas();
canvas.save();
canvas.setStrokeWidth(10);
canvas.restore();
canvas.setStrokeColor(Color.rgb(255, 255, 255));
canvas.drawLine(0, 0, 100, 100);
canvas.strokeRect(10, 10, 80, 80);
graphics().rootLayer().add(graphics().createImageLayer(image));

What is the expected output? What do you see instead?
2. Run as a Java Application - the line is of width 1. This is the desired 
output.
3. Run on Android (2.3 - 4.2) - the line is of width 10 instead.

What version of the product are you using? On what operating system?
PlayN v1.7 (with three-rings library)
Windows 7/Java 1.6
Android 2.3.5 and 4.2.2

Please provide any additional information below.
It looks like AndroidCanvasState 
(http://code.google.com/p/playn/source/browse/android/src/playn/android/AndroidC
anvasState.java) fails to keep track of stroke width as it does stroke color, 
etc:
AndroidCanvasState(Paint paint, int fillColor, int strokeColor, AndroidGradient 
gradient,
      AndroidPattern pattern, Composite composite, float alpha) {
    this.paint = paint;
    this.fillColor = fillColor;
    this.strokeColor = strokeColor;
    this.gradient = gradient;
    this.pattern = pattern;
    this.composite = composite;
    this.alpha = alpha;
  }

Two screenshots are attached.

Original issue reported on code.google.com by thomaswp...@gmail.com on 18 Jun 2013 at 8:46

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed in 9532e777d4d5e99683e06822ac187b5ffee8fa02.

Original comment by m...@samskivert.com on 22 Jun 2013 at 10:17