本文整理匯總了C#中SharpDX.Direct2D1.RenderTarget.DrawGeometry方法的典型用法代碼示例。如果您正苦於以下問題:C# RenderTarget.DrawGeometry方法的具體用法?C# RenderTarget.DrawGeometry怎麽用?C# RenderTarget.DrawGeometry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SharpDX.Direct2D1.RenderTarget
的用法示例。
在下文中一共展示了RenderTarget.DrawGeometry方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: Render2D
public void Render2D(RenderTarget renderTarget, Brush brush)
{
#region Update Color Brush
// if the brush is dirty renew it
if (m_isLineColorBrushDirty && !m_useDefaultColor)
{
// clean the color brush
if (m_lineColorBrush != null)
m_lineColorBrush.Dispose();
// allocate a new one
m_lineColorBrush = new SolidColorBrush(renderTarget, m_lineColor);
// clean the flag
m_isLineColorBrushDirty = false;
}
#endregion
if (m_path.Count > 0)
{
// Update geometry
if (isGeometryDirty)
{
if (m_sharpGeometry != null)
m_sharpGeometry.Dispose();
m_sharpGeometry = new PathGeometry(renderTarget.Factory);
using (GeometrySink Geo_Sink = m_sharpGeometry.Open())
{
int count = m_path.Count;
// create the path
Geo_Sink.BeginFigure(m_path[0].GetVector2(), FigureBegin.Filled);
for (int i = 1; i < count; i++)
{
Geo_Sink.AddLine(m_path[i].GetVector2());
}
Geo_Sink.EndFigure(FigureEnd.Open);
Geo_Sink.Close();
}
isGeometryDirty = false;
}
// check if we use other color
if (m_useDefaultColor || m_lineColorBrush == null)
{
renderTarget.DrawGeometry(m_sharpGeometry, brush, m_lineWidth);
}
else
{
renderTarget.DrawGeometry(m_sharpGeometry, m_lineColorBrush, m_lineWidth);
}
}
}
示例4: Run
//.........這裏部分代碼省略.........
// ---------------------------------------------------------------------------------------------------
// Acquire the mutexes. These are needed to assure the device in use has exclusive access to the surface
// ---------------------------------------------------------------------------------------------------
var device10Mutex = textureD3D10.QueryInterface<KeyedMutex>();
var device11Mutex = textureD3D11.QueryInterface<KeyedMutex>();
// ---------------------------------------------------------------------------------------------------
// Main rendering loop
// ---------------------------------------------------------------------------------------------------
bool first = true;
RenderLoop
.Run(form,
() =>
{
if(first)
{
form.Activate();
first = false;
}
// clear the render target to black
context.ClearRenderTargetView(renderTargetView, Colors.DarkSlateGray);
// Draw the triangle
context.InputAssembler.InputLayout = layoutColor;
context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBufferColor, VertexPositionColor.SizeInBytes, 0));
context.OutputMerger.BlendState = null;
var currentTechnique = effect.GetTechniqueByName("Color");
for (var pass = 0; pass < currentTechnique.Description.PassCount; ++pass)
{
using (var effectPass = currentTechnique.GetPassByIndex(pass))
{
System.Diagnostics.Debug.Assert(effectPass.IsValid, "Invalid EffectPass");
effectPass.Apply(context);
}
context.Draw(3, 0);
};
// Draw Ellipse on the shared Texture2D
device10Mutex.Acquire(0, 100);
renderTarget2D.BeginDraw();
renderTarget2D.Clear(Colors.Black);
renderTarget2D.DrawGeometry(tesselatedGeometry, solidColorBrush);
renderTarget2D.DrawEllipse(new Ellipse(center, 200, 200), solidColorBrush, 20, null);
renderTarget2D.EndDraw();
device10Mutex.Release(0);
// Draw the shared texture2D onto the screen, blending the 2d content in
device11Mutex.Acquire(0, 100);
var srv = new ShaderResourceView(device11, textureD3D11);
effect.GetVariableByName("g_Overlay").AsShaderResource().SetResource(srv);
context.InputAssembler.InputLayout = layoutOverlay;
context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBufferOverlay, VertexPositionTexture.SizeInBytes, 0));
context.OutputMerger.BlendState = blendStateTransparent;
currentTechnique = effect.GetTechniqueByName("Overlay");
for (var pass = 0; pass < currentTechnique.Description.PassCount; ++pass)
{
using (var effectPass = currentTechnique.GetPassByIndex(pass))
{
System.Diagnostics.Debug.Assert(effectPass.IsValid, "Invalid EffectPass");
effectPass.Apply(context);
}
context.Draw(4, 0);
}
srv.Dispose();
device11Mutex.Release(0);
swapChain.Present(0, PresentFlags.None);
});
// dispose everything
vertexBufferColor.Dispose();
vertexBufferOverlay.Dispose();
layoutColor.Dispose();
layoutOverlay.Dispose();
effect.Dispose();
shaderByteCode.Dispose();
renderTarget2D.Dispose();
swapChain.Dispose();
device11.Dispose();
device10.Dispose();
textureD3D10.Dispose();
textureD3D11.Dispose();
factory1.Dispose();
adapter1.Dispose();
sharedResource.Dispose();
factory2D.Dispose();
surface.Dispose();
solidColorBrush.Dispose();
blendStateTransparent.Dispose();
device10Mutex.Dispose();
device11Mutex.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();
}
}
示例6: Render2D
public void Render2D(RenderTarget renderTarget, Brush brush)
{
#region Update Color Brush
// if the brush is dirty renew it
if (m_isLineColorBrushDirty && !m_useDefaultColor)
{
// clean the color brush
if (m_lineColorBrush != null)
m_lineColorBrush.Dispose();
// allocate a new one
m_lineColorBrush = new SolidColorBrush(renderTarget, m_lineColor);
// clean the flag
m_isLineColorBrushDirty = false;
}
#endregion
if(isGeometryDirty)
{
if (m_sharpGeometry != null)
m_sharpGeometry.Dispose();
m_sharpGeometry = new PathGeometry(renderTarget.Factory);
using(GeometrySink Geo_Sink = m_sharpGeometry.Open())
{
// draw the rectangle
Geo_Sink.BeginFigure(m_start.GetVector2(), FigureBegin.Filled);
Geo_Sink.AddLine(new SharpDX.Vector2(m_start.x, m_end.y));
Geo_Sink.AddLine(m_end.GetVector2());
Geo_Sink.AddLine(new SharpDX.Vector2(m_end.x, m_start.y));
Geo_Sink.EndFigure(FigureEnd.Closed);
Geo_Sink.Close();
}
isGeometryDirty = false;
}
// check if we use other color
if (m_useDefaultColor || m_lineColorBrush == null)
{
renderTarget.DrawGeometry(m_sharpGeometry, brush, m_lineWidth);
}
else
{
renderTarget.DrawGeometry(m_sharpGeometry, m_lineColorBrush, m_lineWidth);
}
}