コード例 #1
0
        public static void Build_Rectangle(RectangleData rectangle, double widthScale, double heightScale, AnimationData param)
        {
            var tempPoints = new SDL.SDL_Point[4];

            int x0 = rectangle.OldPoints[0].x + rectangle.Width / 2;
            int y0;

            if (rectangle.OldPoints[0].y > rectangle.OldPoints[3].y)
            {
                y0 = rectangle.OldPoints[0].y - rectangle.Height / 2;
            }
            else
            {
                y0 = rectangle.OldPoints[0].y + rectangle.Height / 2;
            }

            for (int i = 0; i < 4; i++)
            {
                tempPoints[i].x = (int)Math.Floor((x0 + (rectangle.OldPoints[i].x - x0) * Math.Cos(param.fi) -
                                                   (rectangle.OldPoints[i].y - y0) * Math.Sin(param.fi) - 20 + param.RectOffsetX) /** widthScale*/);
                tempPoints[i].y = (int)Math.Floor((y0 + (rectangle.OldPoints[i].x - x0) * Math.Sin(param.fi) +
                                                   (rectangle.OldPoints[i].y - y0) * Math.Cos(param.fi) + param.RectOffSetY) - 20 /** heightScale*/);
            }
            rectangle.Points = tempPoints;
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: Zhikh/computer_graphics
        private void SdlWorker()
        {
            OnInit();

            int clippingWindowWidth  = SCREEN_WIDTH - 100;
            int clippingWindowHeight = SCREEN_HEIGHT - 25;

            mouseClicked = false;
            fi           = 0;

            clippingWindow = new RectangleData(50, 50, clippingWindowWidth, clippingWindowHeight);
            cicle          = new RightPolygonData(100, clippingWindow.X0 + 100, clippingWindow.Y0 + 100, 50, 0.4);
            rectangle      = new RectangleData(clippingWindow.X0 + 400, clippingWindow.Y0 + 200, 200, 70);
            animParams     = new AnimationData();

            OnLoop();

            OnCleanup();
        }
コード例 #3
0
        public static void Build_Rectangle(RectangleData rectangle, double widthScale, double heightScale)
        {
            var points = new SDL.SDL_Point[4];

            points[0].x = rectangle.X0;
            points[0].y = rectangle.Y0;

            points[1].x = points[0].x + rectangle.Width;
            points[1].y = points[0].y;

            points[2].x = points[1].x;
            points[2].y = Math.Abs(points[1].y - rectangle.Height);

            points[3].x = Math.Abs(points[2].x - rectangle.Width);
            points[3].y = points[2].y;

            for (int i = 0; i < 4; i++)
            {
                points[i].x = (int)Math.Floor(points[i].x * widthScale);
                points[i].y = (int)Math.Floor(points[i].y * heightScale);
            }
            rectangle.Points = points;
        }