当前位置: 首页>>代码示例>>C#>>正文


C# Direct2D1.SolidColorBrush类代码示例

本文整理汇总了C#中SharpDX.Direct2D1.SolidColorBrush的典型用法代码示例。如果您正苦于以下问题:C# SolidColorBrush类的具体用法?C# SolidColorBrush怎么用?C# SolidColorBrush使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SolidColorBrush类属于SharpDX.Direct2D1命名空间,在下文中一共展示了SolidColorBrush类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SharpDXDrawing

 public SharpDXDrawing(SharpDXDevice device)
     : base(device)
 {
     this.device = device;
     solidColorBrush = new SolidColorBrush(device.RenderTarget, Colors.Black);
     device.RenderTarget.Transform = Matrix3x2.Identity;
 }
开发者ID:lilinghui,项目名称:DeltaEngine,代码行数:7,代码来源:SharpDXDrawing.cs

示例2: OnLoad

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
 
            // Direct2D
            var renderTargetProperties = new RenderTargetProperties()
            {
                PixelFormat = new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Ignore)
            };
            var hwndRenderTargetProperties = new HwndRenderTargetProperties()
            {
                Hwnd = this.Handle,
                PixelSize = new Size2(bounds.Width, bounds.Height),
                PresentOptions = PresentOptions.Immediately,
            };
            renderTarget = new WindowRenderTarget(factory, renderTargetProperties, hwndRenderTargetProperties);

            var bitmapProperties = new BitmapProperties()
            {
                PixelFormat = new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Ignore)
            };
            bitmap = new SharpDX.Direct2D1.Bitmap(renderTarget, new Size2(bounds.Width, bounds.Height), bitmapProperties);

            textFormat = new TextFormat(directWriteFacrtory, "Arial", FontWeight.Normal, SharpDX.DirectWrite.FontStyle.Normal, 96.0f);
            textFormat.ParagraphAlignment = ParagraphAlignment.Center;
            textFormat.TextAlignment = TextAlignment.Center;

            solidColorBrush = new SolidColorBrush(renderTarget, Color4.White);
        }
开发者ID:dmak78,项目名称:RoomAliveToolkit,代码行数:29,代码来源:ProjectorForm.cs

示例3: InfoText

        public InfoText(SharpDX.Direct3D11.Device device, int width, int height)
        {
            _immediateContext = device.ImmediateContext;
            _rect.Size = new Size2F(width, height);
            _bitmapSize = width * height * 4;
            IsEnabled = true;

            using (var factoryWic = new SharpDX.WIC.ImagingFactory())
            {
                _wicBitmap = new SharpDX.WIC.Bitmap(factoryWic,
                    width, height, _pixelFormat, SharpDX.WIC.BitmapCreateCacheOption.CacheOnLoad);
            }

            var renderTargetProperties = new RenderTargetProperties(RenderTargetType.Default,
                new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm,
                    SharpDX.Direct2D1.AlphaMode.Premultiplied), 0, 0, RenderTargetUsage.None,
                    SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT);

            using (var factory2D = new SharpDX.Direct2D1.Factory())
            {
                _wicRenderTarget = new WicRenderTarget(factory2D, _wicBitmap, renderTargetProperties);
                _wicRenderTarget.TextAntialiasMode = TextAntialiasMode.Default;
            }

            using (var factoryDWrite = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared))
            {
                _textFormat = new TextFormat(factoryDWrite, "Tahoma", 20);
            }

            Color4 color = new Color4(1, 1, 1, 1);
            _sceneColorBrush = new SolidColorBrush(_wicRenderTarget, color);
            _clearColor = color;
            _clearColor.Alpha = 0;

            _renderTexture = new Texture2D(device, new Texture2DDescription()
            {
                ArraySize = 1,
                BindFlags = BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.Write,
                Format = Format.R8G8B8A8_UNorm,
                Height = height,
                Width = width,
                MipLevels = 1,
                OptionFlags = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1, 0),
                Usage = ResourceUsage.Dynamic
            });

            OverlayBufferRes = new ShaderResourceView(device, _renderTexture, new ShaderResourceViewDescription()
            {
                Format = _renderTexture.Description.Format,
                Dimension = ShaderResourceViewDimension.Texture2D,
                Texture2D = new ShaderResourceViewDescription.Texture2DResource()
                {
                    MipLevels = 1,
                    MostDetailedMip = 0
                }
            });
        }
开发者ID:sinkingsugar,项目名称:BulletSharpPInvoke,代码行数:59,代码来源:InfoText.cs

