#!/usr/local/bin/ruby # # ./polygon_map.rb > polygon_map.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) im.polygon(poly, blue) poly.map(50, 50, 150, 100, 75, 100, 125, 150) im.polygon(poly, red) im.gif STDOUT