function rotateLine(position) { if (position < halfabet) { context.rotate((-90 \* Math.PI) / 180); } else if (position > halfabet) { context.rotate((90 \* Math.PI) / 180); } else if (position === halfabet) { context.rotate((180 \* Math.PI) / 180); } }