As some might be aware of, there used to be an active project called Charas Project. It's not really that active anymore, but it still exists and stuff. Anyway, back then someone made an offline version called Charas.EX, which had some nifty things, like colorizing certain parts of the body. I myself used to work with it for a while, as in, I used to add new features, and even tried to make it so you could make facesets and stuff, but in the end, that didn't happen because I didn't really have the patience and stuff.
Anyway, Flash forward ten years later, as in, this year. I finally decided to work on this again, but for different reasons. First of all, the built-in character generator is pretty cool, but it's quite limited with its choice of colors. I don't really want to be limited to just a few colors. So, I wanted to be able to colorize my charsets, however, I didn't want to colorize the entire thing at once. Another reason was so that I could use this same system for one of my games. Which will never happen, considering my track record of not-being-able-to-finish-stuff stuff. Stuff. Thingy.
How does it actually work?
Unlike most simple character generators made for and / or in RPG Maker, this one uses layers for each resource. Let me put it simpler. I'll take a basic resource:
This one I edited from one in the RTP so that it sort of kind of maybe if you squint a little resembles a ninja outfit. I didn't use the one in the Samurai pack because I know it's against the TOS to post anything from DLC packs, even if it's part of it. That and I only realized yesterday that it had a ninja character, heck, it even had a female ninja, which was just the reason I made this one. Because I needed one. A female ninja outfit. You know what I mean.
To actually get the layers though, I actually need to split the sprite up into layers. Charas.EX actually had an ability to select areas based on similar colors, but since I'm in a development phase, I kind of had to do this myself.
Now, as you might not have noticed, each individual layer has at most 256 colors. Actually, it's way less, but let's just say they're less than 256 colors, which is still accurate. This also counts for every difference in alpha, but since there's no alpha difference here aside from the fully transparent background, you can ignore this one for now. All layers have to have at most 256 colors for it to work properly, and quite honestly, you don't even need more than that. What happens now is that each layer is turned into a greyscale image, and each greyscale value that's used will get a color assigned to it. Actually, the latter is more for presets, because with these greyscales you already can go a long way.
During assembly of the sprite, it will first apply a colorset, which is a set of color tables that define the coloring of all layers of a specific resource, where color tables map colors to a greyscale value. It would then turn it into a Bitmap object. Finally it would assemble all resources into one character.
The WIP I'm posting doesn't do a lot, or anything really. All it does is generate each resource from raw images and a set of parameters and data, and then assembles some example sprites to display. Eventually, I want to turn it into a full-fledged resource generator.
For now, here's the demo:
CharasVXA WIP 1
The core script is almost complete, which allows people to create their own resources. In fact, you can already use it in your own project. How you actually make the resources and store them is up to you, but I've included a helper class in it just in case. Of course you can always just Marshal Dump your resources so that they would get compressed. In case anybody wants to just mess with that instead without downloading the entire WIP, here's the script:
CharasVXA WIP 1
The script isn't documented yet, but it eventually will be once it's ready to be released.
If you want to mess around with the WIP, you can search for create_preview, where all examples are being generated.
What needs to be done

