Esempio n. 1
0
        public override bool Resize(int width, int height, Format format, Rational?refreshRate = null)
        {
            if (!base.Resize(width, height, format, refreshRate))
            {
                return(false);
            }

            RemoveAndDispose(ref backBuffer);

#if DIRECTX11_2 && (WIN8METRO || WINDOWS_UWP)
            var swapChainPanel = Description.DeviceWindowHandle as SwapChainPanel;
            if (swapChainPanel != null && swapChain2 != null)
            {
                swapChain2.MatrixTransform = Matrix3x2.Scaling(1f / swapChainPanel.CompositionScaleX, 1f / swapChainPanel.CompositionScaleY);
            }
#endif

            swapChain.ResizeBuffers(bufferCount, width, height, format, Description.Flags);

            // Recreate the back buffer
            backBuffer = ToDispose(RenderTarget2D.New(GraphicsDevice, swapChain.GetBackBuffer <Direct3D11.Texture2D>(0)));

            // Reinit the Viewport
            DefaultViewport = new ViewportF(0, 0, backBuffer.Width, backBuffer.Height);

            return(true);
        }
Esempio n. 2
0
        private void _プレビュー画像を描画する(DeviceContext d2ddc)
        {
            // 枠
            const float 枠の太さdpx = 5f;

            d2ddc.FillRectangle(
                new RectangleF(
                    this._プレビュー画像表示位置dpx.X - 枠の太さdpx,
                    this._プレビュー画像表示位置dpx.Y - 枠の太さdpx,
                    this._プレビュー画像表示サイズdpx.X + 枠の太さdpx * 2f,
                    this._プレビュー画像表示サイズdpx.Y + 枠の太さdpx * 2f),
                this._プレビュー枠ブラシ);

            // プレビュー画像
            var preimage = Global.App.演奏譜面.最高記録を現行化済み ?
                           (Global.App.演奏譜面.プレビュー画像 ?? this._既定のノード画像) :
                           this._現行化前のノード画像;

            var 換行列2D =
                Matrix3x2.Scaling(
                    this._プレビュー画像表示サイズdpx.X / preimage.サイズ.Width,
                    this._プレビュー画像表示サイズdpx.Y / preimage.サイズ.Height) *
                Matrix3x2.Translation(
                    this._プレビュー画像表示位置dpx.X,
                    this._プレビュー画像表示位置dpx.Y);

            preimage.描画する(d2ddc, 換行列2D);
        }
Esempio n. 3
0
        public void DrawTexture(string textureKey, RectangleF rect, float rotation = 0.0f, float opacity = 1.0f)
        {
            var textureEntry = this.textureManager.GetTexture(textureKey);

            if (textureEntry == null)
            {
                throw new TextureNotFoundException(textureKey);
            }

            if (rotation == 0.0f)
            {
                this.context.RenderTarget.DrawBitmap(textureEntry.Bitmap, rect, opacity, BitmapInterpolationMode.Linear);
            }
            else
            {
                var mtx = this.context.RenderTarget.Transform;

                var scaling = new Vector2((float)rect.Width / textureEntry.Bitmap.Size.Width, (float)rect.Height / textureEntry.Bitmap.Size.Height);
                this.context.RenderTarget.Transform = Matrix3x2.Translation(-textureEntry.Center)
                                                      * Matrix3x2.Rotation(rotation)
                                                      * Matrix3x2.Translation(textureEntry.Center)
                                                      * Matrix3x2.Scaling(scaling)
                                                      * Matrix3x2.Translation(rect.Location);
                this.context.RenderTarget.DrawBitmap(textureEntry.Bitmap, opacity, BitmapInterpolationMode.Linear);

                this.context.RenderTarget.Transform = mtx;
            }
        }
