paint method

  1. @override
void paint(
  1. Canvas canvas,
  2. Size size
)
override

Main paint method that draws the entire graph. canvas is the canvas to draw on. size is the size of the canvas.

Implementation

@override
void paint(Canvas canvas, Size size) {
  screenHeight = size.height;
  screenWidth = size.width;

  pixelsPerOneCM = screenHeight / 16;
  pixelsPerOneMM = pixelsPerOneCM / 10;

  leftOffsetStart = size.width * 0.07;
  topOffsetEnd = size.height * 0.9;
  drawingWidth = size.width * 0.93;
  drawingHeight = topOffsetEnd;

  graphGridMainLines = Paint()
    ..color = Colors.grey[600]!
    ..strokeWidth = pixelsPerOneMM * 0.25;
  graphGridLines = Paint()
    ..color = Colors.grey[700]!
    ..strokeWidth = pixelsPerOneMM * 0.20;
  graphGridSubLines = Paint()
    ..color = Colors.grey[700]!
    ..strokeWidth = pixelsPerOneMM * 0.10;
  graphOutlines = Paint()
    ..color = Colors.grey[500]!
    ..strokeWidth = pixelsPerOneMM * .40;
  graphSafeZone = Paint()
    ..color = const Color.fromARGB(34, 123, 250, 66)
    ..strokeWidth = pixelsPerOneMM * .30;
  graphUnSafeZone = Paint()
    ..color = const Color.fromARGB(90, 250, 30, 0)
    ..strokeWidth = pixelsPerOneMM * .30;
  graphNoiseZone = Paint()
    ..color = const Color.fromARGB(100, 169, 169, 169)
    ..strokeWidth = pixelsPerOneMM * .30;
  graphBpmLine = Paint()
    ..color = const Color.fromRGBO(38, 164, 36, 1.0)
    ..strokeWidth = pixelsPerOneMM * .30;
  graphBpmLine2 = Paint()
    ..color = const Color.fromRGBO(12, 227, 16, 1.0)
    ..strokeWidth = pixelsPerOneMM * .30;
  graphBpmLine3 = Paint()
    ..color = const Color.fromRGBO(197, 11, 95, 1.0)
    ..strokeWidth = pixelsPerOneMM * .20;
  graphBpmLine4 = Paint()
    ..color = const Color.fromRGBO(150, 163, 243, 1.0)
    ..strokeWidth = pixelsPerOneMM * .50;
  graphBaseLine = Paint()
    ..color = const Color.fromRGBO(180, 187, 180, 1.0)
    ..strokeWidth = pixelsPerOneMM * .20;

  init(size);

  drawGraph(canvas);
}