I've decided to pick WTFPL as the license because I feel like such a thing should be available for everybody, no strings attached. I myself was thinking about porting it to Java to make it more easier to develop and make it more multi-platform, but others can do so as well.
Do note that it's a very work in progress, even though the core basically is mostly complete, functionality of the generator itself isn't. In fact, there is no functionality. I also can't give an ETA, but if you really are impatient, I suggest learning some Ruby and try it for yourself.
If there are questions about the script, like the specifics, just post them right here.
Anyway, Flash forward ten years later, as in, this year. I finally decided to work on this again, but for different reasons. First of all, the built-in character generator is pretty cool, but it's quite limited with its choice of colors. I don't really want to be limited to just a few colors. So, I wanted to be able to colorize my charsets, however, I didn't want to colorize the entire thing at once. Another reason was so that I could use this same system for one of my games. Which will never happen, considering my track record of not-being-able-to-finish-stuff stuff. Stuff. Thingy.
How does it actually work?
Unlike most simple character generators made for and / or in RPG Maker, this one uses layers for each resource. Let me put it simpler. I'll take a basic resource:
This one I edited from one in the RTP so that it sort of kind of maybe if you squint a little resembles a ninja outfit. I didn't use the one in the Samurai pack because I know it's against the TOS to post anything from DLC packs, even if it's part of it. That and I only realized yesterday that it had a ninja character, heck, it even had a female ninja, which was just the reason I made this one. Because I needed one. A female ninja outfit. You know what I mean.
To actually get the layers though, I actually need to split the sprite up into layers. Charas.EX actually had an ability to select areas based on similar colors, but since I'm in a development phase, I kind of had to do this myself.
Now, as you might not have noticed, each individual layer has at most 256 colors. Actually, it's way less, but let's just say they're less than 256 colors, which is still accurate. This also counts for every difference in alpha, but since there's no alpha difference here aside from the fully transparent background, you can ignore this one for now. All layers have to have at most 256 colors for it to work properly, and quite honestly, you don't even need more than that. What happens now is that each layer is turned into a greyscale image, and each greyscale value that's used will get a color assigned to it. Actually, the latter is more for presets, because with these greyscales you already can go a long way.
During assembly of the sprite, it will first apply a colorset, which is a set of color tables that define the coloring of all layers of a specific resource, where color tables map colors to a greyscale value. It would then turn it into a Bitmap object. Finally it would assemble all resources into one character.
The WIP I'm posting doesn't do a lot, or anything really. All it does is generate each resource from raw images and a set of parameters and data, and then assembles some example sprites to display. Eventually, I want to turn it into a full-fledged resource generator.
For now, here's the demo:
CharasVXA WIP 1
The core script is almost complete, which allows people to create their own resources. In fact, you can already use it in your own project. How you actually make the resources and store them is up to you, but I've included a helper class in it just in case. Of course you can always just Marshal Dump your resources so that they would get compressed. In case anybody wants to just mess with that instead without downloading the entire WIP, here's the script:
CharasVXA WIP 1
$charasvxa_sets = {}#==============================================================================# ** Charas_Type#------------------------------------------------------------------------------# Defines the different types and its categories.#==============================================================================class Charas_Type def initialize(id, name, width, height, cols, rows, preview_frame = 1) $charasvxa_sets||= {} $charasvxa_sets[id] = self @id = id @name = name @width = width @height = height @cols = cols @rows = rows @preview_frame = preview_frame @category = {} @category_order = [] end def add_category(index, id, name, single = true) @category||= {} @category_order ||= [] @category[id] = [name, [], single] @category_order[index] = id end def get_category(id) @category||= {} return nil if @category[id].nil? || @category[id].size < 3 @category[id][1] end def get_category_single?(id) @category||= {} return false if @category[id].nil? || @category[id].size < 3 @category[id][2] end def get_category_name(id) @category||= {} return nil if @category[id].nil? || @category[id].size < 3 @category[id][0] end def get_categories Array.new(@category_order) end def add_entry(id, resource) @category||= {} @category[id] = ["", [], true] if @category[id].nil? @category[id][1].push(resource) if !@category[id][1].include?(resource) end def remove_entry(id, resource) @category||= [] @category[id] = ["", [], true] if @category[id].nil? @category[id][1].delete(resource) if @category[id][1].include?(resource) end def get_entry(id, res_id) @category||= [] @category[id] = ["", [], true] if @category[id].nil? @category[id][1].each do |res| return res if res.id == res_id end return nil end def get_name @name end def get_id @id end def width @width end def height @height end def frame_width @width / @cols end def frame_height @height / @rows end def preview_rect x_i = @preview_frame % @cols y_i = @preview_frame / @cols rect = Rect.new(x_i * frame_width, y_i * frame_height, frame_width, frame_height) rect end def get_data str = [@id.size + 1].pack("c") str+= @id + [0].pack("c") str+= [@name.size + 1].pack("c") str+= @name + [0].pack("c") str+= [@width, @height, @cols, @rows, @preview_frame].pack("vvccv") used_categories = 0 t_str = "" @category_order.each_index do |index| next if @category_order[index].nil? id = @category_order[index] t_str+= [index, id.size + 1].pack("c*") t_str+= id + [0].pack("c") t_str+= [@category[id][0].size + 1].pack("c") t_str+= @category[id][0] + [0].pack("c") t_str+= [(@category[id][2] ? 1 : 0)].pack("c") used_categories+= 1 end str+= [used_categories, t_str.size].pack("vV") + t_str str end def self.set_data(str) idx = 0 idsize = str[idx, 1].unpack("c") idx+= 1 id = str[idx, idsize - 1] idx+= idsize namesize = str[idx, 1].unpack("c") idx+= 1 name = str[idx, namesize - 1] idx+= namesize w, h, c, r, p = str[idx, 8].unpack("vvccv") data = Charas_Type(id, name, w, h, c, r, p) idx+= 6 used_categories, strsize = str[idx, 6].unpack("vV") idx+= 6 t_str = str[idx, strsize] t_idx = 0 for i in 0..(used_categories - 1) index, idsize = t_str[t_idx, 2].unpack("c*") t_idx+= 2 id = t_str[t_idx, idsize - 1] t_idx+= idsize catsize = t_str[t_idx, 1].unpack("c") t_idx+= 2 name = t_str[t_idx, catsize - 1] t_idx+= catsize single = (t_str[t_idx, 1].unpack("c") == 1) t_idx+= 1 data.add_category(index, id, name, single) end data endend#==============================================================================# ** Charas_Layer#------------------------------------------------------------------------------# Layers define greyscale images, which can later be colorized.#==============================================================================class Charas_Layer def set_data_from_bitmap(bmp) @used_values = [] @data = Table.new(bmp.width, bmp.height, 2) for y in 0..(bmp.height - 1) for x in 0..(bmp.width - 1) col = bmp.get_pixel(x, y) red = col.red green = col.green blue = col.blue alpha = col.alpha if alpha == 0 val = 0 elsif red == green && red == blue val = red else val = (2126 * red + 7152 * green + 722 * blue) / 10000 end @data[x, y, 0] = val @data[x, y, 1] = alpha @used_values.push(val) if !@used_values.include?(val) && alpha > 0 end end end def behind_previous=(value) @behind_previous = value end def behind_previous? @behind_previous = false if @behind_previous.nil? @behind_previous end def width @data.xsize end def height @data.ysize end def render(table) gradient = table.get_table bitmap = Bitmap.new(@data.xsize, @data.ysize) for y in 0..(@data.ysize - 1) for x in 0..(@data.xsize - 1) color = gradient.get_pixel(@data[x, y, 0], 0) color.alpha = @data[x, y, 1] bitmap.set_pixel(x, y, color) end end bitmap end def used_values Array.new(@used_values) end def get_data str = [width, height].pack("v*") str+= [(behind_previous? ? 1 : 0)].pack("c") for y in 0..(height - 1) for x in 0..(width - 1) str+= [@data[x, y, 0], @data[x, y, 0]].pack("c*") end end str+= [@used_values.size].pack("c") str+= @used_values.pack("c*") str end def set_data(str) width, height = str[0, 4].unpack("v*") @data = Table.new(width, height, 2) @behind_previous = (str[4, 1].unpack("c") == 1) for y in 0..(height - 1) for x in 0..(width - 1) i = (x + y * width) * 2 @data[x, y, 0], @data[x, y, 1] = str[5 + i, 2].unpack("c*") end end i = 5 + (width * height * 2) @used_values = str[i + 1, str[i, 1].unpack("c")].unpack("c*") endend#==============================================================================# ** Charas_ColorTable#------------------------------------------------------------------------------# Color tables are used in conjunction with layers to colorize them. The# value attached corresponds to the greyscale value that gets colorized. Any# missing value on the grayscale gets interpolated from this color table.#==============================================================================class Charas_ColorTable def initialize @colors = [] @colors[0] = Color.new(0, 0, 0, 255) @colors[255] = Color.new(255, 255, 255, 255) @rendered = false end def add_color(value, red, green, blue) @colors[value] = Color.new(red, green, blue) @rendered = false end def override_colors=(value) @override_colors = value end def override_colors @override_colors = false if @override_colors.nil? @override_colors end def get_table if @gradient.nil? || @gradient.disposed? || @rendered == false @gradient = Bitmap.new(256, 1) cur = [0, @colors[0]] for i in 1..255 next if @colors.nil? @gradient.gradient_fill_rect(cur[0], 0, i, 1, cur[1], @colors) cur = [i, @colors] end end @gradient end def get_data str = [(override_colors ? 1 : 0)].pack("c") used_color = 0 @colors.each_index do |index| next if @colors[index].nil? str+= [index, @colors[index].red, @colors[index].green, @colors[index].blue].pack("c*") used_color+= 1 end str = [used_color].pack("c") + str str end def set_data(str) override_colors = (str[0, 1].unpack("c") == 1) used_color = str[1, 1].unpack("c") @colors = [] @colors[0] = Color.new(0, 0, 0, 255) @colors[255] = Color.new(255, 255, 255, 255) for i in 0..(used_color - 1) index, red, green, blue = str[2 + i * 4, 4].unpack("c*") @colors[index] = Color.new(red, green, blue, 255) end end def self.set_data(str) data = Charas_ColorTable.new data.set_data(str) data endend#==============================================================================# ** Charas_Colorset#------------------------------------------------------------------------------# Colorsets contain a list of color tables whose key corresponds to the layer# that gets colorized with this table.#==============================================================================class Charas_Colorset def add_layer(layer, table) @layer||= [] @layer[layer] = table end def get_layer(layer) @layer||= [] @layer[layer] end def name=(value) @name = value end def name @name = "" if @name.nil? @name end def get_data t_str = "" used_layers = 0 @layer||=[] @layer.each_index do |index| next if @layer[index].nil? dat = @layer[index].get_data t_str+= [index].pack("v") t_str+= [dat.size].pack("V") t_str+= dat used_layers+= 1 end str = [name.size + 1].pack("c") str+= name + [0].pack("c") str+= [used_layers].pack("v") + t_str str end def set_data(str) @name = str[1, str[0, 1].unpack("c") - 1] s_i = str[0, 1].unpack("c") + 1 used_layers = str[s_i, 1].unpack("v") s_i+= 2 @layer = [] for i in 0..(used_layers - 1) l_i = str[s_i, 2].unpack("v") @layer[l_i] = Charas_ColorTable.new s_i+= 2 datsize = str[s_i, 4].unpack("V") s_i+= 4 @layer[l_i].set_data(str[s_i, datsize]) s_i+= datsize end end def self.set_data(str) data = Charas_Colorset.new data.set_data(str) data endend#==============================================================================# ** Charas_Resource#------------------------------------------------------------------------------# Resources are a list of layers, and can get colorized with a colorset.# Essentially this is the backbone of CharasVXA.#==============================================================================class Charas_Resource DEFAULT_GRADIENT = Charas_ColorTable.new def name=(value) @name = value end def name @name = "" if @name.nil? @name end def id=(value) @id = value end def id @id = "" if @id.nil? @id end def type=(value) old_type = type @type = value if old_type != "" && !$charasvxa_sets[old_type].nil? $charasvxa_sets[old_type].remove_entry(category, self) end $charasvxa_sets[@type].add_entry(category, self) end def type @type = "" if @type.nil? @type end def category=(value) $charasvxa_sets[type].remove_entry(category, self) if type != "" @category = value $charasvxa_sets[type].add_entry(category, self) if type != "" end def category @category = "" if @category.nil? @category end def gender=(value) @gender = value if [:unisex, :male, :female].include?(value) end def gender @gender = :unisex if @gender.nil? @gender end def description=(value) @description = value end def description @description = "" if @description.nil? @description end def add_special_layer(sym, layer) @special_layer||= {} @special_layer[sym] = layer end def get_special_layer(sym) @special_layer||= {} return @special_layer[sym] end def add_layer(bmp, layer, behind_previous = false) @layer||= [] @layer[layer] = Charas_Layer.new @layer[layer].set_data_from_bitmap(bmp) @layer[layer].behind_previous = behind_previous end def add_preset(preset_id, layer, table) @preset||= [] @preset[preset_id] = Charas_Colorset.new if @preset[preset_id].nil? @preset[preset_id].add_layer(layer, table) end def set_preset(preset_id, colorset) return if colorset.nil? @preset||= [] @preset[preset_id] = colorset end def get_preset(preset_id) @preset||= [] if preset_id < 0 i = 0 while [email protected]? && [email protected]? && i < @preset.size if !@preset.nil? preset_id = i break end i+= 1 end return nil if preset_id < 0 end return @preset[preset_id] end def render(param = nil, special_layer = nil) return if @layer.nil? || @layer.empty? @preset||= [] colorset = [] if param.kind_of?(Charas_Colorset) for i in 0..(@layer.size - 1) colorset = param.get_layer(i) end elsif param.kind_of?(Integer) && param < 0 i = 0 pre = nil while [email protected]? && [email protected]? && pre.nil? && i < @preset.size pre = @preset if !@preset.nil? i+= 1 end if !pre.nil? for i in 0..(@layer.size - 1) colorset = pre.get_layer(i) end end elsif param.kind_of?(Integer) && !@preset[param].nil? pre = @preset[param] if !pre.nil? for i in 0..(@layer.size - 1) colorset = pre.get_layer(i) end end end special_layer||= {} @special_layer||= {} special_layer.each_pair do |sym, table| if !@special_layer[sym].kind_of?(Array) colorset[@special_layer[sym]] = table if !@special_layer[sym].nil? && !colorset[@special_layer[sym]].override_colors else next if @special_layer[sym].nil? @special_layer[sym].each do |index| colorset[index] = table if !colorset[index].override_colors end end end bitmap_front = Bitmap.new(@layer[0].width, @layer[0].height) bitmap_back = Bitmap.new(@layer[0].width, @layer[0].height) for i in 0..(@layer.size - 1) table = colorset table = DEFAULT_GRADIENT if table.nil? bmp = @layer.render(table) if @layer.behind_previous? bitmap_back.blt(0, 0, bmp, bmp.rect) else bitmap_front.blt(0, 0, bmp, bmp.rect) end end [bitmap_front, bitmap_back] end def set_preview i = 0 pre = nil while [email protected]? && [email protected]? && pre.nil? && i < @preset.size pre = @preset if !@preset.nil? i+= 1 end bmp_duo = render(pre) if bmp_duo.nil? bmp = Bitmap.new(1, 1) @bitmap_data = CXJ::BitmapData.new(bmp) bmp.dispose return end bmp = bmp_duo[1] bmp.blt(0, 0, bmp_duo[0], bmp_duo[0].rect) if $charasvxa_sets[type].nil? @bitmap_data = CXJ::BitmapData.new(bmp) else nbmp = Bitmap.new($charasvxa_sets[type].frame_width, $charasvxa_sets[type].frame_height) r = $charasvxa_sets[type].preview_rect nbmp.blt(0, 0, bmp, r) @bitmap_data = CXJ::BitmapData.new(nbmp) nbmp.dispose end bmp_duo[0].dispose bmp_duo[1].dispose end def get_preview set_preview if @bitmap_data.nil? @bitmap_data.bitmap end def get_data str = [name.size + 1].pack("c") str+= name + [0].pack("c") str+= [id.size + 1].pack("c") str+= id + [0].pack("c") str+= [type.size + 1].pack("c") str+= type + [0].pack("c") str+= [category.size + 1].pack("c") str+= category + [0].pack("c") gen = gender str+= [(gen == :unisex ? 0 : (gen == :male ? 1 : 2))].pack("c") str+= [description.size + 1].pack("v") str+= description + [0].pack("c") used_special_layers = 0 t_str = "" @special_layer||= {} @special_layer.each_pair do |sym, layer| symstr = sym.id2name t_str+= [symstr.size + 1].pack("c") t_str+= symstr + [0].pack("c") t_str+= [layer.size].pack("c") t_str+= layer.pack("v") used_special_layers+= 1 end str+= [used_special_layers, t_str.size].pack("vV") + t_str used_presets = 0 t_str = "" @preset||= [] @preset.each_index do |index| next if @preset[index].nil? pre = @preset[index].get_data t_str+= [index].pack("v") t_str+= [pre.size].pack("V") t_str+= pre used_presets+= 1 end str+= [used_presets, t_str.size].pack("vV") + t_str used_layers = 0 t_str = "" @layer||= [] @layer.each_index do |index| next if @layer[index].nil? dat = @layer[index].get_data t_str+= [index].pack("v") t_str+= [dat.size].pack("V") t_str+= dat used_layers+= 1 end str+= [used_layers].pack("v") + t_str str = [str.size].pack("V") + str set_preview str+= [@bitmap_data.width, @bitmap_data.height].pack("v") str+= [@bitmap_data.data.size].pack("V") str+= @bitmap_data.data str end def set_data(str) idx = str[0, 1].unpack("c") name = str[1, idx - 1] idx+= 1 idx2 = str[idx, 1].unpack("c") @id = str[idx + 1, idx2 - 1] idx+= idx2 + 1 idx2 = str[idx, 1].unpack("c") @type = str[idx + 1, idx2 - 1] idx+= idx2 + 1 idx2 = str[idx, 1].unpack("c") @category = str[idx + 1, idx2 - 1] $charasvxa_sets[@type].add_entry(@category, self) idx+= idx2 + 1 gender = [:unisex, :male, :female][str[idx, 1].unpack("c")] idx+= 1 idx2 = str[idx, 2].unpack("v") description = str[idx + 2, idx2 - 1] idx+= idx2 + 2 use_special_layers, strsize = str[idx, 6].unpack("vV") idx+= 6 t_str = str[idx, strsize] idx+= strsize t_idx = 0 @special_layer = {} for i in 0..(use_special_layers - 1) symstrsize = t_str[t_idx, 1].unpack("c") t_idx+= 1 sym = t_str[t_idx, symstrsize - 1].to_sym t_idx+= symstrsize layersize = t_str[t_idx, 1].unpack("c") t_idx+= 1 layer = t_str[t_idx, layersize * 2].unpack("v*") t_idx+= layersize * 2 @special_layer[sym] = layer end used_presets, strsize = str[idx, 6].unpack("vV") idx+= 6 t_str = str[idx, strsize] t_idx = 0 @preset = [] for i in 0..(used_presets - 1) index, presize = t_str[t_idx, 6].unpack("vV") t_idx+= 6 @preset[index] = Charas_Colorset.new @preset[index].set_data(t_str[t_idx, presize]) t_idx+= presize end used_layers, strsize = str[idx, 6].unpack("vV") idx+= 6 t_str = str[idx, strsize] t_idx = 0 @preset = [] for i in 0..(used_layers - 1) index, datsize = t_str[t_idx, 6].unpack("vV") t_idx+= 6 @layer[index] = Charas_Layer.new @layer[index].set_data(t_str[t_idx, datsize]) t_idx+= datsize end p_width, p_height, datasize = str[idx, 8].unpack("vvV") idx+= 8 data = str[idx, datasize] bmp = Bitmap.new(p_width, p_height) bmp.pointer_data[0, p_height * p_width * 4] = data @bitmap_data = CXJ::BitmapData(bmp) bmp.dispose end def self.set_data(str) data = Charas_Resource.new data.set_data(str) data endend#==============================================================================# ** Charas_Character#------------------------------------------------------------------------------# Characters are assembled from resources.#==============================================================================class Charas_Character def initialize(type) raise("Type does not exist: " + type) unless $charasvxa_sets.include?(type) @type = type @set = [] @preset = [] end def description=(value) @description = value end def description @description = "" if @description.nil? @description end def category_exists?(category) type_object = $charasvxa_sets[@type] return !type_object.get_category(category).nil? end def category_single?(category) type_object = $charasvxa_sets[@type] return type_object.get_category_single?(category) end def set_resource(category, *resource) return unless category_exists?(category) type_object = $charasvxa_sets[@type] categories = type_object.get_categories resource = [resource[0]] if category_single?(category) index = categories.index(category) res = [] resource.each do |r| rs = type_object.get_entry(category, r) res.push(rs) unless rs.nil? end @set[index] = res @preset[index] = [-1] * res.size end def set_preset(category, index, pre) return unless category_exists?(category) type_object = $charasvxa_sets[@type] categories = type_object.get_categories cat_idx = categories.index(category) cur_res = @set[cat_idx] return if cur_res.nil? cur_res = cur_res[index] return if cur_res.nil? @preset[cat_idx][index] = pre end def get_special_layer(category, index, special) def_grad = Charas_Resource:😀EFAULT_GRADIENT return def_grad unless category_exists?(category) type_object = $charasvxa_sets[@type] categories = type_object.get_categories cat_idx = categories.index(category) cur_res = @set[cat_idx] return def_grad if cur_res.nil? cur_res = cur_res[index] return def_grad if cur_res.nil? spec_layer = cur_res.get_special_layer(special) return def_grad if spec_layer.nil? preset = cur_res.get_preset(@preset[cat_idx][index]) return def_grad if preset.nil? if spec_layer.kind_of?(Array) spec_layer.each do |layer| lay = preset.get_layer(layer) return lay unless lay.nil? end else lay = preset.get_layer(spec_layer) return lay unless lay.nil? end return def_grad end def render(special_layer = nil) type_object = $charasvxa_sets[@type] render_bitmap = Bitmap.new(type_object.width, type_object.height) @set.each_index do |res_set_idx| res_set = @set[res_set_idx] next if res_set.nil? res_pre = @preset[res_set_idx] res_set.each_index do |res_idx| res = res_set[res_idx] pre = res_pre[res_idx] bmps = res.render(pre, special_layer) temp_bitmap = Bitmap.new(type_object.width, type_object.height) temp_bitmap.blt(0, 0, bmps[1], bmps[1].rect) temp_bitmap.blt(0, 0, render_bitmap, render_bitmap.rect) temp_bitmap.blt(0, 0, bmps[0], bmps[0].rect) render_bitmap.dispose bmps[0].dispose bmps[1].dispose render_bitmap = temp_bitmap end end return render_bitmap end def get_data str = [description.size + 1].pack("c") str+= description + [0].pack("c") str+= [@type.size + 1].pack("c") str+= @type + [0].pack("c") str+= [@set.size].pack("v") endend#==============================================================================# ** Charas_File#------------------------------------------------------------------------------# To make it easier, this helper class handles files.#==============================================================================class Charas_File def self.write(file, res, deflate = false, auto_make_dir = false) type = 0 case res when Charas_Type type = 0 when Charas_Resource type = 1 when Charas_ColorTable type = 2 when Charas_Colorset type = 3 else raise("Invalid resource type") end if auto_make_dir f_split = File.split(file) dir = f_split[0] mdir = [] while !File.exists?(dir) && !dir.rindex('/').nil? && !dir.rindex('/') > 0 mdir.unshift(dir) dir = dir[0, dir.rindex('/')] end mdir.each do |dir| Dir.mkdir(dir) end end File.open(file, "wb") do |f| f.write("CVXA") f.write([type, deflate ? 1 : 0].pack("c*")) data = res.get_data f.write([Zlib::crc32(data)].pack('V')) f.write(data) unless deflate f.write(Zlib:😀eflate.deflate(data)) end end def self.read(file) raise(Errno::ENOENT) unless File.exists?(file) data = "" File.open(file, "rb") do |f| data = f.read end mgc = data.slice!(0, 4) raise("Not a valid file") unless mgc == "CVXA" type, deflate = data.slice!(0, 2).unpack("c*") type_class = nil case type when 0 type_class = Charas_Type when 1 type_class = Charas_Resource when 2 type_class = Charas_ColorTable when 3 type_class = Charas_Colorset else raise("Not a valid file") end crc32 = data.slice!(0, 4).unpack("V")[0] data = Zlib::Inflate.inflate(data) if deflate == 1 raise("Invalid checksum") unless Zlib::crc32(data) == crc32 ret_data = type_class.set_data(data) ret_data endend
If you want to mess around with the WIP, you can search for create_preview, where all examples are being generated.
What needs to be done
- The GUI for the generator;
- Documentation for the script(s);
- Possible additional work on the core script;
- Possible encryption to protect certain resources (although Marshal dumping it could take care if it);
- More example resources.

I've decided to pick WTFPL as the license because I feel like such a thing should be available for everybody, no strings attached. I myself was thinking about porting it to Java to make it more easier to develop and make it more multi-platform, but others can do so as well.
Do note that it's a very work in progress, even though the core basically is mostly complete, functionality of the generator itself isn't. In fact, there is no functionality. I also can't give an ETA, but if you really are impatient, I suggest learning some Ruby and try it for yourself.
If there are questions about the script, like the specifics, just post them right here.