1require "gd" 2 3math.randomseed(os.time()) 4 5im = gd.createFromJpeg("./bugs.jpg") 6assert(im) 7sx, sy = im:sizeXY() 8 9im2 = gd.createTrueColor(2*sx, sy) 10black = im2:colorAllocate(0, 0, 0) 11white = im2:colorAllocate(255, 255, 255) 12gd.copy(im2, im, 0, 0, 0, 0, sx, sy, sx, sy) 13 14sx2, sy2 = im2:sizeXY() 15im2:stringUp(gd.FONT_SMALL, 5, sy2-10, gd.VERSION, white) 16 17for i = 0, 14 do 18 for j = 0, 24 do 19 rcl = im2:colorAllocate(math.random(255), math.random(255), 20 math.random(255)) 21 im2:filledRectangle(sx+20+j*10, i*20+40, sx+30+j*10, i*20+50, rcl) 22 end 23end 24 25im2:string(gd.FONT_GIANT, sx+80, 10, "Powered by Lua", white) 26 27blackTr = im2:colorAllocateAlpha(0, 0, 0, 80) 28im2:stringFT(blackTr, "./Vera.ttf", 140, 0, 70, 130, "gd") 29im2:stringFT(white, "./Vera.ttf", 45, math.pi/5, 340, 250, "FreeType") 30 31 32im2:png("out.png") 33os.execute("display out.png") 34