コード例 #1
0
        public Vector2 Transform(Vector vector)
        {
            double multX = PhysicalRectangle.GetSize().Width / m_visibleLogicalRectangle.Width;
            double multY = PhysicalRectangle.GetSize().Height / m_visibleLogicalRectangle.Height;

            var transformed = new Vector2((float)(PhysicalRectangle.X + multX * (vector.X - m_visibleLogicalRectangle.Left)),
                                          (float)(PhysicalRectangle.Y + PhysicalRectangle.GetSize().Height - multY * (vector.Y - m_visibleLogicalRectangle.Bottom)));

            return(transformed);
        }
コード例 #2
0
        public Vector2 CreateScaleVector(Size logicalSize, Size physicalSize)
        {
            var needPhysicalWidth = logicalSize.Width * PhysicalRectangle.GetSize().Width / m_visibleLogicalRectangle.Width;

            var needPhysicalHeight = logicalSize.Height * PhysicalRectangle.GetSize().Height / m_visibleLogicalRectangle.Height;

            var scaleVector = new Vector(needPhysicalWidth / physicalSize.Width,
                                         needPhysicalHeight / physicalSize.Height);

            return(scaleVector.ToVector2());
        }
コード例 #3
0
        private Size MaximalVisibleLogicalSize()
        {
            double logicalAspect  = FullLogicalSize.Aspect;
            double physicalAspect = PhysicalRectangle.GetSize().Aspect;

            double visibleHeight;
            double visibleWidth;

            if (logicalAspect > physicalAspect) // logical wider than physical
            {
                visibleHeight = FullLogicalSize.Height;
                visibleWidth  = visibleHeight * physicalAspect;
            }
            else // physical wider than logical
            {
                visibleWidth  = FullLogicalSize.Width;
                visibleHeight = visibleWidth / physicalAspect;
            }

            return(new Size(visibleWidth, visibleHeight));
        }