Esempio n. 4
0
        // 進行と描画


        public void 描画する(DeviceContext dc, float 達成率)
        {
            var 描画領域 = new RectangleF(220f, 650f, 165f, 80f);

            達成率 = Math.Max(Math.Min(達成率, 99.99f), 0f);                                 // 0~99.99にクリッピング

            string 達成率文字列 = (達成率.ToString("0.00") + '%').PadLeft(6).Replace(' ', 'o'); // 右詰め、余白は'o'。例:"99.00%", "o8.12%", "o0.00%"


            // 達成率ロゴを描画する

            var 換行列2D =
                Matrix3x2.Scaling(0.4f, 0.5f) *
                Matrix3x2.Translation(描画領域.X - 30f, 描画領域.Y - 60f);

            this._達成率ロゴ画像.描画する(dc, 換行列2D);


            // 小数部を描画する('%'含む)

            this._数字画像.描画する(dc, 描画領域.X + 65f, 描画領域.Y + (描画領域.Height * 0.2f), 達成率文字列.Substring(3), new Size2F(0.5f, 0.8f));


            // 整数部を描画する('.'含む)

            this._数字画像.描画する(dc, 描画領域.X, 描画領域.Y, 達成率文字列.Substring(0, 3), new Size2F(0.5f, 1.0f));
        }
Esempio n. 5
0
        /// <summary>
        /// Computes the appropriate flattening tolerance to pass to APIs that take a flattening tolerance (for instance, <see cref="DeviceContext.CreateFilledGeometryRealization"/>).
        /// </summary>
        /// <param name="matrix">The matrix that will be applied subsequently to the geometry being flattened.</param>
        /// <param name="dpiX">The horizontal DPI of the render target that the geometry will be rendered onto (a choice of 96 implies no DPI correction).</param>
        /// <param name="dpiY">The vertical DPI of the render target that the geometry will be rendered onto (a choice of 96 implies no DPI correction).</param>
        /// <param name="maxZoomFactor">The maximum amount of additional scaling (on top of any scaling implied by the matrix or the DPI) that will be applied to the geometry.</param>
        /// <returns>The flattening tolerance.</returns>
        public static float ComputeFlatteningTolerance(ref Matrix3x2 matrix, float dpiX = DefaultDpi, float dpiY = DefaultDpi, float maxZoomFactor = 1f)
        {
            var dpiDependentTransform = matrix * Matrix3x2.Scaling(dpiX / DefaultDpi, dpiY / DefaultDpi);
            var absMaxZoomFactor      = maxZoomFactor > 0f ? maxZoomFactor : -maxZoomFactor;

            return(DefaultFlatteningTolerance / (absMaxZoomFactor * ComputeMaximumScaleFactor(ref dpiDependentTransform)));
        }
Esempio n. 6
0
        private static void DrawSmallRaw(Person person, WIC.ImagingFactory wic, D2D.Factory d2dFactory,
                                         WIC.FormatConverter converter)
        {
            var whRate       = 1.0f * converter.Size.Width / converter.Size.Height;
            var smallRawSize = new Vector2(whRate * ImageDefines.SmallRawY, ImageDefines.SmallRawY);
            var scale        = ImageDefines.SmallRawY / converter.Size.Height;

            using (var wicBitmap = new WIC.Bitmap(wic,
                                                  (int)smallRawSize.X, (int)smallRawSize.Y,
                                                  WIC.PixelFormat.Format32bppPBGRA,
                                                  WIC.BitmapCreateCacheOption.CacheOnDemand))
                using (var target = new D2D.WicRenderTarget(d2dFactory,
                                                            wicBitmap, new D2D.RenderTargetProperties()))
                    using (var bmp = D2D.Bitmap.FromWicBitmap(target, converter))
                        using (var bmpBrush = new D2D.BitmapBrush(target, bmp))
                        {
                            target.BeginDraw();
                            target.Transform = Matrix3x2.Scaling(scale, scale);
                            target.DrawBitmap(bmp, 1.0f, D2D.BitmapInterpolationMode.Linear);
                            target.EndDraw();

                            using (var file = File.Create(person.SmallRawImage))
                            {
                                WicTools.SaveD2DBitmap(wic, wicBitmap, file);
                            }
                        }
        }
        protected override void ResizeBackBuffer(int width, int height, PixelFormat format)
        {
            // Manually update back buffer texture
            backBuffer.OnDestroyed();

#if SILICONSTUDIO_PLATFORM_WINDOWS_RUNTIME
            var swapChainPanel = Description.DeviceWindowHandle.NativeHandle as Windows.UI.Xaml.Controls.SwapChainPanel;
            if (swapChainPanel != null)
            {
                var swapChain2 = swapChain.QueryInterface <SwapChain2>();
                if (swapChain2 != null)
                {
                    swapChain2.MatrixTransform = Matrix3x2.Scaling(1f / swapChainPanel.CompositionScaleX, 1f / swapChainPanel.CompositionScaleY);
                    swapChain2.Dispose();
                }
            }
#endif

            swapChain.ResizeBuffers(bufferCount, width, height, (SharpDX.DXGI.Format)format, SwapChainFlags.None);

            // Get newly created native texture
            var backBufferTexture = swapChain.GetBackBuffer <SharpDX.Direct3D11.Texture2D>(0);

            // Put it in our back buffer texture
            backBuffer.InitializeFrom(backBufferTexture);
        }
