本文整理汇总了C#中RenderTarget.FillRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTarget.FillRectangle方法的具体用法?C# RenderTarget.FillRectangle怎么用?C# RenderTarget.FillRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderTarget
的用法示例。
在下文中一共展示了RenderTarget.FillRectangle方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public void Render(RenderTarget target)
{
target.FillRectangle(KeyboardGradient, new RectangleF(0, KeyboardY, target.Size.Width, KEY_HEIGHT));
target.DrawLine(DefaultBrushes[1], 0, KeyboardY, target.Size.Width, KeyboardY, 1f);
for (int i = 0; i < 128; i++)
{
float keyX = i * KeyWidth;
if (IsBlack[i % 12])
{
if (KeyPressed[i] > 0)
{
target.FillRectangle(DefaultBrushes[4], new RectangleF(keyX, KeyboardY, KeyWidth, BLACK_KEY_HEIGHT));
}
else
{
target.FillRectangle(DefaultBrushes[2], new RectangleF(keyX, KeyboardY, KeyWidth, BLACK_KEY_HEIGHT));
target.FillRectangle(DefaultBrushes[1], new RectangleF(keyX, KeyboardY + BLACK_KEY_HEIGHT * 4f / 5, KeyWidth, BLACK_KEY_HEIGHT / 5f));
}
}
else
{
if (KeyPressed[i] > 0)
{
target.FillRectangle(DefaultBrushes[3], new RectangleF(keyX, KeyboardY, KeyWidth, KEY_HEIGHT));
if (IsBlack[(i + 1) % 12])
target.FillRectangle(DefaultBrushes[3], new RectangleF(keyX + KeyWidth, KeyboardY + BLACK_KEY_HEIGHT, KeyWidth / 2, KEY_HEIGHT - BLACK_KEY_HEIGHT));
if (IsBlack[(i + 11) % 12])
target.FillRectangle(DefaultBrushes[3], new RectangleF(keyX - KeyWidth / 2, KeyboardY + BLACK_KEY_HEIGHT, KeyWidth / 2, KEY_HEIGHT - BLACK_KEY_HEIGHT));
}
else
{
target.FillRectangle(DefaultBrushes[2], new RectangleF(keyX, KeyboardY + KEY_HEIGHT * 7f / 8, KeyWidth, KEY_HEIGHT / 8f));
if (IsBlack[(i + 1) % 12])
target.FillRectangle(DefaultBrushes[2], new RectangleF(keyX + KeyWidth, KeyboardY + KEY_HEIGHT * 7f / 8, KeyWidth, KEY_HEIGHT / 8f));
if (IsBlack[(i + 11) % 12])
target.FillRectangle(DefaultBrushes[2], new RectangleF(keyX - KeyWidth / 2, KeyboardY + KEY_HEIGHT * 7f / 8, KeyWidth, KEY_HEIGHT / 8f));
}
}
if (IsBlack[i % 12])
target.DrawLine(DefaultBrushes[1], keyX + KeyWidth / 2, KeyboardY + BLACK_KEY_HEIGHT, i * KeyWidth + KeyWidth / 2, target.Size.Height, 1f);
else if (!IsBlack[(i + 11) % 12])
target.DrawLine(DefaultBrushes[1], keyX, KeyboardY, keyX, target.Size.Height, 1f);
}
}
示例2: Draw
protected internal override void Draw(RenderTarget renderTarget)
{
if (_fill)
{
renderTarget.FillRectangle(_rect, _parent.brushes[_selectedBrushIndex]);
}
else
{
renderTarget.DrawRectangle(_rect, _parent.brushes[_selectedBrushIndex], _strokeWidth);
}
}
示例3: Render
public override void Render(RenderTarget target, List<Note> notes, MIDIKeyboard keyboard)
{
foreach (Note n in notes)
{
if (n.Key >= GFXResources.NoteOffset && n.Key < GFXResources.NoteOffset + GFXResources.NoteCount && n.Length > 0 && n.Velocity > 0)
{
// Calculate pitchbend offset to give notes a sliding effect
/* DISABLED FOR PERFORMANCE
float wheelOffset = (keyboard.Pitchwheel[n.Channel] - 8192) / 8192f * 2 * GFXResources.KeyWidth;
float bottom = n.Position + n.Length;
float left = n.Key * GFXResources.KeyWidth + (bottom >= GFXResources.KeyboardY ? wheelOffset : 0) - GFXResources.NoteOffset * GFXResources.KeyWidth;
*/
float left = n.Key * GFXResources.KeyWidth - GFXResources.NoteOffset * GFXResources.KeyWidth;
GFXResources.NoteRect.X = left;
GFXResources.NoteRect.Y = n.Position;
GFXResources.NoteRect.Width = GFXResources.KeyWidth;
GFXResources.NoteRect.Height = n.Length;
target.FillRectangle(GFXResources.ChannelBrushes[n.Channel], GFXResources.NoteRect);
}
}
}
示例4: Render
public override void Render(RenderTarget target, int[] KeyPressed)
{
target.FillRectangle(GFXResources.DefaultBrushes[0],
new RectangleF
(
0,
GFXResources.KeyboardY,
target.Size.Width,
GFXResources.KeyHeight
)
);
target.DrawLine(GFXResources.DefaultBrushes[1], 0, GFXResources.KeyboardY, target.Size.Width, GFXResources.KeyboardY, 1f);
for (int i = GFXResources.NoteOffset; i < GFXResources.NoteOffset + GFXResources.NoteCount; i++)
{
float keyX = i * GFXResources.KeyWidth - GFXResources.NoteOffset * GFXResources.KeyWidth;
if (GFXResources.IsBlack[i % 12])
{
if (KeyPressed[i] > 0) /* Black key which is pressed */
{
target.FillRectangle
(
// Fill the inside red
GFXResources.DefaultBrushes[4],
new RectangleF
(
keyX,
GFXResources.KeyboardY,
GFXResources.KeyWidth,
GFXResources.BlackKeyHeight
)
);
}
else /* Black key which is not pressed */
{
// Fill the top gray
target.FillRectangle
(
GFXResources.DefaultBrushes[2],
new RectangleF
(
keyX,
GFXResources.KeyboardY,
GFXResources.KeyWidth,
GFXResources.BlackKeyHeight
)
);
}
}
else
{
if (KeyPressed[i] > 0) /* White key which is pressed */
{
// Fill the middle white part red
target.FillRectangle
(
GFXResources.DefaultBrushes[3],
new RectangleF
(
keyX,
GFXResources.KeyboardY,
GFXResources.KeyWidth,
GFXResources.KeyHeight
)
);
if (GFXResources.IsBlack[(i + 1) % 12])
{
// Fill the next half section red if the next note is black
target.FillRectangle
(
GFXResources.DefaultBrushes[3],
new RectangleF
(
keyX + GFXResources.KeyWidth,
GFXResources.KeyboardY + GFXResources.BlackKeyHeight,
GFXResources.KeyWidth / 2,
GFXResources.KeyHeight - GFXResources.BlackKeyHeight
)
);
}
if (GFXResources.IsBlack[(i + 11) % 12])
{
// Fill the previous half section red if the previous note is black
target.FillRectangle
(
GFXResources.DefaultBrushes[3],
new RectangleF
(
keyX - GFXResources.KeyWidth / 2,
GFXResources.KeyboardY + GFXResources.BlackKeyHeight,
GFXResources.KeyWidth / 2,
GFXResources.KeyHeight - GFXResources.BlackKeyHeight
)
);
}
}
}
// Draw note separator lines
if (GFXResources.IsBlack[i % 12])
{
target.DrawLine
//.........这里部分代码省略.........
示例5: Render
/// <summary>
/// Renders rectangle represented by current instance to render target.
/// </summary>
/// <param name="renderTarget">The render target.</param>
public void Render(RenderTarget renderTarget)
{
if (this.stroke != null)
{
renderTarget.DrawRectangle(this.rectangle, this.stroke, this.thickness);
}
if (this.fill != null)
{
renderTarget.FillRectangle(this.rectangle, this.fill);
}
}
示例6: Paint
public void Paint(RenderTarget target)
{
target.BeginDraw();
target.Transform = Matrix3x2.Identity;
if (Fancy)
target.FillRectangle(BackgroundGradient, new RectangleF(PointF.Empty, target.Size));
else
target.Clear(Color.Black);
#region draw_notes
lock (notes)
{
foreach (Note n in notes)
{
float wheelOffset = (Keyboard.Pitchwheel[n.Channel] - 8192) / 8192f * 2 * KeyWidth;
float bottom = n.Position + n.Length;
float left = n.Key * KeyWidth + (bottom >= KeyboardY ? wheelOffset : 0);
if (Fancy)
{
NoteRoundRect.Left = left;
NoteRoundRect.Top = n.Position;
NoteRoundRect.Right = left + KeyWidth;
NoteRoundRect.Bottom = bottom;
float alpha = n.Velocity / 127f * (Keyboard.ChannelVolume[n.Channel] / 127f);
alpha *= alpha;
var gradientBrush = ChannelGradientBrushes[n.Channel];
gradientBrush.Opacity = alpha;
GradientPoint.X = NoteRoundRect.Left;
gradientBrush.StartPoint = GradientPoint;
GradientPoint.X = NoteRoundRect.Right;
gradientBrush.EndPoint = GradientPoint;
target.FillRoundedRectangle(ChannelGradientBrushes[n.Channel], NoteRoundRect);
}
else
{
NoteRect.X = left;
NoteRect.Y = n.Position;
NoteRect.Width = KeyWidth;
NoteRect.Height = n.Length;
target.FillRectangle(ChannelBrushes[n.Channel], NoteRect);
}
}
}
#endregion
Keyboard.Render(target);
// Draw time progress bar
if (sequence?.GetLength() > 0)
{
float percentComplete = 1f*sequencer.Position/sequence.GetLength();
target.FillRectangle(DefaultBrushes[5],
new RectangleF(ProgressBarBounds.X, ProgressBarBounds.Y, ProgressBarBounds.Width*percentComplete, ProgressBarBounds.Height));
target.DrawRectangle(DefaultBrushes[2], ProgressBarBounds, .8f);
}
string[] debug =
{
" file: " + MIDIFile,
"note_count: " + notes.Count,
" renderer: " + (Fancy ? "fancy" : UserFancy ? "forced-fast" : "fast"),
" note: " + (sequence == null ? "? / ?" : sequencer.Position + " / " + sequence.GetLength()),
" delay: " + Delay
};
string debugText = debug.Aggregate("", (current, ss) => current + ss + '\n');
target.DrawText(debugText, DebugFormat, DebugRectangle, DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);
if (Loading == 0)
target.DrawText("INITIALIZING MIDI DEVICES", HugeFormat, FullRectangle, DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);
else if (Loading > 0)
target.DrawText("LOADING " + Loading + "%", HugeFormat, FullRectangle, DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);
target.EndDraw();
}
示例7: Render
public void Render(RenderTarget target)
{
// Fill background depending on render mode
if (NoteManager.RenderFancy)
target.FillRectangle(GFXResources.BackgroundGradient, new RectangleF(PointF.Empty, target.Size));
else
target.Clear(Color.Black);
// Render notes and keyboard display
lock (NoteManager.Notes)
{
if (NoteManager.RenderFancy)
NoteRenderers[1].Render(target, NoteManager.Notes, Keyboard);
else
NoteRenderers[0].Render(target, NoteManager.Notes, Keyboard);
}
lock (Keyboard.KeyPressed)
{
if (NoteManager.RenderFancy)
KeyRenderers[1].Render(target, Keyboard.KeyPressed);
else
KeyRenderers[0].Render(target, Keyboard.KeyPressed);
}
// Draw time progress bar
if (sequence?.GetLength() > 0)
{
float percentComplete = 1f * sequencer.Position / sequence.GetLength();
target.FillRectangle(GFXResources.DefaultBrushes[5],
new RectangleF(GFXResources.ProgressBarBounds.X, GFXResources.ProgressBarBounds.Y, GFXResources.ProgressBarBounds.Width * percentComplete, GFXResources.ProgressBarBounds.Height));
target.DrawRectangle(GFXResources.DefaultBrushes[2], GFXResources.ProgressBarBounds, .8f);
}
// Render debug information
string[] debug;
string usage = Application.ProductName + " " + Application.ProductVersion + " (c) " + Application.CompanyName;
if (ShowDebug)
{
debug = new[]
{
usage,
" file: " + MIDIFile,
"note_count: " + NoteManager.Notes.Count,
" frames/s: " + (Kazedan.Elapsed == 0 ? "NaN" : 1000 / Kazedan.Elapsed + "") +" fps",
" renderer: " + (NoteManager.RenderFancy ? "fancy" : NoteManager.UserEnabledFancy ? "forced-fast" : "fast"),
" seq_tick: " + (sequence == null ? "? / ?" : sequencer.Position + " / " + sequence.GetLength()),
" delay: " + Delay+"ms",
" kbd: " + GFXResources.NoteCount + " key(s) +" + GFXResources.NoteOffset + " offset",
" stopped: " + Stopped
};
}
else
{
debug = new[] { usage };
}
string debugText = debug.Aggregate("", (current, ss) => current + ss + '\n');
target.DrawText(debugText, GFXResources.DebugFormat, GFXResources.DebugRectangle, GFXResources.DefaultBrushes[0], DrawTextOptions.None,
MeasuringMethod.Natural);
// Render large title text
if (Loading == 0)
target.DrawText("INITIALIZING MIDI DEVICES", GFXResources.HugeFormat, GFXResources.FullRectangle, GFXResources.DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);
else if (Loading > 0 && Loading < 100)
target.DrawText("LOADING " + Loading + "%", GFXResources.HugeFormat, GFXResources.FullRectangle, GFXResources.DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);
}