ixfx
    Preparing search index...

    Function scaler

    • Returns a set of scaler functions, to convert to and from ranges.

      const scaler = Scaler.scaler(`both`, {width:window.innerWidth, height:window.innerHeight});
      // Assuming screen of 800x400...
      scaler.abs(400,200); // Yields { x:0.5, y:0.5 }
      scaler.abs({ x:400, y:200 }); // Yields { x:0.5, y:0.5 }

      scaler.rel(0.5, 0.5); // Yields: { x:400, y:200 }
      scaler.rel({ x:0.5, y:0.5 }); // Yields: { x:400, y:200 }

      If no default range is provided, it must be given each time the scale function is used.

      const scaler = Scaler.scaler(`both`);

      scaler.abs(400, 200, 800, 400);
      scaler.abs(400, 200, { width: 800, height: 400 });
      scaler.abs({ x:400, y: 200}, { width: 800, height: 400 });
      scaler.abs({ x:400, y: 200}, 800, 400);
      // All are the same, yielding { x:0.5, y:0.5 }

      scaler.abs(400, 200); // Throws an exception because there is no scale

      Parameters

      Returns ScalerCombined