示例#1
0
        public static List<Point> Generate(int n = 1000, double width = 1.0, double height = 1.0)
        {
            // Probabilities
            double[] p = {0.85, .92, .99, 1.00};

            // Transformations
            var a1 = new MatrixTransform(new Matrix(0.85, -0.04, 0.04, 0.85, 0, 1.6));
            var a2 = new MatrixTransform(new Matrix(0.20, 0.23, -0.26, 0.22, 0, 1.6));
            var a3 = new MatrixTransform(new Matrix(-0.15, 0.26, 0.28, 0.24, 0, 0.44));
            var a4 = new MatrixTransform(new Matrix(0, 0, 0, 0.16, 0, 0));
            var random = new Random();
            var point = new Point(0.5, 0.5);
            var points = new List<Point>();

            // Transformation for [-3,3,0,10] => output coordinates
            var T = new MatrixTransform(new Matrix(width/6.0, 0, 0, -height/10.1, width/2.0, height));

            for (int i = 0; i < n; i++)
            {
                var r = random.NextDouble();

                if (r < p[0])
                    point = a1.Transform(point);
                else if (r < p[1])
                    point = a2.Transform(point);
                else if (r < p[2])
                    point = a3.Transform(point);
                else
                    point = a4.Transform(point);

                points.Add(T.Transform(point));
            }
            return points;
        }
示例#2
0
        void Manipulation(ManipulationDeltaEventArgs e)
        {
            var mt = new MatrixTransform(ShapeUtils.GetTransform(e));

            var Point1 = mt.Transform(new Point(line.X1, line.Y1));
            var Point2 = mt.Transform(new Point(line.X2, line.Y2));
            line.X1 = Point1.X;
            line.Y1 = Point1.Y;
            line.X2 = Point2.X;
            line.Y2 = Point2.Y;            
        }
示例#3
0
        public void Reset()
        {
            mPoints = new List<Point>(defaultPoints);
            //randomize center
            double x = Util.Rand(0, Config.WindowWidth);
            double y = Util.Rand(0, Config.WindowHeight);
            mCenter = new Point(x,y);
            Util.BaitWithinWindow(ref mCenter);

            double angle = Util.Rand((int)0, (int)180);

            Matrix m = new Matrix(1, 0, 0, 1, 0, 0);
            m.Scale(mScale, mScale); 	//scale at (0,0)
            m.Rotate(angle); 			//rotate at (0,0)
            m.Translate(mCenter.X, mCenter.Y);

            MatrixTransform mt = new MatrixTransform(m);
            for (int i = 0; i < mPoints.Capacity; i++)
                mPoints[i] = mt.Transform(mPoints[i]);

            mPolygon.Points = new PointCollection(mPoints);
        }
示例#4
0
        /// <summary>
        /// Gets the resolution in DPI of the target device of a visual.
        /// </summary>
        public static Point GetResolution(Visual visual)
        {
            Point dpi = new Point(120, 120);

            PresentationSource source = PresentationSource.FromVisual(visual);
            if (source == null)
                return dpi;

            CompositionTarget target = source.CompositionTarget;

            Matrix m = target.TransformToDevice;
            MatrixTransform t = new MatrixTransform(m);

            Point pt1 = new Point(0, 0);
            pt1 = t.Transform(pt1);

            Point pt2 = new Point(96, 96);
            pt2 = t.Transform(pt2);

            dpi.X = pt2.X - pt1.X;
            dpi.Y = pt2.Y - pt1.Y;
            return dpi;
        }
        protected override void OnRender(DrawingContext dc)
        {
            // Draw background
            dc.DrawRectangle(Brushes.White, null, new Rect(RenderSize));

            Transform t = new MatrixTransform(TheModel.GetTikzToScreenTransform().ToWpfMatrix());
            t.Freeze();

            Pen pen = new Pen(Brushes.WhiteSmoke, 1);
            pen.Freeze();

            TheModel.DrawRaster(
                (p1, p2) => dc.DrawLine(pen, t.Transform(p1), t.Transform(p2)),
                (r1, r2) =>
                {
                    EllipseGeometry eg = new EllipseGeometry(new Point(0, 0), r1, r2);
                    eg.Transform = t;
                    eg.Freeze();
                    dc.DrawGeometry(null, pen, eg);
                });

        }
示例#6
0
 void Manipulation(ManipulationDeltaEventArgs e)
 {
     var mt = new MatrixTransform(ShapeUtils.GetTransform(e));
     var newTopLeft = mt.Transform(getBadgePos());
     setBadgePos(newTopLeft.X, newTopLeft.Y);                 
 }