Esempio n. 8
0
        private void DrawArrow(Brush brush, Brush borderBrush, RawVector2 arrowTip, float rotAngle, float flowSize, bool moveForward, float borderWidth)
        {
            var transform = Surface.RenderTarget2D.Transform;

            var scaleVector = new Vector2(flowSize, flowSize);

            if (!moveForward)
            {
                rotAngle -= (float)Math.PI;
            }
            var translationVector = arrowTip + ((Matrix3x2)Surface.RenderTarget2D.Transform).TranslationVector;

            var scale       = Matrix3x2.Scaling(scaleVector);
            var rotation    = Matrix3x2.Rotation(rotAngle, Vector2.Zero);
            var translation = Matrix3x2.Translation(translationVector);

            Surface.RenderTarget2D.Transform = scale * rotation * translation;

            if (brush != null)
            {
                Surface.RenderTarget2D.FillGeometry(LineFlow, brush);
            }

            if (borderBrush != null)
            {
                Surface.RenderTarget2D.DrawGeometry(LineFlow, borderBrush, borderWidth);
            }

            Surface.RenderTarget2D.Transform = transform;
        }
Esempio n. 9
0
        public void 進行描画する(DeviceContext dc, double?スキル値)
        {
            if (null == スキル値)
            {
                return;
            }
            var skill = (double)スキル値;

            var 描画領域 = new RectangleF(108f, 780f, 275f, 98f);

            string スキル値文字列 = skill.ToString("0.00").PadLeft(6).Replace(' ', 'o');                    // 右詰め、余白は'o'。

            // 曲別SKILLアイコンを描画する
            dc.Transform =
                Matrix3x2.Scaling(0.375f, 0.5f) *
                Matrix3x2.Translation(描画領域.X, 描画領域.Y);
            this._ロゴ画像.描画する(dc, 0f, 0f);

            // 小数部を描画する
            dc.Transform =
                Matrix3x2.Scaling(0.65f, 0.8f) *
                Matrix3x2.Translation(描画領域.X + 90f + 105f, 描画領域.Y + (描画領域.Height * 0.2f));
            this._数字画像.描画する(dc, 0f, 0f, スキル値文字列.Substring(4));

            // 整数部を描画する('.'含む)
            dc.Transform =
                Matrix3x2.Scaling(0.65f, 1.0f) *
                Matrix3x2.Translation(描画領域.X + 90f, 描画領域.Y);
            this._数字画像.描画する(dc, 0f, 0f, スキル値文字列.Substring(0, 4));
        }
