/// <summary> /// デバイスを初期化します. /// </summary> public new void Load() { base.Load(false, D3D.DeviceCreationFlags.BgraSupport, DeviceCreationFlags.BgraSupport); //ラスタライザの設定を上書き var blendDesc = new D3D.BlendStateDescription(); blendDesc.AlphaToCoverageEnable = true; // Alpha to Coverage を有効にする blendDesc.IndependentBlendEnable = false; for (int i = 0; i < blendDesc.RenderTargets.Length; i++) { blendDesc.RenderTargets[i].BlendEnable = true; blendDesc.RenderTargets[i].SourceBlend = D3D.BlendOption.SourceAlpha; blendDesc.RenderTargets[i].DestinationBlend = D3D.BlendOption.InverseSourceAlpha; blendDesc.RenderTargets[i].BlendOperation = D3D.BlendOperation.Add; blendDesc.RenderTargets[i].SourceBlendAlpha = D3D.BlendOption.One; blendDesc.RenderTargets[i].DestinationBlendAlpha = D3D.BlendOption.One; // ここを1にしないとアルファの合成が変 blendDesc.RenderTargets[i].BlendOperationAlpha = D3D.BlendOperation.Add; blendDesc.RenderTargets[i].RenderTargetWriteMask = D3D.ColorWriteMaskFlags.All; } customBlendState = Context.OutputMerger.BlendState = D3D.BlendState.FromDescription(Device, blendDesc); d2dFactory = new D2D.Factory(D2D.FactoryType.Multithreaded); dwFactory = new DW.Factory(DW.FactoryType.Shared); }
public DX11TextLayerAdvancedNode(IIOFactory factory, SlimDX.DirectWrite.Factory dwFactory) { this.iofactory = factory; this.dwFactory = dwFactory; this.iofactory.PluginHost.CreateTransformInput("Transform In", TSliceMode.Dynamic, TPinVisibility.True, out this.transformIn); this.transformIn.Order = 1; }
private void CreateTextFormat() { var factory = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared); mTextFormat = factory.CreateTextFormat("Consola", FontWeight.Normal, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 100, "en-us"); mTextFormat.TextAlignment = TextAlignment.Center; mTextFormat.ParagraphAlignment = ParagraphAlignment.Center; }
public DWOutlinedText(D2D.Factory d2dFactory, DW.Factory dwFactory, string fontfile, int fontFaceIndex, DW.FontFaceType fontFaceType) { _d2DFactory = d2dFactory; _dwFactory = dwFactory; _fontFile = _dwFactory.CreateFontFileReference(fontfile); _fontFaceIndex = fontFaceIndex; _fontFaceType = fontFaceType; }
public D2DInteropHandler(RenderManager manager) { Manager = manager; #if DEBUG D3DDevice10 = new D3D101.Device1(manager.DXGIAdapter, D3D10.DriverType.Hardware, D3D10.DeviceCreationFlags.BgraSupport | D3D10.DeviceCreationFlags.Debug, D3D101.FeatureLevel.Level_10_0); #else D3DDevice10 = new D3D101.Device1(D3D10.DriverType.Hardware, D3D10.DeviceCreationFlags.BgraSupport, D3D101.FeatureLevel.Level_10_0); #endif D2DFactory = new D2D.Factory(D2D.FactoryType.SingleThreaded); DWFactory = new DW.Factory(DW.FactoryType.Shared); }
public ProgressUpdate(WindowRenderTarget rt1) { _rt = rt1; _brush = new SolidColorBrush(_rt, Color.Green); _clearColor = new SolidColorBrush(_rt, Color.Black); _borderBounds = new Rectangle(18, rt1.PixelSize.Height / 2 - 2, rt1.PixelSize.Width - 36, 24); _barBounds = new Rectangle(20, rt1.PixelSize.Height / 2, rt1.PixelSize.Width - 40, 20); _factory = new Factory(FactoryType.Isolated); _txtFormat = new TextFormat(_factory, "Arial", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 18, "en-us") { TextAlignment = TextAlignment.Center }; _textRect = new Rectangle(100, rt1.PixelSize.Height / 2 - 25, _rt.PixelSize.Width - 200, 20); }
public d2dengine(Control container, List <gameobject> theList) { ToDraw = theList; targetControl = container; debugLevel = DebugLevel.None; d2dFactory = new SlimDX.Direct2D.Factory(SlimDX.Direct2D.FactoryType.Multithreaded, debugLevel); wrtFactory = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared); d2dWindowRenderTarget = new WindowRenderTarget(d2dFactory, new WindowRenderTargetProperties() { Handle = targetControl.Handle, PixelSize = targetControl.Size, PresentOptions = PresentOptions.Immediately }); }
public void Render(SlimDX.Direct2D.Factory factory, SlimDX.DirectWrite.Factory dwFactory, RenderTarget renderTarget) { if (this.brush == null) { brush = new SolidColorBrush(renderTarget, new Color4(1.0f, 1.0f, 1.0f)); txtFormat = dwFactory.CreateTextFormat("lcd phone", FontWeight.Regular, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 60, "en-us"); } SizeF newWindowSize = renderTarget.Size; if (windowSize == null || !windowSize.Equals(newWindowSize)) { windowSize = newWindowSize; float centerX = windowSize.Width / 2; rect = new RectangleF(new PointF(centerX + posOffset.X, posOffset.Y), textLayoutSize); } renderTarget.DrawText(val.ToString(), txtFormat, rect, brush); }
public override void OnInit(Game currentGame, Form owner, Save settings) { base.currentGame = currentGame; base.owner = owner; base.info = settings; this.owner.Controls.Add(this); this.Dock = DockStyle.Fill; try { SlimDX.DirectWrite.Factory m = new SlimDX.DirectWrite.Factory(FactoryType.Shared); textFormatCentered = m.CreateTextFormat(this.Font.FontFamily.Name, SlimDX.DirectWrite.FontWeight.Regular, SlimDX.DirectWrite.FontStyle.Normal, SlimDX.DirectWrite.FontStretch.Expanded, 50, "de-de"); textFormatCentered.TextAlignment = SlimDX.DirectWrite.TextAlignment.Center; textFormatCentered.ParagraphAlignment = SlimDX.DirectWrite.ParagraphAlignment.Center; } catch (Exception) { } this.initializeGraphics(); this.FinishedInit = true; this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque | ControlStyles.ResizeRedraw, true); this.UpdateStyles(); try { if (string.IsNullOrEmpty(settings.Background)) { this.BackgroundImage = Image.FromFile(System.IO.Path.Combine(Application.StartupPath, "Images", "Image.jpg")); } else { this.BackgroundImage = Image.FromFile(settings.Background); } } catch (Exception) { } this.e = new Graphics.DirectGraphics(this.renderTarget); this.Invalidate(); }
/// <summary> /// In a derived class, implements logic to initialize the sample. /// </summary> protected override void OnInitialize() { DeviceSettings2D settings = new DeviceSettings2D { Width = WindowWidth, Height = WindowHeight }; InitializeDevice(settings); _writeFactory = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared); _textFormat = _writeFactory.CreateTextFormat("Gabriola", FontWeight.Regular, FontStyle.Normal, FontStretch.Normal, 72.0f, "en-us"); _textFormat.TextAlignment = TextAlignment.Center; _textFormat.ParagraphAlignment = ParagraphAlignment.Center; using (Graphics graphics = Graphics.FromHwnd(_mainForm.Handle)) { _dpiY = graphics.DpiY / 96.0f; _dpiX = graphics.DpiX / 96.0f; } InitializeSimpleText(); InitializeMultiformattedText(); }
public MeasureTextNode(DWriteFactory dwFactory) { this.dwFactory = dwFactory; }
public static void Init(RenderTarget renderTarget) { FullRectangle = new RectangleF(0, 0, Bounds.Width, Bounds.Height); ProgressBarBounds = new RectangleF(20 + DebugRectangle.X + DebugRectangle.Width, 20, Bounds.Width - 40 - DebugRectangle.X - DebugRectangle.Width, 20); // Generate common brushes DefaultBrushes = new Brush[DefaultColors.Length]; for (int i = 0; i < DefaultColors.Length; i++) { DefaultBrushes[i] = new SolidColorBrush(renderTarget, DefaultColors[i]); } ChannelBrushes = new Brush[ChannelColors.Length]; for (int i = 0; i < ChannelColors.Length; i++) { ChannelBrushes[i] = new SolidColorBrush(renderTarget, ChannelColors[i]); } // Generate common gradients KeyboardGradient = new LinearGradientBrush(renderTarget, new GradientStopCollection(renderTarget, new[] { new GradientStop() { Color = new Color4(Color.White), Position = 0 }, new GradientStop() { Color = new Color4(Color.DarkGray), Position = 1 } }), new LinearGradientBrushProperties() { StartPoint = new PointF(0, renderTarget.Size.Height), EndPoint = new PointF(0, renderTarget.Size.Height - KeyHeight) }); BackgroundGradient = new LinearGradientBrush(renderTarget, new GradientStopCollection(renderTarget, new[] { new GradientStop() { Color = Color.Black, Position = 1f }, new GradientStop() { Color = Color.FromArgb(30, 30, 30), Position = 0f } }), new LinearGradientBrushProperties() { StartPoint = new PointF(0, renderTarget.Size.Height), EndPoint = new PointF(0, 0) }); ChannelGradientBrushes = new LinearGradientBrush[ChannelColors.Length]; for (int i = 0; i < ChannelGradientBrushes.Length; i++) { ChannelGradientBrushes[i] = new LinearGradientBrush(renderTarget, new GradientStopCollection(renderTarget, new[] { new GradientStop() { Color = ChannelColors[i], Position = 1f }, new GradientStop() { Color = ControlPaint.Light(ChannelColors[i], .8f), Position = 0f } }), new LinearGradientBrushProperties() { StartPoint = new PointF(0, renderTarget.Size.Height), EndPoint = new PointF(0, 0) }); } // Generate common fonts using (var textFactory = new Factory()) { DebugFormat = new TextFormat(textFactory, "Consolas", FontWeight.Bold, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 14, "en-us"); SmallFormat = new TextFormat(textFactory, "Century Gothic", FontWeight.UltraBold, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 10, "en-us"); HugeFormat = new TextFormat(textFactory, "Century Gothic", FontWeight.UltraBold, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 50, "en-us") { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center }; } }
public CaretPositionNode(DWriteFactory dwFactory) { this.dwFactory = dwFactory; }
/// <summary> /// In a derived class, implements logic to initialize the sample. /// </summary> protected override void OnInitialize() { DeviceSettings2D settings = new DeviceSettings2D { Width = WindowWidth, Height = WindowHeight }; InitializeDevice(settings); _writeFactory = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared); _textFormat = _writeFactory.CreateTextFormat("Gabriola", FontWeight.Regular, FontStyle.Normal, FontStretch.Normal, 72.0f, "en-us"); _textFormat.TextAlignment = TextAlignment.Center; _textFormat.ParagraphAlignment = ParagraphAlignment.Center; using (Graphics graphics = Graphics.FromHwnd(_mainForm.Handle)) { _dpiY = graphics.DpiY/96.0f; _dpiX = graphics.DpiX/96.0f; } InitializeSimpleText(); InitializeMultiformattedText(); }
public CaretRangeNode(DWriteFactory dwFactory) { this.dwFactory = dwFactory; }
public TextLayoutMetricsNode(DWriteFactory dwFactory) { this.dwFactory = dwFactory; }
public FontTypographyStyle(DWriteFactory dwFactory) { this.dwFactory = dwFactory; }
public TextLayoutLineMetricsNode(DWriteFactory dwFactory) { this.dwFactory = dwFactory; }
public DX11TextLayerCacheNode(SlimDX.DirectWrite.Factory dwFactory) { this.dwFactory = dwFactory; }
public TextLayoutClusterMetricsNode(DWriteFactory dwFactory) { this.dwFactory = dwFactory; }
public HitTestTextNode(DWriteFactory dwFactory) { this.dwFactory = dwFactory; }
public TextLayoutAdvancedNode(DWriteFactory dwFactory) { this.dwFactory = dwFactory; }
public void Using_DirectWrite() { Device device; SwapChain swapChain; RenderTargetView renderTarget; EmptyWindow.CreateDeviceSwapChainAndRenderTarget(mForm, out device, out swapChain, out renderTarget); var direct2dfactory = new Direct2DFactory(); var directWriteFactory = new DirectWriteFactory(); var properties = new WindowRenderTargetProperties { Handle = mForm.Handle, PixelSize = mForm.ClientSize }; var windowRenderTarget = new WindowRenderTarget(direct2dfactory, properties); var brush = new SolidColorBrush(windowRenderTarget, Color.Black); var textFormat = new TextFormat(directWriteFactory, "Gabriola", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 72.0f, "en-us") { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center }; Application.Idle += delegate { device.ClearRenderTargetView(renderTarget, new Color4(1, 0, 0)); if (!windowRenderTarget.IsOccluded) { windowRenderTarget.BeginDraw(); windowRenderTarget.Transform = Matrix3x2.Identity; windowRenderTarget.Clear(Color.White); windowRenderTarget.DrawText("Hello World using DirectWrite!", textFormat, mForm.ClientRectangle, brush); windowRenderTarget.EndDraw(); } swapChain.Present(0, PresentFlags.None); Application.DoEvents(); }; Application.Run(mForm); }
public TextLayoutNode(DWriteFactory dwFactory) { this.dwFactory = dwFactory; }
public TextFormatNode(DWriteFactory dwFactory) { this.dwFactory = dwFactory; }
public static void Init(RenderTarget renderTarget) { // Generate common brushes DefaultBrushes = new Brush[DefaultColors.Length]; for (int i = 0; i < DefaultColors.Length; i++) DefaultBrushes[i] = new SolidColorBrush(renderTarget, DefaultColors[i]); ChannelBrushes = new Brush[ChannelColors.Length]; for (int i = 0; i < ChannelColors.Length; i++) ChannelBrushes[i] = new SolidColorBrush(renderTarget, ChannelColors[i]); // Generate common gradients KeyboardGradient = new LinearGradientBrush(renderTarget, new GradientStopCollection(renderTarget, new[] { new GradientStop() { Color = new Color4(Color.White),Position = 0 }, new GradientStop() { Color = new Color4(Color.DarkGray), Position = 1 } }), new LinearGradientBrushProperties() { StartPoint = new PointF(0, renderTarget.Size.Height), EndPoint = new PointF(0, renderTarget.Size.Height - KEY_HEIGHT) }); BackgroundGradient = new LinearGradientBrush(renderTarget, new GradientStopCollection(renderTarget, new[] { new GradientStop() { Color = Color.Black, Position = 1f }, new GradientStop() { Color = Color.FromArgb(30, 30, 30), Position = 0f } }), new LinearGradientBrushProperties() { StartPoint = new PointF(0, renderTarget.Size.Height), EndPoint = new PointF(0, 0) }); ChannelGradientBrushes = new LinearGradientBrush[ChannelColors.Length]; for (int i = 0; i < ChannelGradientBrushes.Length; i++) { ChannelGradientBrushes[i] = new LinearGradientBrush(renderTarget, new GradientStopCollection(renderTarget, new[] { new GradientStop() { Color = ChannelColors[i], Position = 1f }, new GradientStop() { Color = ControlPaint.Light(ChannelColors[i], .8f), Position = 0f } }), new LinearGradientBrushProperties() { StartPoint = new PointF(0, renderTarget.Size.Height), EndPoint = new PointF(0, 0) }); } // Generate common fonts using (var textFactory = new Factory()) { DebugFormat = new TextFormat(textFactory, "Consolas", FontWeight.UltraBold, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 18, "en-us"); HugeFormat = new TextFormat(textFactory, "Consolas", FontWeight.UltraBold, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 50, "en-us") { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center }; } }
public override void OnInit(Game currentGame, Form owner, Save settings) { base.currentGame = currentGame; base.owner = owner; base.info = settings; this.owner.Controls.Add(this); this.Dock = DockStyle.Fill; try { SlimDX.DirectWrite.Factory m = new SlimDX.DirectWrite.Factory(FactoryType.Shared); textFormatCentered = m.CreateTextFormat(this.Font.FontFamily.Name, SlimDX.DirectWrite.FontWeight.Regular, SlimDX.DirectWrite.FontStyle.Normal, SlimDX.DirectWrite.FontStretch.Expanded, 50, "de-de"); textFormatCentered.TextAlignment = SlimDX.DirectWrite.TextAlignment.Center; textFormatCentered.ParagraphAlignment = SlimDX.DirectWrite.ParagraphAlignment.Center; } catch (Exception) { } this.initializeGraphics(); this.FinishedInit = true; this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque | ControlStyles.ResizeRedraw, true); this.UpdateStyles(); try { if (string.IsNullOrEmpty(settings.Background)) this.BackgroundImage = Image.FromFile(System.IO.Path.Combine(Application.StartupPath, "Images", "Image.jpg")); else this.BackgroundImage = Image.FromFile(settings.Background); } catch (Exception) { } this.e = new Graphics.DirectGraphics(this.renderTarget); this.Invalidate(); }