gpt4 book ai didi

c# - 带有画笔的 Oxyplot 注释

转载 作者:行者123 更新时间:2023-11-30 16:50:35 24 4
gpt4 key购买 nike

我想用比纯色更漂亮的东西为我的 OxyPlotRectangleAnnotation 着色,即某种类型的画笔 (GradientBrush 等)。我在 WPF 工作。

他们 GitHub 站点上的这个问题 ( PlotAreaBackground can be defined using gradient ? ) 建议可以为注释提供渐变,但我找不到建议的示例。

有没有一种方法可以将画笔应用于 RectangleAnnotation?或任何其他方式在图表上创建与轴上的值相关联的彩色区域?

最佳答案

我认为这是 suggested example .

我已将其修改为看起来像一个矩形注释,因为示例填满了整个背景。希望对您有所帮助。

效果:

enter image description here

代码:

// create a gradient image of height n
int n = 256;
var imageData1 = new OxyColor[n, 1];
for (int i = 0; i < n; i++)
{
imageData1[i, 0] = OxyColor.Interpolate(OxyColors.Red, OxyColors.Blue, i / (n - 1.0));
}

PngBitmapEncoder encoder = new PngBitmapEncoder();
PngEncoder encode = new PngEncoder(new PngEncoderOptions());
var image1 = new OxyImage(encode.Encode(imageData1));

ImageAnnotation anotation = new ImageAnnotation
{
ImageSource = image1,
Interpolate = true,
Layer = AnnotationLayer.BelowAxes,
X = new PlotLength(0.5, PlotLengthUnit.RelativeToPlotArea),
Y = new PlotLength(0.5, PlotLengthUnit.RelativeToPlotArea),
Width = new PlotLength(0.1, PlotLengthUnit.RelativeToPlotArea),
Height = new PlotLength(0.5, PlotLengthUnit.RelativeToPlotArea),
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Top
};
plotModel.Annotations.Add(anotation);

关于c# - 带有画笔的 Oxyplot 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34896421/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com