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)
white = im.colorAllocate("#FFFFFF") black = im.colorAllocate("#000000") red = im.colorAllocate("#FF0000") green = im.colorAllocate("#00FF00") blue = im.colorAllocate("#0000FF") yellow = im.colorAllocate("#FFFACD")
white = im.colorAllocate(255,255,255) black = im.colorAllocate(0,0,0) red = im.colorAllocate(255,0,0) STDERR.print red, "\n" green = im.colorAllocate(0,255,0) blue = im.colorAllocate(0,0,255) yellow = im.colorAllocate(255,250,205) im.colorDeallocate(red) color = im.colorAllocate(238,130,238) STDERR.print color, "\n"
2 2
STDERR.print im.colorsTotal, "\n" white = im.colorAllocate(255,255,255) STDERR.print im.colorsTotal, "\n" black = im.colorAllocate(0,0,0) STDERR.print im.colorsTotal, "\n" red = im.colorAllocate(255,0,0) STDERR.print im.colorsTotal, "\n" green = im.colorAllocate(0,255,0) STDERR.print im.colorsTotal, "\n" blue = im.colorAllocate(0,0,255) STDERR.print im.colorsTotal, "\n"
0 1 2 3 4 5
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
def print_rgb(im, color) STDERR.printf "red: %3d green: %3d blue: %3d\n", im.red(color), im.green(color), im.blue(color) end 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) print_rgb(im, white) print_rgb(im, black) print_rgb(im, red) print_rgb(im, green) print_rgb(im, blue)
red: 255 green: 255 blue: 255 red: 0 green: 0 blue: 0 red: 255 green: 0 blue: 0 red: 0 green: 255 blue: 0 red: 0 green: 0 blue: 255
im.transparent(white) im.filledRectangle(10, 10, 50, 50, blue)
im = GD::Image.new(200, 200) white = im.colorAllocate(255,255,255) STDERR.print im.getTransparent, "\n" im.transparent(white) STDERR.print im.getTransparent, "\n"
-1 0?
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_png.png", "rb") brush = GD::Image.newFromPng(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_png.png", "rb") tile = GD::Image.newFromPng(file) file.close im.setTile(tile) im.filledRectangle(50, 50, 150, 150, GD::Tiled)