dx static method

double dx(
  1. HAlign align,
  2. double textWidth
)

The dx offset to apply to an origin x so a label of textWidth is anchored.

Implementation

static double dx(HAlign align, double textWidth) {
  switch (align) {
    case HAlign.start:
      return 0;
    case HAlign.center:
      return -textWidth / 2;
    case HAlign.end:
      return -textWidth;
  }
}