Draw a Diamond Shape with Graphic DrawPolygon for icon

Hello

I;m trying to draw a diamond shape with Graphics.DrawPolygon in an older version of Xojo that supports DrawPolygon. Then convert it to an icon for a dropdown menu with icons in a Bevel Button(This code is not shown). Using close to example 1.5 from Eugene Dankin Canvas Book. I’m not getting result I desire from the code example.

  Dim PBuffer As Picture
  Dim PIcon As Picture
  Dim p(8) As Integer
  p(1) = 12 'x1
  p(2) = 2  'y1
  p(3) = 12 'x2
  p(4) = 24 'y2
  p(5) = 12 'x3
  p(6) = 36 'y3
  p(7) = 2  'x 4
  p(8) = 12 'y4
  
  PBuffer.Graphics.PenHeight = 2
  PBuffer.Graphics.PenWidth = 2
  PBuffer.Graphics.DrawPolygon(p)
  PIcon = PBuffer
1 Like

the first 3 sets of x and y draw a straight line from x,y 12,2 to 12,36

edit

Dim PBuffer As New picture(80,80)
Dim PIcon As Picture
Dim p(8) As Integer
p(1) = 12 'x1
p(2) = 0 'y1
p(3) = 0 'x2
p(4) = 12 'y2
p(5) = 12 'x3
p(6) = 24 'y3
p(7) = 24  'x 4
p(8) = 12 'y4

PBuffer.Graphics.ForeColor = &cff0000
PBuffer.Graphics.PenHeight = 2
PBuffer.Graphics.PenWidth = 2
PBuffer.Graphics.DrawPolygon(p)
PIcon = PBuffer
1 Like

So I left out the ForeColor for the pen lines and my x y number were off. It worked perfect thanks Norman.

Just trying to help out
You’re welcome

And you forgot the new.

And you thanked yourself for the answer :-1:

Then maybe you should mark HIS answer as answer and not YOURS? :roll_eyes:

Sorry, This my first post on this new Forum layout and haven’t been on here in a while. I corrected the solution. Thanks