/// <summary> /// Transform a rectangle with all matrices with potential animation phases. /// </summary> /// <param name="r"></param> /// <param name="phaseY"></param> public SKRect RectToPixelPhaseHorizontal(SKRect r, float phaseY) { // multiply the height of the rect with the phase r.Left *= phaseY; r.Right *= phaseY; return(MatrixOffset.MapRect(ViewPortHandler.touchMatrix .MapRect(MatrixValueToPx.MapRect(r)))); }
/// <summary> /// Transform a rectangle with all matrices with potential animation phases. /// </summary> /// <param name="r"></param> /// <param name="phaseY"></param> public SKRect RectToPixelPhase(SKRect r, float phaseY) { // multiply the height of the rect with the phase r.Top *= phaseY; r.Bottom *= phaseY; return(MatrixOffset.MapRect(ViewPortHandler.touchMatrix .MapRect(MatrixValueToPx.MapRect(r)))); }
public SKPoint[] PixelsToValue(params SKPoint[] points) { // invert all matrixes to convert back to the original value MatrixOffset.TryInvert(out SKMatrix tmp); points = tmp.MapPoints(points); ViewPortHandler.TouchMatrix.TryInvert(out tmp); points = tmp.MapPoints(points); MatrixValueToPx.TryInvert(out tmp); return(tmp.MapPoints(points)); }
public SKPoint PixelsToValue(float x, float y) { // invert all matrixes to convert back to the original value MatrixOffset.TryInvert(out SKMatrix tmp); var point = tmp.MapPoint(x, y); ViewPortHandler.touchMatrix.TryInvert(out tmp); point = tmp.MapPoint(point); MatrixValueToPx.TryInvert(out tmp); return(tmp.MapPoint(point)); }
/// <summary> /// Transforms the given array of touch positions(pixels) (x, y, x, y, ...) /// into values on the chart. /// </summary> public void PixelsToValue(float[] pixels) { Matrix tmp = mPixelToValueMatrixBuffer; tmp.Reset(); // invert all matrixes to convert back to the original value MatrixOffset.Invert(tmp); tmp.MapPoints(pixels); ViewPortHandler.touchMatrix.Invert(tmp); tmp.MapPoints(pixels); MatrixValueToPx.Invert(tmp); tmp.MapPoints(pixels); }
/// <summary> /// Prepares the matrix that transforms values to pixels. Calculates the ///scale factors from the charts size and offsets. /// </summary> public void PrepareMatrixValuePx(float xChartMin, float deltaX, float deltaY, float yChartMin) { float scaleX = (float)((ViewPortHandler.ContentWidth) / deltaX); float scaleY = (float)((ViewPortHandler.ContentHeight) / deltaY); if (float.IsInfinity(scaleX)) { scaleX = 0; } if (float.IsInfinity(scaleY)) { scaleY = 0; } // setup all matrices MatrixValueToPx.Reset(); MatrixValueToPx.PostTranslate(-xChartMin, -yChartMin); MatrixValueToPx.PostScale(scaleX, -scaleY); }
public void PointValueToPixel(float[] points) { MatrixValueToPx.MapPoints(points); MatrixOffset.MapPoints(points); ViewPortHandler.touchMatrix.MapPoints(points); }
/// <summary> /// Transform a rectangle with all matrices. /// </summary> /// <param name="r"></param> public void RectValueToPixel(RectF r) { MatrixValueToPx.MapRect(r); ViewPortHandler.touchMatrix.MapRect(r); MatrixOffset.MapRect(r); }
public SKPoint PointValueToPixel(float x, float y) { return(MatrixOffset .MapPoint(ViewPortHandler.TouchMatrix.MapPoint(MatrixValueToPx.MapPoint(x, y)))); }
public SKPoint[] PointValuesToPixel(SKPoint[] pts) { pts = MatrixValueToPx.MapPoints(pts); pts = ViewPortHandler.TouchMatrix.MapPoints(pts); return(MatrixOffset.MapPoints(pts)); }
/// <summary> /// Transform a rectangle with all matrices. /// </summary> /// <param name="r"></param> public SKRect RectValueToPixel(SKRect r) { r = MatrixValueToPx.MapRect(r); r = ViewPortHandler.touchMatrix.MapRect(r); return(MatrixOffset.MapRect(r)); }