示例4: Initialize

 //public static Brush TEXT_BRUSH;
 public static void Initialize(RenderTarget g)
 {
     SCBRUSH_RED = new SolidColorBrush(g, Color.Red);
     SCBRUSH_BLACK = new SolidColorBrush(g, Color.Black);
     WRITE_FACTORY = new SharpDX.DirectWrite.Factory();
     TEXT_FORMAT = new TextFormat(WRITE_FACTORY, "Arial", 14);
     //TEXT_BRUSH = new SolidColorBrush(g, Color.Red);
 }
开发者ID:Harrum,项目名称:TestGamePlsIgnore,代码行数:9,代码来源:Resources.cs

示例5: SolidColorBrush

 public SolidColorBrush(D2D.RenderTarget target, Color color)
 {
     if (target != null)
     {
         d2dBrush = new D2D.SolidColorBrush(target, color.ToD2D());
     }
     else
         throw new ArgumentNullException();
 }
开发者ID:denismaster,项目名称:Seal,代码行数:9,代码来源:SolidColorBrush.cs

示例6: InitializeResources

 internal void InitializeResources(RenderTarget d2dRenderTarget)
 {
     if (!initialized)
     {
         Fill = new SolidColorBrush(d2dRenderTarget, Colors.Green);
         Stroke = new SolidColorBrush(d2dRenderTarget, Colors.Azure);
         initialized = true;
        texture = MainGame.LoadFromFile(d2dRenderTarget, @"C:\git\KinectLight\resources\Logo_EDGE_40.bmp");
     }
 }
开发者ID:aL3891,项目名称:KinectLight,代码行数:10,代码来源:ThingBase.cs

示例7: SharpDXDrawing

 public SharpDXDrawing(SharpDXDevice device, Window window)
     : base(device)
 {
     this.device = device;
     brush = new SolidColorBrush(device.RenderTarget, new Color4(lastColor.PackedRgba));
     device.RenderTarget.Transform = Matrix3x2.Identity;
     drawShader = new SharpDXDrawShader(device);
     Reset(window.ViewportPixelSize);
     window.ViewportSizeChanged += Reset;
     device.Context.OutputMerger.BlendState = device.GetAlphaBlendStateLazy();
 }
开发者ID:hillwhite,项目名称:DeltaEngine,代码行数:11,代码来源:SharpDXDrawing.cs

示例8: TextDX

 /* CONSTRUCTOR METHOD */
 /// <summary>
 /// Constructs a 2D block of text that can displayed in a 3D rendering window.
 /// </summary>
 /// <param name="window">A reference to a Direct3D-capable rendering window.</param>
 public TextDX(Window3D window)
     : base(window)
 {
     ColorBrush		= Tag(new SolidColorBrush(RenderTarget, Color4.Black));
     Font			= "Calibri";
     Size			= 16f;
     Style			= FontStyle.Normal;
     Text			= string.Empty;
     UpdateSettings	= true;
     Weight			= FontWeight.Normal;
 }
开发者ID:JoshGrooms,项目名称:Tesseract,代码行数:16,代码来源:TextDX.cs

示例9: Create3dObjects

        public void Create3dObjects()
        {
            //Create RenderWindow
            RenderWindowInstance = new ModelRenderWindow();
            FormInstance = RenderWindowInstance.CreateWindow(1080,1240,FormStartPosition.CenterScreen);

            //Create SwapChain
            SwapChainCreator = new ModelSwapChainDesc();
            SwapChainD = SwapChainCreator.CreateSwapChain(2, Usage.RenderTargetOutput, FormInstance.Handle, true, 0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm, 1,0,SwapChainFlags.AllowModeSwitch, SwapEffect.Discard);

            //Create Device
            Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, SwapChainD, out GraphicsDevice, out NewSwapChain);

            //Create Back buffer
            BackBuffer = Surface.FromSwapChain(NewSwapChain, 0);

            //Create Factory
            FactoryD2D FactoryInstance = new FactoryD2D();

            //Create RenderTarget
            RenderTargetInstance = new ModelRenderTarget();
            RenderTarget = RenderTargetInstance.CreateRenderTarget(SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT, new PixelFormat(Format.Unknown, SharpDX.Direct2D1.AlphaMode.Ignore), RenderTargetType.Default, RenderTargetUsage.None, BackBuffer, FactoryInstance);

            RenderLoop.Run(FormInstance, () =>
            {

                RenderTarget.BeginDraw();
                RenderTarget.Transform = Matrix3x2.Identity;
                RenderTarget.Clear(Color.White);

                using (var brush = new SolidColorBrush(RenderTarget, Color.Red))
                {
                    //for (int x = 0; x < RenderTarget.Size.Width; x += 10)
                    //    RenderTarget.DrawLine(new Vector2(x, 0), new Vector2(x, RenderTarget.Size.Height), brush, 0.5f);

                    //for (int y = 0; y < RenderTarget.Size.Height; y += 10)
                    //    RenderTarget.DrawLine(new Vector2(0, y), new Vector2(RenderTarget.Size.Width, y), brush, 0.5f);
                    RenderTarget.DrawLine(new Vector2(300, 10), new Vector2(300, 300), brush,1.5f);
                   // RenderTarget.FillRectangle(new RectangleF(RenderTarget.Size.Width / 2 - 50, RenderTarget.Size.Height / 2 - 50, 100, 100), brush);
                }

              //  RenderTarget.DrawRectangle(
                   // new RectangleF(RenderTarget.Size.Width / 2 - 100, RenderTarget.Size.Height / 2 - 100, 200, 200),
                   // new SolidColorBrush(RenderTarget, Color.CornflowerBlue));

                RenderTarget.EndDraw();

                NewSwapChain.Present(0, PresentFlags.None);
            });

            RenderTarget.Dispose();
            NewSwapChain.Dispose();
            GraphicsDevice.Dispose();
        }
