コード例 #1
0
        /// <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))));
        }
コード例 #2
0
        /// <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))));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
 public void PointValueToPixel(float[] points)
 {
     MatrixValueToPx.MapPoints(points);
     MatrixOffset.MapPoints(points);
     ViewPortHandler.touchMatrix.MapPoints(points);
 }
コード例 #8
0
 /// <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);
 }
コード例 #9
0
 public SKPoint PointValueToPixel(float x, float y)
 {
     return(MatrixOffset
            .MapPoint(ViewPortHandler.TouchMatrix.MapPoint(MatrixValueToPx.MapPoint(x, y))));
 }
コード例 #10
0
 public SKPoint[] PointValuesToPixel(SKPoint[] pts)
 {
     pts = MatrixValueToPx.MapPoints(pts);
     pts = ViewPortHandler.TouchMatrix.MapPoints(pts);
     return(MatrixOffset.MapPoints(pts));
 }
コード例 #11
0
 /// <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));
 }