Esempio n. 10
0
        // 進行と描画


        public void 進行描画する(DeviceContext dc)
        {
            var 描画矩形 = new RectangleF(122f, 313f, 240f, 30f);

            // 初回または名前が変更された場合に TextLayout を再構築する。
            if ((null == this._TextLayout) || (this._前回表示した名前 != this.前))
            {
                this._TextLayout = new TextLayout(DXResources.Instance.DWriteFactory, this.前, this._TextFormat, 1000f, 30f)      // 最大1000dpxまで
                {
                    TextAlignment = TextAlignment.Leading,
                    WordWrapping  = WordWrapping.NoWrap, // 1000dpxを超えても改行しない(はみ出し分は切り捨て)
                };

                float 文字列幅dpx = this._TextLayout.Metrics.WidthIncludingTrailingWhitespace;
                this._拡大率X = (文字列幅dpx <= 描画矩形.Width) ? 1.0f : (描画矩形.Width / 文字列幅dpx);
            }

            DXResources.Instance.D2DBatchDraw(dc, () => {
                var pretrans      = dc.Transform;
                dc.PrimitiveBlend = PrimitiveBlend.SourceOver;

                dc.Transform =
                    Matrix3x2.Scaling(this._拡大率X, 1.0f) *        // 拡大縮小
                    Matrix3x2.Translation(描画矩形.X, 描画矩形.Y) *      // 平行移動
                    pretrans;

                dc.DrawTextLayout(Vector2.Zero, this._TextLayout, this._文字色);   // 座標(描画矩形)は拡大率の影響をうけるので、このメソッドではなく、Matrix3x2.Translation() で設定するほうが楽。

                dc.Transform = pretrans;
            });

            this._前回表示した名前 = this.前;
        }
        // 進行と描画


        public void 進行描画する(DeviceContext d2ddc)
        {
            var 描画矩形 = new RectangleF(122f, 313f, 240f, 30f);

            // 初回または名前が変更された場合に TextLayout を再構築する。
            if ((this._TextLayout is null) || (this._前回表示した名前 != this.前))
            {
                const float 最大幅 = 1000f;
                this._TextLayout = new TextLayout(Global.GraphicResources.DWriteFactory, this.前, this._TextFormat, 最大幅, 30f)
                {
                    TextAlignment = TextAlignment.Leading,
                    WordWrapping  = WordWrapping.NoWrap, // 最大幅を超えても改行しない(はみ出し分は切り捨て)
                };

                float 文字列幅dpx = this._TextLayout.Metrics.WidthIncludingTrailingWhitespace;
                this._拡大率X = (文字列幅dpx <= 描画矩形.Width) ? 1.0f : (描画矩形.Width / 文字列幅dpx);
            }

            var preTrans = d2ddc.Transform;

            d2ddc.Transform =
                Matrix3x2.Scaling(this._拡大率X, 1.0f) *        // 拡大縮小
                Matrix3x2.Translation(描画矩形.X, 描画矩形.Y) *      // 平行移動
                preTrans;

            // 座標(描画矩形)は拡大率の影響をうけるので、このメソッドではなく、Matrix3x2.Translation() で設定するほうが楽。
            d2ddc.DrawTextLayout(Vector2.Zero, this._TextLayout, this._文字色);

            d2ddc.Transform = preTrans;


            // 更新

            this._前回表示した名前 = this.前;
        }
Esempio n. 12
0
        private void _難易度パネルを1つ描画する(DeviceContext dc, Matrix3x2 pretrans, float 基点X, float 基点Y, string 難易度ラベル, float 難易度値, Brush 文字ブラシ, Brush 見出し背景ブラシ, Brush 数値背景ブラシ)
        {
            dc.Transform = pretrans;

            dc.FillRectangle(new RectangleF(基点X, 基点Y, 157f, 20f), 見出し背景ブラシ);
            dc.FillRectangle(new RectangleF(基点X, 基点Y + 20f, 157f, 66f), 数値背景ブラシ);

            this._見出し用TextFormat.TextAlignment = TextAlignment.Trailing;
            dc.DrawText(難易度ラベル, this._見出し用TextFormat, new RectangleF(基点X + 4f, 基点Y, 157f - 8f, 18f), 文字ブラシ);

            if (難易度ラベル.Nullでも空でもない() && 0.00 != 難易度値)
            {
                var 難易度値文字列 = 難易度値.ToString("0.00").PadLeft(1);                         // 整数部は2桁を保証(1桁なら十の位は空白文字)

                //// 小数部を描画する
                dc.Transform =
                    Matrix3x2.Scaling(0.5f, 0.5f) *
                    Matrix3x2.Translation(基点X + 84f, 基点Y + 36f) *
                    pretrans;
                this._数字画像.描画する(dc, 0f, 0f, 難易度値文字列.Substring(2));

                // 整数部を描画する('.'含む)
                dc.Transform =
                    Matrix3x2.Scaling(0.7f, 0.7f) *
                    Matrix3x2.Translation(基点X + 20f, 基点Y + 20f) *
                    pretrans;
                this._数字画像.描画する(dc, 0f, 0f, 難易度値文字列.Substring(0, 2));
            }
        }
