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)
im.filledRectangle(10, 10, 50, 50, blue) STDERR.print im.getPixel(1, 1), "\n" STDERR.print im.getPixel(30, 30), "\n"
0 4
def print_rgb(rgb) STDERR.printf "red: %3d green: %3d blue: %3d\n", rgb[0], rgb[1], rgb[2] end white = im.colorAllocate(255,255,255) black = im.colorAllocate(0,0,0) yellow = im.colorAllocate(255,250,205) rgb = im.rgb(white) print_rgb(rgb) rgb = im.rgb(black) print_rgb(rgb) rgb = im.rgb(yellow) print_rgb(rgb)
red: 255 green: 255 blue: 255 red: 0 green: 0 blue: 0 red: 255 green: 250 blue: 205
im.transparent(white) im.filledRectangle(10, 10, 50, 50, blue)
brush = GD::Image.new(10,10) brush.colorAllocate(255, 255, 255) # white brush.colorAllocate(0, 0, 0) # black brush.transparent(white) # white is transparent brush.filledRectangle(0,0,5,2,black) # a black rectangle im.setBrush(brush) im.arc(100, 100, 100, 50, 0, 360, GD::Brushed)
file = open("setbrush_gif.gif", "rb") brush = GD::Image.newFromGif(file) file.close im.setBrush(brush) im.arc(100, 100, 100, 50, 0, 360, GD::Brushed)
im.setStyle(red, red, red, white, white, white) im.line(10, 10, 50, 10, GD::Styled)
# for Brushed brush = GD::Image.new(10,10) brush.colorAllocate(255, 255, 255) # white brush.colorAllocate(0, 0, 0) # black brush.transparent(white) # white is transparent brush.filledRectangle(0,0,5,2,black) # a black rectangle im.setBrush(brush) # for Styled im.setStyle(red, red, red, white, white, white)
file = open("settile_gif.gif", "rb") tile = GD::Image.newFromGif(file) file.close im.setTile(tile) im.filledRectangle(50, 50, 150, 150, GD::Tiled)