module RaylibAdditions::Graphic
Overview
A WAD graphic
Direct including types
Defined in:
raylib.crInstance Method Summary
-
#get_pixel(x : Int, y : Int, palette : ::WAD::Playpal::Palette) : Raylib::Color
Returns a Raylib Color for the pixel of a graphic
-
#to_image(palette : ::WAD::Playpal::Palette) : Raylib::Image
Converts a graphic to a raylib image using a palette
-
#to_png(filename : String | Path, palette : ::WAD::Playpal::Palette)
Exports a graphic to a png given a filename and a palette
Instance Method Detail
def get_pixel(x : Int, y : Int, palette : ::WAD::Playpal::Palette) : Raylib::Color
#
Returns a Raylib Color for the pixel of a graphic
Gets the Raylib Color of the pixel [2, 4] and draws it:
require "wa-cr/raylib"
palette = my_wad.playpal.palettes[0]
my_pixel = my_wad.graphics["HELP1"].get_pixel(2, 4)
Raylib.draw_pixel(
0,
0,
my_pixel
)
def to_image(palette : ::WAD::Playpal::Palette) : Raylib::Image
#
Converts a graphic to a raylib image using a palette
Converts a graphic to a Raylib Image given a palette and draws that image:
require "wa-cr/raylib"
palette = my_wad.playpal.palettes[0]
my_image = my_wad.graphics["HELP1"].to_image(palette)
Raylib.draw_texture(
Raylib.load_texture_from_image(my_image),
0,
0,
Raylib::WHITE
)
def to_png(filename : String | Path, palette : ::WAD::Playpal::Palette)
#
Exports a graphic to a png given a filename and a palette
my_wad = WAD.read("Path/To/Wad")
palette = my_wad.playpal.palettes[0]
my_graphic = my_wad.graphics["MyGraphic"]
my_graphic.to_png("Path/To/MyGraphic.png", palette)