#!/usr/local/bin/ruby # # ./polygon_length.rb > polygon_length.gif require "GD" # create a new image im = GD::Image.new(200, 200) # allocate some colors white = im.colorAllocate(255,255,255) black = im.colorAllocate(0,0,0) red = im.colorAllocate(255,0,0) green = im.colorAllocate(0,255,0) blue = im.colorAllocate(0,0,255) yellow = im.colorAllocate(255,250,205) 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) im.gif STDOUT