Example #1
0
function convertsOffsetsToCoordinates() {
  do_print("Converts offsets to coordinates");

  let b = new BezierCanvas(getCanvasMock(), getCubicBezier(), [.25, 0]);

  let coordinates = b.offsetsToCoordinates({style: {
    left: "0px",
    top: "0px"
  }});
  do_check_eq(coordinates.length, 2);
  do_check_eq(coordinates[0], 0);
  do_check_eq(coordinates[1], 1.5);

  coordinates = b.offsetsToCoordinates({style: {
    left: "0px",
    top: "300px"
  }});
  do_check_eq(coordinates[0], 0);
  do_check_eq(coordinates[1], 0);

  coordinates = b.offsetsToCoordinates({style: {
    left: "200px",
    top: "100px"
  }});
  do_check_eq(coordinates[0], 1);
  do_check_eq(coordinates[1], 1);
}
Example #2
0
function plotsCanvas() {
  do_print("Plots the curve to the canvas");

  let hasDrawnCurve = false;
  let b = new BezierCanvas(getCanvasMock(), getCubicBezier(), [.25, 0]);
  b.ctx.bezierCurveTo = () => hasDrawnCurve = true;
  b.plot();

  do_check_true(hasDrawnCurve);
}