Re: Fill inside Polygon ???

From: Mike D Sutton (EDais_at_mvps.org)
Date: 04/04/04


Date: Sun, 4 Apr 2004 18:24:04 +0100


> I want to fill inside Arrow

Use the Polygon() API call rather than drawing lines and filling the inside, this is also a lot quicker so you'll notice a
considerable performance increase if drawing many shapes.

'***
Private Declare Function Polygon Lib "GDI32.dll" ( _
    ByVal hDC As Long, ByRef lpPoint As PointAPI, _
    ByVal nCount As Long) As Long

Private Type PointAPI
    X As Long
    Y As Long
End Type

Private Sub Command1_Click()
    Dim ArrowPts(3) As PointAPI

    ArrowPts(0).X = 20
    ArrowPts(0).Y = 20
    ArrowPts(1).X = 280
    ArrowPts(1).Y = 30
    ArrowPts(2).X = 90
    ArrowPts(2).Y = 90
    ArrowPts(3).X = 100
    ArrowPts(3).Y = 50

    Picture1.FillStyle = 2
    Picture1.FillColor = vbRed
    Picture1.ForeColor = vbGreen

    Call Polygon(Picture1.hDC, ArrowPts(0), 4)
End Sub
'***

> But how to do it and is that possible to change scale of hatch.

You can't change the scales of the default hatch styles, however you can create your own hatch pattern brush and fill your shape
with that.
Here's an old post with an example of creating your own hatch pattern brush:
http://groups.google.co.uk/groups?selm=ud3j%23aVCEHA.2908%40TK2MSFTNGP09.phx.gbl
Hope this helps,

    Mike

 - Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: http://www.mvps.org/EDais/



Relevant Pages

  • Re: Some help with System.Drawing Part 1.
    ... Drawing a polygon is simple because the outline of the polygon is used to create a scan-line map of the pixels and then the whole shape can be copied line by line into the graphics buffer. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... A GraphicsPath cannot be filled, this is the fastest operation, if it's not ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Rendering grid of cubes. Ray casting?
    ... Painter's algorithm, which can be vastly simplified for terrain. ... Picture the eye point and the grid looking down from the +z-axis. ... It sounds like you are interested in a line drawing, ... Maintain a 2d limb polygon L, ...
    (comp.graphics.algorithms)
  • RE: How to get from a Shape object to a GeometryDrawing (WPF)
    ... I am expecting the ImageControl to scale the drawing. ... I am trying to develop a WPF application which should show a Polygon Shape ... Geometry polygonGeometry = polygon.RenderedGeometry; ...
    (microsoft.public.dotnet.framework)
  • Re: DrawIndexedPrimitive confusion
    ... > MinIndex and BaseVertexIndex define the range of vertices the indices ... So if you're drawing a strip with indices 3,4,5,8 their most ... This would only draw the first polygon, ...
    (microsoft.public.win32.programmer.directx.graphics)