r/GraphicsProgramming • u/[deleted] • Aug 23 '21
Question Custom graphic generator in Java - what tutorials should I look for?
I want to create a custom graphic generator in JavaScript, something like this: https://store.steampowered.com/app/1075104/RPG_Maker_MV__Heroine_Character_Generator_4/
Multiple image layers should be put one on top of another and then baked into a PNG or GIF file. I can make a page where users combine different graphics on layers into an image, but I have no idea where to look for resources about programming a merge of the images. Could you please guide me to what should I look for? Specific functions I should learn? Maybe some videos?
Thank you very much for all the help!
1
Upvotes
1
u/wm_cra_dev Aug 23 '21 edited Aug 23 '21
Pixels are usually represented as 3 values, called "RGB" -- Red, Green, and Blue. Sometimes a fourth value is used, called "Alpha" ("RGBA"), to represent transparency when you have multiple layers of pixels. A low Alpha means it's invisible, a high Alpha means it's opaque.
To merge multiple layers of an image, start with an empty image (i.e. it's just the background color, or a color with Alpha=0). Then apply each layer from back to front. When applying the pixels of a layer onto the pixels of the final image, use the following formula for simple "alpha blending" (assuming pixel values range from 0 to 1, and not 0 to 255):