struct

Shale::Surface

Inherits Struct < Value < Object

Constructors

new(width : UInt32, height : UInt32, channels : Int32 = 4)

Create a surface buffer.

Arguments

  • width
  • height
  • channels

Description

Source

Instance methods

channels
Source
clear(shade : UInt8 = 0)

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.

Source
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

Source
data
Source
height
Source
inspect(io : IO) : Nil

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)"
Source
map_pixel(x : UInt32, y : UInt32, *colours : UInt8)

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.

Source
to_unsafe
Source
width
Source