Esempio n. 13
0
        public static Matrix3x2 Scale(this Matrix3x2 target, float sx, float sy)
        {
            return(Matrix3x2.Multiply(Matrix3x2.Scaling(sx, sy), target));

            /* target.M11 *= sx;
             * target.M22 *= sy;
             * return target;*/
        }
        private Matrix3x2 GetWorldToFormTransform()
        {
            float worldExtent = 20;
            var   size        = renderEnvironment.Size;
            float scaling     = Math.Min(size.Width, size.Height) / worldExtent;

            return(new Matrix3x2(1, 0, 0, -1, 0, 0) * Matrix3x2.Scaling(scaling) * Matrix3x2.Translation(size.Width / 2, size.Height / 2));
        }
Esempio n. 15
0
        protected override void CreateSizeDependentResources(TargetBase renderBase)
        {
            base.CreateSizeDependentResources(renderBase);

            if (SwapChain != null)
            {
                SwapChain.MatrixTransform = Matrix3x2.Scaling(1f / panel.CompositionScaleX, 1f / panel.CompositionScaleY);
            }
        }
Esempio n. 16
0
 public void Draw(BitmapManager bmp, RenderTarget ctx)
 {
     ctx.Transform =
         Matrix3x2.Translation(-24, -24) *
         Matrix3x2.Rotation(RotationAngle) *
         Matrix3x2.Scaling(Scale) *
         Matrix3x2.Translation(X, Y);
     ctx.DrawBitmap(bmp[_snow], 1.0f, BitmapInterpolationMode.Linear);
 }
Esempio n. 17
0
        public void 描画する(グラフィックデバイス gd)
        {
            var 見出し描画領域 = new RectangleF(783f, 117f, 414f, 63f);
            var 数値描画領域  = new RectangleF(783f, 180f, 414f, 213f);

            var node  = App.曲ツリー.フォーカス曲ノード;
            var anker = App.曲ツリー.フォーカス難易度;

            (string label, float level)難易度;
            if (node.親ノード is SetNode)
            {
                // 親が SetNode なら、難易度はそっちから取得する。
                難易度 = node.親ノード.難易度[anker];
            }
            else
            {
                難易度 = node.難易度[anker];
            }

            gd.D2DBatchDraw((dc) => {
                var pretrans = dc.Transform;

                using (var 見出し背景ブラシ = new SolidColorBrush(dc, Node.難易度色[anker]))
                    using (var 黒ブラシ = new SolidColorBrush(dc, Color4.Black))
                        using (var 黒透過ブラシ = new SolidColorBrush(dc, new Color4(Color3.Black, 0.5f)))
                            using (var 白ブラシ = new SolidColorBrush(dc, Color4.White))
                            {
                                dc.Transform = pretrans;

                                // 背景領域を塗りつぶす。
                                dc.FillRectangle(見出し描画領域, 見出し背景ブラシ);
                                dc.FillRectangle(数値描画領域, 黒ブラシ);

                                // 見出し文字列を描画する。
                                this._見出し用TextFormat.TextAlignment = TextAlignment.Trailing;
                                var 見出し文字領域    = 見出し描画領域;
                                見出し文字領域.Width -= 8f;            // 右マージン
                                dc.DrawText(難易度.label, this._見出し用TextFormat, 見出し文字領域, 白ブラシ);

                                // 小数部を描画する。
                                var 数値文字列    = 難易度.level.ToString("0.00").PadLeft(1);
                                dc.Transform =
                                    Matrix3x2.Scaling(2.2f, 2.2f) *
                                    Matrix3x2.Translation(数値描画領域.X + 175f, 数値描画領域.Y) *
                                    pretrans;
                                this._数字画像.描画する(dc, 0f, 0f, 数値文字列.Substring(2));

                                // 整数部と小数点を描画する。
                                dc.Transform =
                                    Matrix3x2.Scaling(2.2f, 2.2f) *
                                    Matrix3x2.Translation(数値描画領域.X + 15f, 数値描画領域.Y) *
                                    pretrans;
                                this._数字画像.描画する(dc, 0f, 0f, 数値文字列.Substring(0, 2));
                            }
            });
        }
