class WAD::Graphic
- WAD::Graphic
- Reference
- Object
Overview
A WAD graphic
WARNING The max graphic height is 255. The max width is unlimited
NOTE Graphic has no is_graphic?
method.
Instead, Graphic#parse
will return nil
if
io is not a valid graphic
Included Modules
Extended Modules
Defined in:
raylib.crwa-cr/wad/wad-data/texture.cr
write.cr
Class Method Summary
-
.is_sprite_mark_end?(name : String)
Checks to see if name is "S_END".
-
.is_sprite_mark_start?(name : String)
Checks to see if name is "S_START".
-
.parse(filename : String | Path) : Graphic | Nil
Parses a graphic file given the filename
-
.parse(file : File, file_pos : Int = 0, size : Int = -1) : Graphic | Nil
Parses a graphic file given the file
Instance Method Summary
- #[](x : Int, y : Int)
-
#clone
Returns a copy of
self
with all instance variables cloned. - #data : Array(UInt8 | Nil)
- #file_size : UInt32
- #file_size=(file_size : UInt32)
- #height : UInt16
- #height=(height : UInt16)
- #leftoffset : Int16
- #leftoffset=(leftoffset : Int16)
- #reset_data
-
#set_pixel(x : Int, y : Int, value : Int)
Sets a pixel in the graphic to be value.
- #topoffset : Int16
- #topoffset=(topoffset : Int16)
- #width : UInt16
- #width=(width : UInt16)
Instance methods inherited from module WritingAdditions::Graphic
write(file : String | Path) : UInt32write(io : IO) : UInt32 write
Instance methods inherited from module RaylibAdditions::Graphic
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
Class Method Detail
Checks to see if name is "S_END".
Returns true if the name is a sprite marker end:
sprite_mark_name = "S_END"
if WAD::Graphic.is_sprite_mark_end?(sprite_mark_name)
puts "Is a Sprite Marker End"
else
puts "Is not a Sprite Marker End"
end
Checks to see if name is "S_START".
Returns true if the name is a sprite marker start:
sprite_mark_name = "S_START"
if WAD::Graphic.is_sprite_mark_start?(sprite_mark_name)
puts "Is a Sprite Marker Start"
else
puts "Is not a Sprite Marker Start"
end
Parses a graphic file given the filename
Opens a graphic file and parses it:
my_graphic = WAD::Graphic.parse("Path/To/Graphic")
Parses a graphic file given the file
Opens a graphic file and parses it:
File.open("Path/To/Graphic") do |file|
my_graphic = WAD::Graphic.parse(file)
end
Instance Method Detail
Sets a pixel in the graphic 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_graphic = my_wad.graphics["MyGraphic"]
my_graphic[2, 3] # => Returns the value of the pixel at x=2 y=3
my_graphic.set_pixel(2, 3, 120) # => Sets the value of the pixel at x=2 y=3 to be 120
my_graphic[2, 3] # => 120
my_graphic.set_pixel(2, 3, -1) # => Raises an exception
my_graphic.set_pixel(2, 3, 256) # => Raises an exception