コード例 #1
0
ファイル: OSD.cs プロジェクト: WombatFromHell/VSCView
        private void Draw2dAs3d(
            UI_ImageCache cache, Graphics g,
            Image image, string ImageGyroLName, Image ImageGyroL, string ImageGyroRName, Image ImageGyroR, string ImageGyroUName, Image ImageGyroU, string ImageGyroDName, Image ImageGyroD,
            float transformX, float transformY,
            float rotationAngle,
            float TiltFactorX, float TiltFactorY,
            float Width, float Height,
            float TiltTranslateX, float TiltTranslateY)
        {
            // fix flip
            if (TiltFactorX < -1)
            {
                TiltFactorX = 2.0f + TiltFactorX;
            }
            if (TiltFactorX > 1)
            {
                TiltFactorX = 2.0f - TiltFactorX;
            }
            if (TiltFactorY < -1)
            {
                TiltFactorY = 2.0f + TiltFactorY;
            }
            if (TiltFactorY > 1)
            {
                TiltFactorY = 2.0f - TiltFactorY;
            }

            PointF location = new PointF((TiltFactorY * -TiltTranslateX) - (Width / 2), (TiltFactorX * TiltTranslateY) - (Height / 2));

            g.RotateTransform(rotationAngle);
            g.ScaleTransform(transformX, transformY);

            g.DrawImage(image, location.X, location.Y, Width, Height);

            if (Math.Abs(TiltFactorX) > 0)
            {
                if (Math.Sign(TiltFactorX) > 0)
                {
                    float percent = TiltFactorX * 2;// * 0.15f;
                    percent = (float)Math.Round(percent * 25f) / 25f;
                    percent = (float)Math.Min(percent, 1.0f);
                    g.DrawImage(cache.GetImage($"{ImageGyroDName}:{percent}", () => { return(UI_ImageCache.SetImageOpacity(ImageGyroD, percent)); }), location.X, location.Y, Width, Height);
                }
                if (Math.Sign(TiltFactorX) < 0)
                {
                    float percent = -TiltFactorX * 2;// * 0.15f;
                    percent = (float)Math.Round(percent * 25f) / 25f;
                    percent = (float)Math.Min(percent, 1.0f);
                    g.DrawImage(cache.GetImage($"{ImageGyroUName}:{percent}", () => { return(UI_ImageCache.SetImageOpacity(ImageGyroU, percent)); }), location.X, location.Y, Width, Height);
                }
            }

            if (Math.Abs(TiltFactorY) > 0)
            {
                if (Math.Sign(TiltFactorY) > 0)
                {
                    float percent = TiltFactorY * 2;// * 0.15f;
                    percent = (float)Math.Round(percent * 25f) / 25f;
                    percent = (float)Math.Min(percent, 1.0f);
                    g.DrawImage(cache.GetImage($"{ImageGyroLName}:{percent}", () => { return(UI_ImageCache.SetImageOpacity(ImageGyroL, percent)); }), location.X, location.Y, Width, Height);
                }
                if (Math.Sign(TiltFactorY) < 0)
                {
                    float percent = -TiltFactorY * 2;// * 0.15f;
                    percent = (float)Math.Round(percent * 25f) / 25f;
                    percent = (float)Math.Min(percent, 1.0f);
                    g.DrawImage(cache.GetImage($"{ImageGyroRName}:{percent}", () => { return(UI_ImageCache.SetImageOpacity(ImageGyroR, percent)); }), location.X, location.Y, Width, Height);
                }
            }
        }
コード例 #2
0
ファイル: OSD.cs プロジェクト: WombatFromHell/VSCView
        protected override void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            base.Initalize(data, cache, themePath, themeData);
            this.data = data;

            PadPosHistory = new List <PointF?>();

            InputName = themeData["inputName"]?.Value <string>();
            string imageName   = themeData["image"]?.Value <string>();
            int    TrailLength = themeData["length"]?.Value <int>() ?? 0;

            float Width  = themeData["width"]?.Value <float>() ?? 0;
            float Height = themeData["height"]?.Value <float>() ?? 0;

            if (!string.IsNullOrWhiteSpace(imageName) && TrailLength > 0)
            {
                Image  ImagePadDecayBase = cache.LoadImage(imageName);
                string SizeSuffix        = string.Empty;
                if (Width > 0 && Height > 0)
                {
                    ImagePadDecayBase = new Bitmap(ImagePadDecayBase, (int)Width, (int)Height);
                }
                //int scaledTrailLength = (int)(TrailLength * (MainForm.fpsLimit / 60.0f));
                ImagePadDecay = new Image[TrailLength];
                for (int x = 0; x < ImagePadDecay.Length; x++)
                {
                    float percent = ((x + 1) * 1.0f / ImagePadDecay.Length);

                    ImagePadDecay[x] = cache.GetImage($"{imageName}:{Width}:{Height}:{percent}", () => { return(UI_ImageCache.SetImageOpacity(ImagePadDecayBase, percent * 0.15f)); });
                }
            }
            else
            {
                ImagePadDecay = new Image[0];
            }
        }