power_bar.dart 626 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
part of game;

class PowerBar extends NodeWithSize {
  PowerBar(Size size, [this.power = 1.0]) : super(size);

  double power;

  Paint _paintFill = new Paint()
    ..color = new Color(0xffffffff);
  Paint _paintOutline = new Paint()
    ..color = new Color(0xffffffff)
    ..strokeWidth = 1.0
13
    ..style = ui.PaintingStyle.stroke;
14 15 16 17 18 19 20 21

  void paint(PaintingCanvas canvas) {
    applyTransformForPivot(canvas);

    canvas.drawRect(new Rect.fromLTRB(0.0, 0.0, size.width - 0.0, size.height - 0.0), _paintOutline);
    canvas.drawRect(new Rect.fromLTRB(2.0, 2.0, (size.width - 2.0) * power, size.height - 2.0), _paintFill);
  }
}