0

オブジェクトの重複部分が別のブラシでペイントされるように、2 つの形状オブジェクトが互いに重複する場合に WPF に方法はありますか?

4

1 に答える 1

3

それを解決しました。

塗りつぶし規則が EvenOdd の GeometryGroup を含むジオメトリ図面を使用できます。これにより、重なっているアイテムが白で塗りつぶされます。次に、GeometryCombineMode が Intersect の Geometry グループと同じオブジェクトを含む CombinedGeometry で別の画像を上に配置すると、カスタム ブラシで交差が強調表示されます。サンプルコードは次のとおりです。

    <Grid>
    <Image Stretch="None">
        <Image.Source>
            <DrawingImage>
                <DrawingImage.Drawing>
                    <GeometryDrawing Brush="Red">
                        <GeometryDrawing.Pen>
                            <Pen Brush="Black" Thickness="3" />
                        </GeometryDrawing.Pen>
                        <GeometryDrawing.Geometry>
                            <GeometryGroup FillRule="EvenOdd">
                                <EllipseGeometry RadiusX="80" RadiusY="80" Center="0,0" />
                                <EllipseGeometry RadiusX="80" RadiusY="80" Center="40,0" />
                            </GeometryGroup>
                        </GeometryDrawing.Geometry>
                    </GeometryDrawing>
                </DrawingImage.Drawing>
            </DrawingImage>
        </Image.Source>
    </Image>
    <Image HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Stretch="None">
        <Image.Source>
            <DrawingImage>
                <DrawingImage.Drawing>
                    <GeometryDrawing Brush="LightBlue">
                        <GeometryDrawing.Geometry>
                            <CombinedGeometry GeometryCombineMode="Intersect">
                                <CombinedGeometry.Geometry1>
                                    <EllipseGeometry RadiusX="80" RadiusY="80" Center="0,0" />
                                </CombinedGeometry.Geometry1>
                                <CombinedGeometry.Geometry2>
                                    <EllipseGeometry RadiusX="80" RadiusY="80" Center="40,0" />
                                </CombinedGeometry.Geometry2>
                            </CombinedGeometry>
                        </GeometryDrawing.Geometry>
                    </GeometryDrawing>
                </DrawingImage.Drawing>
            </DrawingImage>
        </Image.Source>
    </Image>
</Grid>

ありがとう!

于 2009-08-18T13:19:32.773 に答える