本文整理汇总了C#中SharpDX.Direct2D1.RenderTarget.FillGeometry方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTarget.FillGeometry方法的具体用法?C# RenderTarget.FillGeometry怎么用?C# RenderTarget.FillGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpDX.Direct2D1.RenderTarget
的用法示例。
在下文中一共展示了RenderTarget.FillGeometry方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderScatterGeometry
public void RenderScatterGeometry(RenderTarget renderTarget)
{
double[] x = curve.X;
double[] y = curve.Y;
int length = x.Length;
double xScale, xOffset, yScale, yOffset;
xScale = graphToCanvas.Matrix.M11;
xOffset = graphToCanvas.Matrix.OffsetX - this.xOffsetMarker;
yScale = graphToCanvas.Matrix.M22;
yOffset = graphToCanvas.Matrix.OffsetY - this.yOffsetMarker;
bool[] include = curve.includeMarker;
StrokeStyleProperties properties = new StrokeStyleProperties();
properties.LineJoin = LineJoin.MiterOrBevel;
StrokeStyle strokeStyle = new StrokeStyle(renderTarget.Factory, properties);
for (int i = 0; i < length; ++i)
{
if (include[i])
{
renderTarget.Transform = (Matrix3x2)Matrix.Translation((float)(x[i] * xScale + xOffset), (float)(y[i] * yScale + yOffset), 0);
renderTarget.FillGeometry(Geometry, FillBrush);
renderTarget.DrawGeometry(Geometry, Brush, (float)StrokeThickness, strokeStyle);
}
}
renderTarget.Transform = Matrix3x2.Identity;
}
示例2: Render2D
/// <summary>
/// render the circle to specific render target of Direct2D1
/// </summary>
/// <param name="renderTarget"></param>
public void Render2D(RenderTarget renderTarget, SharpDX.Direct2D1.Brush brush)
{
// check if the geometry is dirty
if (isGeometryDirty)
{
// dispose the old geometry
if (TriangleGeometry != null)
{
TriangleGeometry.Dispose();
}
// create a new one
TriangleGeometry = new PathGeometry(renderTarget.Factory);
// fill the geometry struct
using (GeometrySink Geo_Sink = TriangleGeometry.Open())
{
// create the figure
Geo_Sink.BeginFigure(mp_P1, FigureBegin.Filled);
Geo_Sink.AddLine(mp_P2);
Geo_Sink.AddLine(mp_P3);
Geo_Sink.EndFigure(FigureEnd.Closed);
// close the mesh
Geo_Sink.Close();
}
// set the geometry that is the final
isGeometryDirty = false;
}
// draw the wireframe of the triangle
renderTarget.DrawGeometry(TriangleGeometry, brush, _LineWidth);
if (fillTheTriangle)
{
// check if we must renew the brush
if (fillColorDirty)
{
// dispose the old brush
if (fillColorBrush != null)
fillColorBrush.Dispose();
// create the new one
fillColorBrush = new SolidColorBrush(renderTarget, fillColor);
// set that the color is the correct
fillColorDirty = false;
}
// fill the triangle
renderTarget.FillGeometry(TriangleGeometry, fillColorBrush);
}
}
示例3: Main
private static void Main()
{
var form = new RenderForm("SharpDX - MiniTri Direct2D - Direct3D 10 Sample");
// SwapChain description
var desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription =
new ModeDescription(form.ClientSize.Width, form.ClientSize.Height,
new Rational(60, 1), Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = form.Handle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
};
// Create Device and SwapChain
Device1 device;
SwapChain swapChain;
Device1.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, desc, FeatureLevel.Level_10_0, out device, out swapChain);
var d2dFactory = new SharpDX.Direct2D1.Factory();
int width = form.ClientSize.Width;
int height = form.ClientSize.Height;
var rectangleGeometry = new RoundedRectangleGeometry(d2dFactory, new RoundedRectangle() { RadiusX = 32, RadiusY = 32, Rect = new RectangleF(128, 128, width - 128 * 2, height-128 * 2) });
// Ignore all windows events
Factory factory = swapChain.GetParent<Factory>();
factory.MakeWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll);
// New RenderTargetView from the backbuffer
Texture2D backBuffer = Texture2D.FromSwapChain<Texture2D>(swapChain, 0);
var renderView = new RenderTargetView(device, backBuffer);
Surface surface = backBuffer.QueryInterface<Surface>();
var d2dRenderTarget = new RenderTarget(d2dFactory, surface,
new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied)));
var solidColorBrush = new SolidColorBrush(d2dRenderTarget, Color.White);
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
// Main loop
RenderLoop.Run(form, () =>
{
d2dRenderTarget.BeginDraw();
d2dRenderTarget.Clear(Color.Black);
solidColorBrush.Color = new Color4(1, 1, 1, (float)Math.Abs(Math.Cos(stopwatch.ElapsedMilliseconds * .001)));
d2dRenderTarget.FillGeometry(rectangleGeometry, solidColorBrush, null);
d2dRenderTarget.EndDraw();
swapChain.Present(0, PresentFlags.None);
});
// Release all resources
renderView.Dispose();
backBuffer.Dispose();
device.ClearState();
device.Flush();
device.Dispose();
device.Dispose();
swapChain.Dispose();
factory.Dispose();
}
示例4: Main
static void Main()
{
var form = new RenderForm("FUN STUFF PHYSXS");
// SwapChain description
var desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription =
new ModeDescription(form.ClientSize.Width, form.ClientSize.Height,
new Rational(60, 1), Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = form.Handle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
};
// Create Device and SwapChain
Device device;
SwapChain swapChain;
Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, new SharpDX.Direct3D.FeatureLevel[] { SharpDX.Direct3D.FeatureLevel.Level_10_0 }, desc, out device, out swapChain);
var d2dFactory = new SharpDX.Direct2D1.Factory();
// Ignore all windows events
Factory factory = swapChain.GetParent<Factory>();
factory.MakeWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll);
// New RenderTargetView from the backbuffer
Texture2D backBuffer = Texture2D.FromSwapChain<Texture2D>(swapChain, 0);
var renderView = new RenderTargetView(device, backBuffer);
Surface surface = backBuffer.QueryInterface<Surface>();
var d2dRenderTarget = new RenderTarget(d2dFactory, surface,
new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied)));
var solidColorBrush = new SolidColorBrush(d2dRenderTarget, Color.White);
var sim = new Simulation();
// Main loop
RenderLoop.Run(form, () =>
{
d2dRenderTarget.BeginDraw();
int width = form.ClientSize.Width;
int height = form.ClientSize.Height;
var simScaleX = sim.SimBounds.MaxX - sim.SimBounds.MinX;
var simScaleY = sim.SimBounds.MaxY - sim.SimBounds.MinY;
var viewScaleX = sim.ViewBounds.MaxX - sim.ViewBounds.MinX;
var viewScaleY = sim.ViewBounds.MaxY - sim.ViewBounds.MinY;
d2dRenderTarget.Clear(Color.Black);
foreach (Body body in sim.State)
{
var x = Convert.ToSingle((body.Pos.X - sim.SimBounds.MinX) * width / simScaleX);
var y = Convert.ToSingle((body.Pos.Y - sim.SimBounds.MinY) * height / simScaleY);
var xRad = Convert.ToSingle((body.Radius) * width / viewScaleX);
var yRad = Convert.ToSingle((body.Radius) * height / viewScaleY);
var elipse = new EllipseGeometry(d2dFactory, new Ellipse(new Vector2(x, y), xRad, yRad));
d2dRenderTarget.FillGeometry(elipse, solidColorBrush, null);
}
d2dRenderTarget.EndDraw();
sim.Step();
swapChain.Present(0, PresentFlags.None);
});
// Release all resources
renderView.Dispose();
backBuffer.Dispose();
device.ImmediateContext.ClearState();
device.ImmediateContext.Flush();
device.Dispose();
device.Dispose();
swapChain.Dispose();
factory.Dispose();
}
示例5: Render
public override void Render(RenderTarget renderTarget)
{
if (!IsVisible) return;
CurrentBorderBrush.Resource.Opacity = this.Opacity;
CurrentBackgroundBrush.Resource.Opacity = this.Opacity;
renderTarget.Transform = this.Transform;
//TODO: Check if we need a second rect for this...
renderTarget.PushAxisAlignedClip(this.ClippingRectangle, AntialiasMode.Aliased);
try {
if (DrawBackground) {
renderTarget.FillGeometry(_backgroundGeometry, CurrentBackgroundBrush.Resource);
//if (CurrentBitmap != null)
// renderTarget.DrawBitmap(CurrentBitmap.Resource, Opacity, BitmapInterpolationMode.Linear);
}
if (DrawBorder)
renderTarget.DrawGeometry(_backgroundGeometry, CurrentBorderBrush.Resource);
if (DrawText && !String.IsNullOrEmpty(_text))
renderTarget.DrawTextLayout(new DrawingPointF(TextIndent, 0f), RenderedText, CurrentFontBrush.Resource);
base.Render(renderTarget);
} finally {
renderTarget.PopAxisAlignedClip();
}
}