本文整理汇总了C#中OxyPlot.OxyColor类的典型用法代码示例。如果您正苦于以下问题:C# OxyColor类的具体用法?C# OxyColor怎么用?C# OxyColor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OxyColor类属于OxyPlot命名空间,在下文中一共展示了OxyColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderRect
public void RenderRect(OxyRect bounds, OxyColor fill, OxyColor borderColor, double borderThickness)
{
var border = new[]
{
new ScreenPoint(bounds.Left, bounds.Top), new ScreenPoint(bounds.Right, bounds.Top),
new ScreenPoint(bounds.Right, bounds.Bottom), new ScreenPoint(bounds.Left, bounds.Bottom),
new ScreenPoint(bounds.Left, bounds.Top)
};
rc.DrawPolygon(border, fill, borderColor, borderThickness, null, true);
}
示例2: DrawEllipse
/// <summary>
/// Draws an ellipse.
/// </summary>
/// <param name="rect">The rectangle.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The thickness.</param>
public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
var isStroked = stroke.IsVisible() && thickness > 0;
if (fill.IsVisible())
{
if (!isStroked)
{
this.g.SmoothingMode = SmoothingMode.HighQuality;
}
this.g.FillEllipse(this.GetCachedBrush(fill), (float)rect.Left, (float)rect.Top, (float)rect.Width, (float)rect.Height);
}
if (!isStroked)
{
return;
}
using (var pen = this.GetCachedPen(stroke, thickness))
{
this.g.SmoothingMode = SmoothingMode.HighQuality;
this.g.DrawEllipse(pen, (float)rect.Left, (float)rect.Top, (float)rect.Width, (float)rect.Height);
}
}
示例3: Encode
/// <summary>
/// Encodes the specified image data to png.
/// </summary>
/// <param name="pixels">
/// The pixel data (bottom line first).
/// </param>
/// <param name="dpi">
/// The image resolution in dots per inch.
/// </param>
/// <returns>
/// The png image data.
/// </returns>
public static byte[] Encode(OxyColor[,] pixels, int dpi = 96)
{
int height = pixels.GetLength(0);
int width = pixels.GetLength(1);
var bytes = new byte[(width * height * 4) + height];
int k = 0;
for (int i = height - 1; i >= 0; i--)
{
bytes[k++] = 0; // Filter
for (int j = 0; j < width; j++)
{
bytes[k++] = pixels[i, j].R;
bytes[k++] = pixels[i, j].G;
bytes[k++] = pixels[i, j].B;
bytes[k++] = pixels[i, j].A;
}
}
var w = new MemoryWriter();
w.Write((byte)0x89);
w.Write("PNG\r\n\x1a\n".ToCharArray());
WriteChunk(w, "IHDR", CreateHeaderData(width, height));
WriteChunk(w, "pHYs", CreatePhysicalDimensionsData(dpi, dpi));
WriteChunk(w, "IDAT", CreateUncompressedBlocks(bytes));
WriteChunk(w, "IEND", new byte[0]);
return w.ToArray();
}
示例4: AddSeries
public void AddSeries(IEnumerable<double> x, IEnumerable<double> y, string title, OxyColor fill)
{
var series = new ScatterSeries
{
MarkerFill = fill,
MarkerSize = 2,
MarkerStrokeThickness = 0,
MarkerType = MarkerType.Diamond,
Title = title
};
double[] xPoints = x as double[] ?? x.ToArray();
double[] yPoints = y as double[] ?? y.ToArray();
if (xPoints.Length != yPoints.Length)
throw new Exception("The two data arrays must be of equal length.");
for (int i = 0; i < xPoints.Length; i++)
{
var point = new ScatterPoint(xPoints[i], yPoints[i]);
series.Points.Add(point);
}
Model.Series.Add(series);
}
示例5: DrawEllipses
/// <summary>
/// Draws the collection of ellipses, where all have the same stroke and fill.
/// This performs better than calling DrawEllipse multiple times.
/// </summary>
/// <param name="rectangles">The rectangles.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The stroke thickness.</param>
public virtual void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyColor stroke, double thickness)
{
foreach (var r in rectangles)
{
this.DrawEllipse(r, fill, stroke, thickness);
}
}
示例6: GraphComponents
public GraphComponents(OxyColor color)
{
scatters = new ScatterSeries
{
BinSize = 8,
MarkerFill = color,
MarkerSize = 2.0,
MarkerStroke = color,
MarkerStrokeThickness = 1.0,
MarkerType = MarkerType.Circle
};
lines = new LineSeries
{
Color = color,
LineStyle = LineStyle.Solid,
StrokeThickness = 1.0,
Smooth = true
};
stems = new StemSeries
{
Color = color,
StrokeThickness = 1.0,
};
}
示例7: DrawEllipse
/// <summary>
/// Draws an ellipse.
/// </summary>
/// <param name="rect">The rectangle.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The thickness.</param>
public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
var isStroked = stroke.IsVisible() && thickness > 0;
var isFilled = fill.IsVisible();
if (!isStroked && !isFilled)
{
return;
}
double y = this.doc.PageHeight - rect.Bottom;
if (isStroked)
{
this.SetLineWidth(thickness);
this.doc.SetColor(stroke);
if (isFilled)
{
this.doc.SetFillColor(fill);
this.doc.DrawEllipse(rect.Left, y, rect.Width, rect.Height, true);
}
else
{
this.doc.DrawEllipse(rect.Left, y, rect.Width, rect.Height);
}
}
else
{
this.doc.SetFillColor(fill);
this.doc.FillEllipse(rect.Left, y, rect.Width, rect.Height);
}
}
示例8: DrawLine
/// <summary>
/// Draws a polyline.
/// </summary>
/// <param name="points">The points.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The stroke thickness.</param>
/// <param name="dashArray">The dash array.</param>
/// <param name="lineJoin">The line join type.</param>
/// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
public abstract void DrawLine(
IList<ScreenPoint> points,
OxyColor stroke,
double thickness,
double[] dashArray,
OxyPenLineJoin lineJoin,
bool aliased);
示例9: ScatterSeries
/// <summary>
/// Initializes a new instance of the <see cref="ScatterSeries"/> class.
/// </summary>
/// <param name="title">
/// The title.
/// </param>
/// <param name="markerFill">
/// The marker fill color.
/// </param>
/// <param name="markerSize">
/// Size of the markers (If ScatterPoint.Size is set, this value will be overriden).
/// </param>
public ScatterSeries(string title, OxyColor markerFill = null, double markerSize = 5)
: this()
{
this.MarkerFill = markerFill;
this.MarkerSize = markerSize;
this.Title = title;
}
示例10: CandleStickSeries
/// <summary>
/// Initializes a new instance of the <see cref="CandleStickSeries"/> class.
/// </summary>
/// <param name="color">
/// The color.
/// </param>
/// <param name="strokeThickness">
/// The stroke thickness.
/// </param>
/// <param name="title">
/// The title.
/// </param>
public CandleStickSeries(OxyColor color, double strokeThickness = 1, string title = null)
: this()
{
this.Color = color;
this.StrokeThickness = strokeThickness;
this.Title = title;
}
示例11: DrawMathText
/// <summary>
/// Draws or measures text containing sub- and superscript.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="pt">The point.</param>
/// <param name="text">The text.</param>
/// <param name="textColor">Color of the text.</param>
/// <param name="fontFamily">The font family.</param>
/// <param name="fontSize">The font size.</param>
/// <param name="fontWeight">The font weight.</param>
/// <param name="angle">The angle.</param>
/// <param name="ha">The horizontal alignment.</param>
/// <param name="va">The vertical alignment.</param>
/// <param name="maxsize">The maximum size of the text.</param>
/// <param name="measure">Measure the size of the text if set to <c>true</c>.</param>
/// <returns>The size of the text.</returns>
/// <example>Subscript: H_{2}O
/// Superscript: E=mc^{2}
/// Both: A^{2}_{i,j}</example>
public static OxySize DrawMathText(
this IRenderContext rc,
ScreenPoint pt,
string text,
OxyColor textColor,
string fontFamily,
double fontSize,
double fontWeight,
double angle,
HorizontalAlignment ha,
VerticalAlignment va,
OxySize? maxsize,
bool measure)
{
if (string.IsNullOrEmpty(text))
{
return OxySize.Empty;
}
if (text.Contains("^{") || text.Contains("_{"))
{
double x = pt.X;
double y = pt.Y;
// Measure
var size = InternalDrawMathText(rc, x, y, text, textColor, fontFamily, fontSize, fontWeight, true, angle);
switch (ha)
{
case HorizontalAlignment.Right:
x -= size.Width;
break;
case HorizontalAlignment.Center:
x -= size.Width * 0.5;
break;
}
switch (va)
{
case VerticalAlignment.Bottom:
y -= size.Height;
break;
case VerticalAlignment.Middle:
y -= size.Height * 0.5;
break;
}
InternalDrawMathText(rc, x, y, text, textColor, fontFamily, fontSize, fontWeight, false, angle);
return measure ? size : OxySize.Empty;
}
rc.DrawText(pt, text, textColor, fontFamily, fontSize, fontWeight, angle, ha, va, maxsize);
if (measure)
{
return rc.MeasureText(text, fontFamily, fontSize, fontWeight);
}
return OxySize.Empty;
}
示例12: CreateRandomScatterSeriesWithColorAxisPlotModel
private static PlotModel CreateRandomScatterSeriesWithColorAxisPlotModel(int n, OxyPalette palette, MarkerType markerType, AxisPosition colorAxisPosition, OxyColor highColor, OxyColor lowColor)
{
var model = new PlotModel { Title = string.Format("ScatterSeries (n={0})", n), Background = OxyColors.LightGray };
var colorAxis = new LinearColorAxis { Position = colorAxisPosition, Palette = palette, Minimum = -1, Maximum = 1, HighColor = highColor, LowColor = lowColor };
model.Axes.Add(colorAxis);
model.Series.Add(CreateRandomScatterSeries(n, markerType, false, true, colorAxis));
return model;
}
示例13: DrawLine
/// <summary>
/// Draws a polyline.
/// </summary>
/// <param name="points">The points.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The stroke thickness (in device independent units, 1/96 inch).</param>
/// <param name="dashArray">The dash array (in device independent units, 1/96 inch). Use <c>null</c> to get a solid line.</param>
/// <param name="lineJoin">The line join type.</param>
/// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
public void DrawLine(
IList<ScreenPoint> points,
OxyColor stroke,
double thickness = 1,
double[] dashArray = null,
LineJoin lineJoin = LineJoin.Miter,
bool aliased = false)
{
}
示例14: DrawLine
/// <summary>
/// Draws a polyline.
/// </summary>
/// <param name="points">The points.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The stroke thickness.</param>
/// <param name="dashArray">The dash array.</param>
/// <param name="lineJoin">The line join type.</param>
/// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
public override void DrawLine(
IList<ScreenPoint> points,
OxyColor stroke,
double thickness,
double[] dashArray,
OxyPenLineJoin lineJoin,
bool aliased)
{
var xckdPoints = this.Distort(points);
this.rc.DrawLine(xckdPoints, stroke, thickness * this.ThicknessScale, dashArray, lineJoin);
}
示例15: OxyPen
/// <summary>
/// Initializes a new instance of the <see cref="OxyPen"/> class.
/// </summary>
/// <param name="color">
/// The color.
/// </param>
/// <param name="thickness">
/// The thickness.
/// </param>
/// <param name="lineStyle">
/// The line style.
/// </param>
/// <param name="lineJoin">
/// The line join.
/// </param>
public OxyPen(
OxyColor color,
double thickness = 1.0,
LineStyle lineStyle = LineStyle.Solid,
OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter)
{
this.Color = color;
this.Thickness = thickness;
this.DashArray = LineStyleHelper.GetDashArray(lineStyle);
this.LineStyle = lineStyle;
this.LineJoin = lineJoin;
}