Closed mnordine closed 7 years ago
I just looked at it but can't reproduce the error. Could you please send me a small example?
I think I've narrowed it down:
import 'dart:html' as html;
import 'package:stagexl/stagexl.dart';
main() {
var canvas = html.querySelector('#stage');
var stage = new Stage(canvas, width: 1280, height: 800);
new RenderLoop()..addStage(stage);
final holder = new Sprite()..addTo(stage);
final format = new TextFormat('Helvetica, Arial, sans-serif', 20, Color.Black);
final t = new TextField('', format)
..autoSize = TextFieldAutoSize.CENTER
..addTo(holder);
t.parent.width = 0.0;
print(t.parent.width); // NaN
}
There was a division by zero in width
, height
setters:
set width(num value) {
var bounds = this.bounds;
var matrix = this.transformationMatrix;
var boundsTransformed = matrix.transformRectangle(bounds, bounds);
var scale = value == 0 ? 0 : value / boundsTransformed.width; // <= Fix
// var scale = value / boundsTransformed.width; // <= division by zero
_reverseMatrix(matrix.a * scale, matrix.b, matrix.c * scale, matrix.d);
}
Would you like me to submit a pull request? Or do you see issues with the fix?
No need for a pull request. I will do some tests (tomorrow) and then provide a new version. Thanks for the bug report!
Similar issue discussed here: https://groups.google.com/forum/#!topic/stagexl/hfIUlhmfYE4
I've pushed an update (20ecb406741a7c53c0e4d3edb73601c327830247). Could you please try if this fixes your problems?
Looks good!
Run-time render errors are being thrown due to this commit:
and