0

我有一组在 Visual Basic 中创建的需要着色的形状:

Public Class Form1

Private Sub btnDraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDraw.Click
    Dim formSurface As Graphics = Me.CreateGraphics 'creates surface

    Dim world As New Pen(Color.Black, 3)
    formSurface.DrawRectangle(world, 250, 50, 300, 300) 'world


    Dim roof As New Pen(Color.Black, 3)
    Dim roof1 As New Point(325, 200)
    Dim roof2 As New Point(475, 200)
    Dim roof3 As New Point(400, 100)
    Dim roof4 As New Point(400, 100)
    Dim curvePoints As Point() = {roof1, roof2, roof3, roof4}
    formSurface.DrawPolygon(roof, curvePoints) 'triangle roof

    Dim body As New Pen(Color.Black, 3)
    formSurface.DrawRectangle(body, 325, 200, 150, 150) 'square body

    Dim sun As New Pen(Color.Black, 3)
    formSurface.DrawEllipse(sun, 450, 75, 50, 50) 'sun

    Dim door As New Pen(Color.Black, 3)
    formSurface.DrawRectangle(door, 387, 300, 25, 50) 'door

End Sub

结束类

一切正常;形状都是在我想要的地方生成的。(我正在尝试画一座房子)但是,我该如何给它们上色呢?另外,如果我这样做,颜色会重叠吗(我希望发生这种情况)?

我应该使用一些功能image.fill吗?我知道这是不对的,但我正在寻找类似的东西。

谢谢!

4

1 回答 1

1

您想使用 formSurface.FillPolygon、FillRectangle 和 FillEllipse 命令。您仍然可以使用“绘图”命令创建与填充颜色不同的轮廓。

“填充”命令需要画笔而不是钢笔。(笔画线,刷子填充空间。)最简单的刷子类型就像“Brushes.AliceBlue”。

于 2012-07-23T22:19:26.427 回答