class WAD::Flat
- WAD::Flat
- Reference
- Object
Overview
A WAD flat
Included Modules
Extended Modules
Defined in:
raylib.crwa-cr/wad/wad-data/texture.cr
write.cr
Constructors
-
.parse(filename : String | Path) : Flat
Parses a flat file given the filename
-
.parse(io : IO) : Flat
Parses a flat file given the io
Class Method Summary
-
.is_flat_mark_end?(name : String)
Checks to see if name is "F_END".
-
.is_flat_mark_start?(name : String)
Checks to see if name is "F_START".
Instance Method Summary
- #[](x : Int, y : Int)
-
#clone
Returns a copy of
self
with all instance variables cloned. - #colors : Array(UInt8)
- #colors=(colors : Array(UInt8))
- #height : Int32
- #height=(height : Int32)
- #lump_bytes : Int32
- #lump_bytes=(lump_bytes : Int32)
-
#set_pixel(x : Int, y : Int, value : Int)
Sets a pixel in the flat to be value.
- #width : Int32
- #width=(width : Int32)
Instance methods inherited from module WritingAdditions::Flat
write(file : String | Path) : UInt32write(io : IO) : UInt32 write
Instance methods inherited from module RaylibAdditions::Flat
get_pixel(x : Int, y : Int, palette : ::WAD::Playpal::Palette) : Raylib::Color
get_pixel,
to_image(palette : ::WAD::Playpal::Palette) : Raylib::Image
to_image,
to_png(filename : String | Path, palette : ::WAD::Playpal::Palette)
to_png
Constructor Detail
Parses a flat file given the filename
Opens a flat file and parses it:
my_flat = WAD::Flat.parse("Path/To/Flat")
Parses a flat file given the io
Opens a flat io and parses it:
File.open("Path/To/Flat") do |file|
my_flat = WAD::Flat.parse(file)
end
Class Method Detail
def self.is_flat_mark_end?(name : String)
#
Checks to see if name is "F_END".
Returns true if the name is a flat marker end:
flat_mark_name = "F_END"
if WAD::Flat.is_flat_mark_end?(flat_mark_name)
puts "Is a Flat Marker End"
else
puts "Is not a Flat Marker End"
end
def self.is_flat_mark_start?(name : String)
#
Checks to see if name is "F_START".
Returns true if the name is a flat marker start:
flat_mark_name = "F_START"
if WAD::Flat.is_flat_mark_start?(flat_mark_name)
puts "Is a Flat Marker Start"
else
puts "Is not a Flat Marker Start"
end
Instance Method Detail
def set_pixel(x : Int, y : Int, value : Int)
#
Sets a pixel in the flat to be value.
Raises an error if value is not within the bounds
of a UInt8
NOTE value does not refer to an rgb color,
but instead to an index in the colors of a WAD::Playpal::Palette
my_wad = WAD.read("Path/To/Wad")
my_flat = my_wad.flats["MyFlat"]
my_flat[2, 3] # => Returns the value of the pixel at x=2 y=3
my_flat.set_pixel(2, 3, 120) # => Sets the value of the pixel at x=2 y=3 to be 120
my_flat[2, 3] # => 120
my_flat.set_pixel(2, 3, -1) # => Raises an exception
my_flat.set_pixel(2, 3, 256) # => Raises an exception