开发者ID:thornhillad,项目名称:Test3dEngine,代码行数:54,代码来源:ThreeDeeObjects.cs

示例10: Panel

 /* CONSTRUCTOR & DESTRUCTOR METHODS */
 /// <summary>
 /// Constructs a generic 2D rectangular panel that will be displayed as a flat, image-like rendering in the 3D rendering window.
 /// </summary>
 /// <param name="window">A reference to a Direct3D-capable rendering window in which this entity will be displayed.</param>
 protected Panel(Window3D window)
     : base(window)
 {
     BackgroundBrush = Tag(new SolidColorBrush(RenderTarget, Color.SlateGray));
     BorderBrush = Tag(new SolidColorBrush(RenderTarget, Color.SlateGray));
     Rectangle = new RoundedRectangle()
     {
         RadiusX = 0f,
         RadiusY = 0f,
         Rect = new RectangleF(0, 0, 100, 100),
     };
 }
开发者ID:JoshGrooms,项目名称:Tesseract,代码行数:17,代码来源:Panel.cs

示例11: Main

        private static void Main()
        {
            var wicFactory = new ImagingFactory();
            var d2dFactory = new SharpDX.Direct2D1.Factory();

            string filename = "output.jpg";
            const int width = 512;
            const int height = 512;

            var rectangleGeometry = new RoundedRectangleGeometry(d2dFactory, new RoundedRectangle() { RadiusX = 32, RadiusY = 32, Rect = new RectangleF(128, 128, width - 128, height-128) });

            var wicBitmap = new Bitmap(wicFactory, width, height, SharpDX.WIC.PixelFormat.Format32bppBGR, BitmapCreateCacheOption.CacheOnLoad);

            var renderTargetProperties = new RenderTargetProperties(RenderTargetType.Default, new PixelFormat(Format.Unknown, AlphaMode.Unknown), 0, 0, RenderTargetUsage.None, FeatureLevel.Level_DEFAULT);

            var d2dRenderTarget = new WicRenderTarget(d2dFactory, wicBitmap, renderTargetProperties);

            var solidColorBrush = new SolidColorBrush(d2dRenderTarget, Color.White);

            d2dRenderTarget.BeginDraw();
            d2dRenderTarget.Clear(Color.Black);
            d2dRenderTarget.FillGeometry(rectangleGeometry, solidColorBrush, null);
            d2dRenderTarget.EndDraw();

            if (File.Exists(filename))
                File.Delete(filename);

            var stream = new WICStream(wicFactory, filename, NativeFileAccess.Write);
            // Initialize a Jpeg encoder with this stream
            var encoder = new JpegBitmapEncoder(wicFactory);
            encoder.Initialize(stream);

            // Create a Frame encoder
            var bitmapFrameEncode = new BitmapFrameEncode(encoder);
            bitmapFrameEncode.Initialize();
            bitmapFrameEncode.SetSize(width, height);
            var pixelFormatGuid = SharpDX.WIC.PixelFormat.FormatDontCare;
            bitmapFrameEncode.SetPixelFormat(ref pixelFormatGuid);
            bitmapFrameEncode.WriteSource(wicBitmap);

            bitmapFrameEncode.Commit();
            encoder.Commit();

            bitmapFrameEncode.Dispose();
            encoder.Dispose();
            stream.Dispose();

            System.Diagnostics.Process.Start(Path.GetFullPath(Path.Combine(Environment.CurrentDirectory,filename)));
        }
开发者ID:rbwhitaker,项目名称:SharpDX,代码行数:49,代码来源:Program.cs