Esempio n. 18
0
        private Matrix3x2 GetCenterRenderTransform(float scaleFactor, float xLocation, float yLocation, float rotation)
        {
            var   scaleTransform      = Matrix3x2.Scaling(scaleFactor);
            var   geometryBounds      = GetBounds(scaleTransform);
            float centerScalingOffset = scaleFactor * 4;
            float xTranslate          = xLocation - (geometryBounds.Right - geometryBounds.Left) + centerScalingOffset;
            float yTranslate          = yLocation - (geometryBounds.Bottom - geometryBounds.Top) + centerScalingOffset;

            return(scaleTransform * Matrix3x2.Rotation(rotation) * Matrix3x2.Translation(xTranslate, yTranslate));
        }
Esempio n. 19
0
 public override void Render()
 {
     if (Fill != null)
     {
         Fill.Transform = Matrix3x2.Scaling(RenderSize.X, RenderSize.Y) * Transform;
         Device.FillRectangle(this, Fill);
     }
     if (Stroke != null)
     {
         Device.DrawRectangle(this, Stroke, StrokeThickness);
     }
 }
Esempio n. 20
0
        public void 描画する(DeviceContext dc, RectangleF 描画先矩形, float 透明度0to1 = 1.0f)
        {
            if (null == this._VideoSource)
            {
                return;
            }

            var 換行列2D =
                Matrix3x2.Scaling(描画先矩形.Width / this._VideoSource.フレームサイズ.Width, 描画先矩形.Height / this._VideoSource.フレームサイズ.Height) * // 拡大縮小
                Matrix3x2.Translation(描画先矩形.Left, 描画先矩形.Top);                                                                       // 平行移動

            this.描画する(dc, 換行列2D, 透明度0to1);
        }
Esempio n. 21
0
 public override void Render()
 {
     Device.Transform = Matrix3x2.Scaling(ScaleX, ScaleY) * Transform;
     if (Fill != null)
     {
         Device.FillGeometry(pathGeometry, Fill);
     }
     if (Stroke != null)
     {
         Device.DrawGeometry(pathGeometry, Stroke, StrokeThickness);
     }
     Device.Transform = Matrix3x2.Identity;
 }
Esempio n. 22
0
 /// <summary>
 /// 计算转换矩阵。
 /// </summary>
 private void CalculateMatrix()
 {
     matrix = new Matrix3x2(1, 0, 0, 1, -shape.Center.X, -shape.Center.Y);
     if (rotate != 0)
     {
         matrix *= Matrix3x2.Rotation(this.rotateRadian);
     }
     if (this.scale != 1)
     {
         matrix *= Matrix3x2.Scaling(scale);
     }
     matrix *= Matrix3x2.Translation(offset.X + scale * shape.Center.X, offset.Y + scale * shape.Center.Y);
 }
        static private SharpDX.Matrix3x2 CalculateTransformation(Vector2 faceCenter, float zoom, int deviceWidth, int deviceHeight)
        {
            Matrix3x2 result = Matrix3x2.Identity;

            // 1) Translate the target so that the points will be centered.
            // 2) Scale the points to fit the target.
            // 3) Translate the target to the center of the device target.
            result =
                Matrix3x2.Translation(-faceCenter.X, -faceCenter.Y) *
                Matrix3x2.Scaling(zoom, zoom) *
                Matrix3x2.Translation(deviceWidth / 2.0f, deviceHeight / 2.0f);

            return(result);
        }
Esempio n. 24
0
        private void _サムネイルを描画する(DeviceContext d2ddc)
        {
            var サムネイル画像 = Global.App.演奏譜面?.プレビュー画像 ?? this._既定のノード画像;

            var 換行列2D =
                Matrix3x2.Scaling(
                    this._サムネイル画像表示サイズdpx.X / サムネイル画像.サイズ.Width,
                    this._サムネイル画像表示サイズdpx.Y / サムネイル画像.サイズ.Height) *
                Matrix3x2.Translation(
                    this._サムネイル画像表示位置dpx.X,
                    this._サムネイル画像表示位置dpx.Y);

            サムネイル画像.描画する(d2ddc, 換行列2D);
        }
