Sample 3 - Drawing polygons

Drawing Polygons

polygon.vbs


Dim im
Dim coords(100)
Set im = CreateObject("ActiveImage.Images.1")
im.CreateImage 300,300
im.SetColor 255,255,255
im.Fill 0,0
im.SetColor 194,194,194
im.DrawRectangle 288,288,298,298

im.SetLineThickness 1

coords(0) = 122
coords(1) = 4
coords(2) = 157
coords(3) = 174
coords(4) = 205
coords(5) = 206
coords(6) = 295
coords(7) = 189
coords(8) = 294
coords(9) = 178
coords(10) = 205
coords(11) = 195
coords(12) = 167
coords(13) = 170
coords(14) = 133
coords(15) = 3


im.DrawPolygon coords, 16

x = -100
y = 30

For i = 0 to 15 step 2
coords(i) = coords(i) + x
coords(i+1) = coords(i+1) + y
next

im.DrawFilledPolygon coords, 16

im.SetColor 0,0,0

im.SetFont 4
im.DrawTextAngle 126,10, 77, "19 Street"
im.DrawTextAngle 126+x,10 + y, 77, "19 Street"

im.SetFont 2
im.DrawTextAngle 209,193, -13, "19 Street"
im.DrawTextAngle 209+x,193 + y, -13, "19 Street"


im.WriteToFile "C:\polygon.png"
im.SetImageType 1
im.SetJpegQuality 100
im.WriteToFile "C:\polygon.jpg"
im.DestroyImage
Set im = Nothing


polygon.jpg polygon.png
Picture 1. polygon.jpg (size - 16 Kb) Picture 2. polygon.png (size - 3.1 Kb)

If you have any questions or bug reports, write to active.image@tonec.com for technical support.