16

ac#windowsアプリケーションを作成し、コードの75%を記述しました。このプログラムを使用すると、ユーザーはフローチャートを作成でき、ステータスに応じてフローチャートの形状に陰影を付けることができます。ジェルボタン ウェブサイトWebdesign.orgなどの3Dボタンにしたかった

ボタンごとにPNGを作成するのではなく、ブラシまたは次のような他の手法を使用してC#で作成したいと思いました。

// Create solid brush.
SolidBrush blueBrush = new SolidBrush(Color.Blue);
// Create points that define polygon.
PointF point1 = new PointF(50.0F, 50.0F);
PointF point2 = new PointF(100.0F, 25.0F);
PointF point3 = new PointF(200.0F, 5.0F);
PointF point4 = new PointF(250.0F, 50.0F);
PointF point5 = new PointF(300.0F, 100.0F);
PointF point6 = new PointF(350.0F, 200.0F);
PointF point7 = new PointF(250.0F, 250.0F);
PointF[] curvePoints = {point1, point2, point3, point4, point5, point6, point7};
// Define fill mode.
FillMode newFillMode = FillMode.Winding;
// Fill polygon to screen.
e.Graphics.FillPolygon(blueBrush, curvePoints, newFillMode);

WPFには放射状のグラデーションがあることは知っていますが、CGIで同様のことを行うことはできますか?

4

2 に答える 2

26

WPFとは異なり、GDI +/WinFormsには。がありませんRadialGradientBrush。ただし、を使用して同じ効果を得ることができますPathGradientBrush

次に例を示します。

Rectangle bounds = ...;
using (var ellipsePath = new GraphicsPath())
{
    ellipsePath.AddEllipse(bounds);
    using (var brush = new PathGradientBrush(ellipsePath))
    {
        brush.CenterPoint = new PointF(bounds.Width/2f, bounds.Height/2f);
        brush.CenterColor = Color.White;
        brush.SurroundColors = new[] { Color.Red };
        brush.FocusScales = new PointF(0, 0);

        e.Graphics.FillRectangle(brush, bounds);
    }
}

にはPathGradientBrush、目的の効果を確実に得るために実験するプロパティがたくさんあります。

于 2012-11-29T10:30:52.897 に答える
13

このCodeprojectの記事を見てから、パスのグラデーションを見てください。

于 2010-08-19T08:20:54.007 に答える