Esempio n. 25
0
        protected override void OnDraw(DeviceContext renderTarget)
        {
            var worldScale  = renderTarget.Size.Width / StageWidth;
            var worldOffset = -CameraY * worldScale;

            GlobalTransform = Matrix3x2.Scaling(worldScale) * Matrix3x2.Translation(0.0f, worldOffset);

            base.OnDraw(renderTarget);

            if (KeyboardState.IsPressed(SharpDX.DirectInput.Key.LeftShift))
            {
                DrawDiagnostics(renderTarget);
            }
        }
Esempio n. 26
0
 private void CalculateMatrix()
 {
     matrix = new Matrix3x2(1, 0, 0, 1, -orignalCenter.X, -orignalCenter.Y);
     if (rotate != 0)
     {
         float rotateRadian = (float)(lastrotate * Math.PI / 180);
         matrix *= Matrix3x2.Rotation(rotateRadian);
     }
     if (this.scale != 1)
     {
         matrix *= Matrix3x2.Scaling(scale);
     }
     matrix *= Matrix3x2.Translation(offset.X + scale * orignalCenter.X, offset.Y + scale * orignalCenter.Y);
 }
Esempio n. 27
0
        // 進行と描画


        public void 進行描画する(DeviceContext dc)
        {
            var ノード画像 = Global.App.演奏譜面.譜面と画像を現行化済み ? (Global.App.演奏譜面.プレビュー画像 ?? this._既定のノード画像) : this._現行化前のノード画像;

            var 換行列2D =
                Matrix3x2.Scaling(
                    this._プレビュー画像表示サイズdpx.X / ノード画像.サイズ.Width,
                    this._プレビュー画像表示サイズdpx.Y / ノード画像.サイズ.Height) *
                Matrix3x2.Translation(
                    this._プレビュー画像表示位置dpx.X,
                    this._プレビュー画像表示位置dpx.Y);

            ノード画像.描画する(dc, 換行列2D);
        }
