poly = GD::Polygon.new
poly = GD::Polygon.new poly.addPt(100,50) poly.addPt(50,100) poly.addPt(150,100)
poly = GD::Polygon.new poly.addPt(100,50) poly.toPt(-50,50) poly.toPt(100,0)
poly = GD::Polygon.new poly.addPt(100,50) poly.addPt(50,100) poly.addPt(150,100) x, y = poly.getPt(0) STDERR.print "Point 0 x: ", x, " y: ", y, "\n" x, y = poly.getPt(1) STDERR.print "Point 1 x: ", x, " y: ", y, "\n" x, y = poly.getPt(2) STDERR.print "Point 2 x: ", x, " y: ", y, "\n" im.polygon(poly, blue)
Point 0 x: 100 y: 50 Point 1 x: 50 y: 100 Point 2 x: 150 y: 100
poly = GD::Polygon.new poly.addPt(100,50) poly.addPt(50,100) poly.addPt(100,150) poly.setPt(2, 150,100) im.polygon(poly, blue)
poly = GD::Polygon.new poly.addPt(100,50) poly.addPt(50,100) poly.addPt(100,150) poly.addPt(150,100) poly.deletePt(3) im.polygon(poly, blue)
poly = GD::Polygon.new poly.addPt(100,50) poly.addPt(50,100) poly.addPt(150,100) STDERR.print "length: ", poly.length, "\n" im.polygon(poly, blue)
length: 3
poly = GD::Polygon.new poly.addPt(100,50) poly.addPt(50,100) poly.addPt(150,100) im.polygon(poly, blue) xs = poly.vertices for i in xs STDERR.print "(", i[0], " , ", i[1], ")", "\n" end
(100 , 50) (50 , 100) (150 , 100)
poly = GD::Polygon.new poly.addPt(100,50) poly.addPt(50,100) x1, y1, x2, y2 = poly.bounds STDERR.print "x1: ", x1, " y1: ", y1, " x2: ", x2, " y2: ", y2, "\n" poly.addPt(150,100) x1, y1, x2, y2 = poly.bounds STDERR.print "x1: ", x1, " y1: ", y1, " x2: ", x2, " y2: ", y2, "\n" im.polygon(poly, blue)
x1: 50 y1: 50 x2: 100 y2: 100 x1: 50 y1: 50 x2: 150 y2: 100
poly = GD::Polygon.new poly.addPt(100,50) poly.addPt(50,100) poly.addPt(150,100) im.polygon(poly, blue) poly.offset(25, 75) im.polygon(poly, blue)
poly = GD::Polygon.new poly.addPt(100,50) poly.addPt(50,100) poly.addPt(150,100) im.polygon(poly, blue) poly.map(50, 50, 150, 100, 75, 100, 125, 150) im.polygon(poly, red)
poly = GD::Polygon.new poly.addPt(100,50) poly.addPt(50,100) poly.addPt(150,100) im.polygon(poly, blue) poly.scale(0.5, 0.5) im.polygon(poly, red)
poly = GD::Polygon.new poly.addPt(100,50) poly.addPt(50,100) poly.addPt(150,100) im.polygon(poly, blue) # scale poly.transform(0.5,0,0,0.5,0,0) im.polygon(poly, red) poly.transform(2,0,0,2,30,50) im.polygon(poly, green)