【问题标题】:Overlapping Lines on WPF canvas blending colors - how to fix?WPF画布混合颜色上的重叠线 - 如何修复?
【发布时间】:2016-02-05 16:42:57
【问题描述】:

如果我画一条线(假设 ls 只是一条带有一些坐标的线段)。 . .

Line line = new Line();
String rgb = "#FF0000";  // Red
line.Stroke = (SolidColorBrush)(new BrushConverter().ConvertFrom(rgb));
ls = PlyList[p].L3Ds[seg];
line.X1 = ls.P0.X;
line.Y1 = ls.P0.Y;
line.X2 = ls.P1.X;
line.Y2 = ls.P1.Y;
GeometryCnv.Children.Add(line);

...我得到一条红线。如果我做 。 . .

Line line = new Line();
String rgb = "#00FF00";  // Green
line.Stroke = (SolidColorBrush)(new BrushConverter().ConvertFrom(rgb));
ls = PlyList[p].L3Ds[seg];
line.X1 = ls.P0.X;
line.Y1 = ls.P0.Y;
line.X2 = ls.P1.X;
line.Y2 = ls.P1.Y;
GeometryCnv.Children.Add(line);

...我得到一条绿线。
但是如果我同时做这两个(使用相同的坐标),我会得到棕橙色,就好像两条线的颜色是混合的,就好像这些线有某种透明度一样。我想要做的是让最近的线条覆盖前一条线条,以便生成的颜色是最近的颜色 - 在这种情况下为绿色。

我需要做什么才能实现这一目标?

【问题讨论】:

    标签: wpf canvas colors


    【解决方案1】:

    尝试在 GeometryCnv. 上将 SnapsToDevicePixels 设置为 true 两条线的别名会导致您看到的效果。

    【讨论】:

    • 好电话,成功了!
    猜你喜欢
    • 2022-07-28
    • 2014-10-04
    • 1970-01-01
    • 1970-01-01
    • 2014-06-08
    • 2015-10-07
    • 2016-08-11
    • 2011-07-04
    • 1970-01-01
    相关资源
    最近更新 更多