Esempio n. 28
0
 public override void Render()
 {
     Device.Transform = Transform;
     if (Fill != null)
     {
         Fill.Transform = Matrix3x2.Scaling(Width, Height) * Transform;
         Device.FillGeometry(shape, Fill);
     }
     if (Stroke != null)
     {
         Device.DrawGeometry(shape, Stroke);
     }
     Device.Transform = Matrix3x2.Identity;
 }
        public void 描画する(グラフィックデバイス gd, float x, float y, 成績 結果)
        {
            gd.D2DBatchDraw((dc) => {
                dc.Transform =
                    Matrix3x2.Scaling(1.4f, 1.3f, center: new Vector2(x, y)) *                          // 画像が小さいので少々拡大。
                    dc.Transform;

                var 割合表 = 結果.判定toヒット割合;
                int 合計  = 0;

                float 基点X = x;

                x = 基点X + (float)this._パラメータアニメ.X位置オフセット[0].Value;
                this.パラメータを一行描画する(dc, x, y, 判定種別.PERFECT, 結果.判定toヒット数[判定種別.PERFECT], 割合表[判定種別.PERFECT], (float)this._パラメータアニメ.透明度[0].Value);
                合計 += 結果.判定toヒット数[判定種別.PERFECT];
                y  += _改行幅dpx;

                x = 基点X + (float)this._パラメータアニメ.X位置オフセット[1].Value;
                this.パラメータを一行描画する(dc, x, y, 判定種別.GREAT, 結果.判定toヒット数[判定種別.GREAT], 割合表[判定種別.GREAT], (float)this._パラメータアニメ.透明度[1].Value);
                合計 += 結果.判定toヒット数[判定種別.GREAT];
                y  += _改行幅dpx;

                x = 基点X + (float)this._パラメータアニメ.X位置オフセット[2].Value;
                this.パラメータを一行描画する(dc, x, y, 判定種別.GOOD, 結果.判定toヒット数[判定種別.GOOD], 割合表[判定種別.GOOD], (float)this._パラメータアニメ.透明度[2].Value);
                合計 += 結果.判定toヒット数[判定種別.GOOD];
                y  += _改行幅dpx;

                x = 基点X + (float)this._パラメータアニメ.X位置オフセット[3].Value;
                this.パラメータを一行描画する(dc, x, y, 判定種別.OK, 結果.判定toヒット数[判定種別.OK], 割合表[判定種別.OK], (float)this._パラメータアニメ.透明度[3].Value);
                合計 += 結果.判定toヒット数[判定種別.OK];
                y  += _改行幅dpx;

                x = 基点X + (float)this._パラメータアニメ.X位置オフセット[4].Value;
                this.パラメータを一行描画する(dc, x, y, 判定種別.MISS, 結果.判定toヒット数[判定種別.MISS], 割合表[判定種別.MISS], (float)this._パラメータアニメ.透明度[4].Value);
                合計 += 結果.判定toヒット数[判定種別.MISS];
                y  += _改行幅dpx;

                x      = 基点X + (float)this._パラメータアニメ.X位置オフセット[5].Value;
                var 矩形 = (RectangleF)this._判定種別文字の矩形リスト["MaxCombo"];
                this._判定種別文字.描画する(dc, x, y, 転送元矩形: 矩形, 透明度0to1: (float)this._パラメータアニメ.透明度[5].Value);

                x += 矩形.Width + 16f;
                this.数値を描画する(dc, x, y, 結果.MaxCombo, 4, (float)this._パラメータアニメ.透明度[5].Value);
                this.数値を描画する(dc, x + _dr, y, (int)Math.Floor(100.0 * 結果.MaxCombo / 合計), 3, (float)this._パラメータアニメ.透明度[5].Value);                             // 切り捨てでいいやもう
                this._パラメータ文字.透明度 = (float)this._パラメータアニメ.透明度[5].Value;
                this._パラメータ文字.描画する(dc, x + _dp, y, "%");
            });
        }
Esempio n. 30
0
        private void RenderBitmap(GraphicsContext graphics)
        {
            Log.InfoFormat("Rendering Bitmap");

            int   xOffset = 0, zOffset = 0;
            Size2 size = Size2.Empty;

            ChunkCacheBitmap[] cache;

            lock (_renderSync)
            {
                _isDirty = false;
                xOffset  = Math.Min(0, _minChunk.X) * -1;
                zOffset  = Math.Min(0, _minChunk.Z) * -1;
                size     = _imageSize;
                cache    = _chunkCache.Values.ToArray();
            }


            var arrSize = size.Width * size.Height * 4;

            if (_bitmap == null || _bitmapMemory == null || _bitmapMemory.Length != arrSize)
            {
                _bitmapMemory = new byte[arrSize];
                _bitmap       = new SharpDX.Direct2D1.Bitmap(graphics.Target2D, size, new BitmapProperties(graphics.Target2D.PixelFormat));
            }
            _scale = Math.Min(graphics.ViewportSize.Width / (float)size.Width,
                              graphics.ViewportSize.Height / (float)size.Height);

            _scaleMatrix = Matrix3x2.Scaling(_scale);

            if (cache.Length == 0)
            {
                return;
            }

            foreach (var chunk in cache)
            {
                for (int z = 0; z < 16; z++)
                {
                    Array.Copy(chunk.BitmapMemory, z * 16 * 4, _bitmapMemory, (size.Width * ((chunk.Z + zOffset) * 16 + z) * 4) + ((chunk.X + xOffset) * 16) * 4, 16 * 4);
                }
                //chunk.BitmapMemory.CopyTo(_bitmapMemory, (int)((_imageSize.Width * ((chunk.Z + _zOffset) * 16)) + ((chunk.X + _xOffset)* 16))*4);
            }

            _bitmap.CopyFromMemory(_bitmapMemory, size.Width * 4);
            Log.InfoFormat("Rendering Bitmap Complete | Size: {0}", _bitmapMemory.Length);
        }