本文整理匯總了C#中SharpDX.Direct2D1.RenderTarget.DrawLine方法的典型用法代碼示例。如果您正苦於以下問題:C# RenderTarget.DrawLine方法的具體用法?C# RenderTarget.DrawLine怎麽用?C# RenderTarget.DrawLine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SharpDX.Direct2D1.RenderTarget
的用法示例。
在下文中一共展示了RenderTarget.DrawLine方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnRender
public void OnRender(RenderTarget target)
{
if(gBorderBrush == null)
{
gBackgroundBrush = Brushes.Solid[0xCC555555];
gBackgroundHoverBrush = Brushes.Solid[0xCC888888];
gClickBrush = Brushes.Solid[0xFFFF7F00];
gBackgroundClickedBrush = Brushes.Solid[0xCCBBBBBB];
gBorderBrush = Brushes.White;
}
target.DrawTextLayout(new Vector2(Position.X + Size + 7, Position.Y - 2), mTextDraw, Brushes.White);
var brush = gBackgroundBrush;
if (mIsPressed)
brush = gBackgroundClickedBrush;
else if (mIsHovered)
brush = gBackgroundHoverBrush;
target.FillRectangle(mTargetRect, brush);
target.DrawRectangle(mTargetRect, gBorderBrush);
if (!Checked) return;
target.DrawLine(Position + new Vector2(3, 3), Position + new Vector2(mSize - 3, mSize - 3), gClickBrush,
mSize / 4.0f);
target.DrawLine(new Vector2(Position.X + 3, Position.Y + mSize - 3),
new Vector2(Position.X + mSize - 3, Position.Y + 3), gClickBrush, mSize / 4.0f);
}
示例2: 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();
}
示例3: OnRender
public void OnRender(RenderTarget target)
{
target.FillRectangle(new RectangleF(0, 0, mSize.X, mSize.Y), Brushes.Solid[0xFF333333]);
target.PushAxisAlignedClip(new RectangleF(0, 100, mSize.X, mSize.Y - 100), AntialiasMode.Aliased);
foreach (var label in mMapLabels)
label.OnRender(target);
target.PopAxisAlignedClip();
target.DrawLine(new Vector2(0, 100.0f), new Vector2(mSize.X, 100.0f), Brushes.White);
mTitleLabel.OnRender(target);
mLabelScroll.OnRender(target);
}
示例4: OnRender
public void OnRender(RenderTarget target)
{
var borderStart = new Vector2(mPosition.X + BorderOffsets.X, mPosition.Y);
var borderEnd = new Vector2(mPosition.X + mSize.X - BorderOffsets.Y, mPosition.Y);
target.FillRectangle(mTargetRectangle, Brushes.Solid[0xCC333333]);
target.DrawLine(borderStart, borderEnd, Brushes.White);
var ot = target.Transform;
target.Transform *= Matrix3x2.Translation(Position.X, Position.Y);
foreach (var item in Items)
item.OnRender(target);
target.Transform = ot;
}
示例5: OnRender
public void OnRender(RenderTarget target)
{
UpdateCaret();
var transform = target.Transform;
target.Transform *= Matrix3x2.Translation(Position);
target.AntialiasMode = AntialiasMode.Aliased;
target.FillRectangle(new RectangleF(0, 0, mSize.X, mSize.Y), Brushes.Solid[0xCC111111]);
target.DrawRectangle(new RectangleF(0, 0, mSize.X, mSize.Y), Brushes.Solid[System.Drawing.Color.White]);
target.PushAxisAlignedClip(new RectangleF(4, 0, mSize.X - 8, mSize.Y), AntialiasMode.Aliased);
target.DrawTextLayout(new Vector2(mStartPosition, 0), mTextDraw, Brushes.Solid[0xFFFFFFFF]);
target.PopAxisAlignedClip();
if (mCaretVisible && mIsFocused)
{
target.DrawLine(new Vector2(mCaretOffset, 4), new Vector2(mCaretOffset, 23),
Brushes.Solid[0xFFFFFFFF], 2.0f);
}
target.Transform = transform;
}
示例6: DrawFpsSamples
private void DrawFpsSamples(RenderTarget target)
{
var maxValue = mFpsSamples.Max();
var minValue = mFpsSamples.Min();
if (MathUtil.WithinEpsilon(minValue, maxValue, 0.5f)) maxValue = minValue + 10;
var baseOffset = 0.0f;
var step = mSize.X / 19.0f;
var diff = (DateTime.Now - mLastFpsSample);
if (mFpsSamples.Count == 20)
baseOffset = (float)diff.TotalSeconds * step;
var curPos = mFpsRectangle.Left - baseOffset;
var endY = mFpsRectangle.Bottom - 5;
var height = mFpsRectangle.Height - 20;
target.PushAxisAlignedClip(mFpsRectangle, AntialiasMode.Aliased);
for (var i = 1; i < mFpsSamples.Count; ++i)
{
var sat = (mFpsSamples[i] - minValue) / (maxValue - minValue);
var satPrev = (mFpsSamples[i - 1] - minValue) / (maxValue - minValue);
target.DrawLine(new Vector2(curPos, endY - satPrev * height), new Vector2(curPos + step, endY - sat * height), Brushes.White);
curPos += step;
}
var satLast = (mFpsSamples.Last() - minValue) / (maxValue - minValue);
target.DrawLine(new Vector2(curPos, endY - satLast * height),
new Vector2(curPos + (float)diff.TotalSeconds * step, endY - satLast * height), Brushes.White);
target.PopAxisAlignedClip();
mFpsMin.Text = minValue.ToString("F2");
mFpsMax.Text = maxValue.ToString("F2");
target.DrawTextLayout(new Vector2(Position.X + 3.0f, mFpsRectangle.Top - 20.0f), mFpsMax, Brushes.White);
target.DrawTextLayout(new Vector2(Position.X + 3.0f, mFpsRectangle.Bottom + 2.0f), mFpsMin, Brushes.White);
}
示例7: DrawMemorySamples
private void DrawMemorySamples(RenderTarget target)
{
var maxValue = mMemorySamples.Max();
var minValue = mMemorySamples.Min();
if (minValue == maxValue) maxValue = minValue + 50;
var baseOffset = 0.0f;
var step = mSize.X / 19.0f;
var diff = (DateTime.Now - mLastMemorySample);
if (mMemorySamples.Count == 20)
baseOffset = ((float)diff.TotalSeconds / 0.5f) * step;
var curPos = mMemoryRectangle.Left - baseOffset;
var endY = mMemoryRectangle.Bottom - 5;
var height = mMemoryRectangle.Height - 20;
target.PushAxisAlignedClip(mMemoryRectangle, AntialiasMode.Aliased);
for (var i = 1; i < mMemorySamples.Count; ++i)
{
var sat = (mMemorySamples[i] - (float)minValue) / (maxValue - minValue);
var satPrev = (mMemorySamples[i - 1] - (float)minValue) / (maxValue - minValue);
target.DrawLine(new Vector2(curPos, endY - satPrev * height), new Vector2(curPos + step, endY - sat * height), Brushes.White);
curPos += step;
}
var satLast = (mMemorySamples.Last() - (float) minValue) / (maxValue - minValue);
target.DrawLine(new Vector2(curPos, endY - satLast * height),
new Vector2(curPos + ((float)diff.TotalSeconds / 0.5f) * step, endY - satLast * height), Brushes.White);
target.PopAxisAlignedClip();
DrawMemoryStrings(target, maxValue, minValue);
}
示例8: 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 )
{
// if the brush is dirty renew it
if ( m_isLineColorBrushDirty ) {
// 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;
}
if (m_useDefaultColor || m_lineColorBrush == null)
{
renderTarget.DrawLine(m_pStart, m_pEnd, brush, m_lineWidth);
}
else
{
// draw
renderTarget.DrawLine(m_pStart, m_pEnd, m_lineColorBrush, m_lineWidth);
}
}
示例9: Draw
public virtual void Draw(RenderTarget g)
{
//Texture draw call
if (Texture != null)
{
DrawingPositionRect = new RectangleF(X - Game.VIEWPORT.X, Y - Game.VIEWPORT.Y, Width, Height);
Texture.DrawTexture(g, new RectangleF(X, Y, Width, Height));
}
//Debug drawing options
if (Config.DEBUG_MODE == DebugMode.DISPLAY_HITBOX)
{
g.DrawRectangle(new RectangleF(Hitbox.X, Hitbox.Y, Hitbox.Width, Hitbox.Height), Resources.SCBRUSH_RED);
}
else if (Config.DEBUG_MODE == DebugMode.DISPLAY_RECT)
{
g.DrawRectangle(new RectangleF(X, Y, Width, Height), Resources.SCBRUSH_RED);
g.DrawLine(new Vector2(X, Y), new Vector2(X + Width, Y + Height), Resources.SCBRUSH_RED);
g.DrawLine(new Vector2(X, Y + Height), new Vector2(X + Width, Y), Resources.SCBRUSH_RED);
}
/* Used for debug purposes
if (drawHitbox)
g.DrawRectangle(Hitbox, Resources.SCBRUSH_BLACK, 3f);
*/
}