示例12: Initialize

        protected override void Initialize(DemoConfiguration demoConfiguration)
        {
            base.Initialize(demoConfiguration);
            Factory2D = new SharpDX.Direct2D1.Factory();
            using (var surface = BackBuffer.QueryInterface<Surface>())
            {
                RenderTarget2D = new RenderTarget(Factory2D, surface,
                                                  new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied)));
            }
            RenderTarget2D.AntialiasMode = AntialiasMode.PerPrimitive;

            FactoryDWrite = new SharpDX.DirectWrite.Factory();

            SceneColorBrush = new SolidColorBrush(RenderTarget2D, Color.White);
        }
开发者ID:numo16,项目名称:SharpDX,代码行数:15,代码来源:Direct2D1DemoApp.cs

示例13: Initialize

        protected override void Initialize(DemoConfiguration demoConfiguration)
        {
            Factory2D = new SharpDX.Direct2D1.Factory();
            FactoryDWrite = new SharpDX.DirectWrite.Factory();

            HwndRenderTargetProperties properties = new HwndRenderTargetProperties();
            properties.Hwnd = DisplayHandle;
            properties.PixelSize = new SharpDX.DrawingSize(demoConfiguration.Width, demoConfiguration.Height);
            properties.PresentOptions = PresentOptions.None;

            RenderTarget2D = new WindowRenderTarget(Factory2D, new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied)), properties);

            RenderTarget2D.AntialiasMode = AntialiasMode.PerPrimitive;


            SceneColorBrush = new SolidColorBrush(RenderTarget2D, Color.White);
        }
开发者ID:rbwhitaker,项目名称:SharpDX,代码行数:17,代码来源:Direct2D1WinFormDemoApp.cs

示例14: InitializeGraphics

		private void InitializeGraphics()
		{
			factory = new Factory(FactoryType.SingleThreaded, DebugLevel.None);

			renderTargetProperties = new RenderTargetProperties(new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied));

			hwndRenderTargetProperties = new HwndRenderTargetProperties();
			hwndRenderTargetProperties.Hwnd = this.Handle;
			hwndRenderTargetProperties.PixelSize = new SharpDX.Size2(Width, Height);
			hwndRenderTargetProperties.PresentOptions = PresentOptions.None;

			windowRenderTarget = new WindowRenderTarget(factory, renderTargetProperties, hwndRenderTargetProperties);

			backgroundColor = new RawColor4(BackColor.R, BackColor.G, BackColor.B, BackColor.A);

			borderColor = new SolidColorBrush(windowRenderTarget, new RawColor4(0.5f, 0.5f, 0.5f, 1));
			wayColor = new SolidColorBrush(windowRenderTarget, new RawColor4(0, 0, 1, 0.3f));
			currentPositionColor = new SolidColorBrush(windowRenderTarget, new RawColor4(0, 0, 1, 1));

			graphicsInitialized = true;
		}
开发者ID:MarcusWichelmann,项目名称:StepBot,代码行数:21,代码来源:MapView.cs

示例15: DrawGlyphRun

        public Result DrawGlyphRun(object clientDrawingContext, float baselineOriginX, float baselineOriginY, MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, ComObject clientDrawingEffect)
        {
            var pathGeometry = new PathGeometry(_d2DFactory);
            var geometrySink = pathGeometry.Open();

            var fontFace = glyphRun.FontFace;
            if (glyphRun.Indices.Length > 0)
                fontFace.GetGlyphRunOutline(glyphRun.FontSize, glyphRun.Indices, glyphRun.Advances, glyphRun.Offsets, glyphRun.IsSideways, glyphRun.BidiLevel % 2 != 0, geometrySink);
            geometrySink.Close();
            geometrySink.Dispose();
            fontFace.Dispose();

            var matrix = new Matrix3x2()
            {
                M11 = 1,
                M12 = 0,
                M21 = 0,
                M22 = 1,
                M31 = baselineOriginX,
                M32 = baselineOriginY
            };

            var transformedGeometry = new TransformedGeometry(_d2DFactory, pathGeometry, matrix);

            var  brushColor = (Color4)Color.Black;

            if (clientDrawingEffect != null && clientDrawingEffect is ColorDrawingEffect)
                brushColor = (clientDrawingEffect as ColorDrawingEffect).Color;

            var brush = new SolidColorBrush(_renderTarget, brushColor);
            
            _renderTarget.DrawGeometry(transformedGeometry, brush);
            _renderTarget.FillGeometry(transformedGeometry, brush);

            pathGeometry.Dispose();
            transformedGeometry.Dispose();
            brush.Dispose();

            return SharpDX.Result.Ok;
        }
开发者ID:numo16,项目名称:SharpDX,代码行数:40,代码来源:CustomTextRenderer.cs


注:本文中的SharpDX.Direct2D1.SolidColorBrush类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。