struct Shale::Surface
- Shale::Surface
- Struct
- Value
- Object
Defined in:
shale/surface.crConstructors
-
.new(width : UInt32, height : UInt32, channels : Int32 = 4)
Create a surface buffer.
Instance Method Summary
- #channels : Int32
-
#clear(shade : UInt8 = 0)
Clear the buffer.
-
#copy_pixel(dest_x, dest_y, src_x, src_y, src : Surface)
quick and dirty way to copy value from slice to slice, trying to get it working first from what's coded in the video, then i will look up another way that maybe better from the crystal docs
- #data : Bytes
- #height : UInt32
-
#inspect(io : IO) : Nil
Appends this struct's name and instance variables names and values to the given IO.
-
#map_pixel(x : UInt32, y : UInt32, *colours : UInt8)
Map pixel to the surface
- #to_unsafe : Pointer(Bytes)
- #width : UInt32
Constructor Detail
Instance Method Detail
Clear the buffer.
Arguments
- shade Provide an 8-bit colour to fill the buffer.
Description
This will fill in the buffer's @data
property to clear whatever has been set.
quick and dirty way to copy value from slice to slice, trying to get it working first from what's coded in the video, then i will look up another way that maybe better from the crystal docs
Appends this struct's name and instance variables names and values to the given IO.
struct Point
def initialize(@x : Int32, @y : Int32)
end
end
p1 = Point.new 1, 2
p1.to_s # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"
Map pixel to the surface
Arguments
- x Horizontal coordinate.
- y Vertial coordinate.
- *colours Tuple of colour values, order currently is for BGRA.
Description
Maps a pixel at the exact coordinate in the surface buffer with the provided colour channels.
There is bounds checking on the incoming parameters, and the mapping of
the colours are using Slice#unsafe_put
method to skip its own bounds
checking. This is done for performance reasons, however (in limited test
time) the speed up is more significant when not building with the
--release
flag.
NOTE Im not sure about a splat for the incoming colours, since I'm not sure if or how to support other colour channel sequences, i.e. CMYK, YCbCr, etc.