module Boleite::Image::Contracts

Defined in:

boleite/graphics/image.cr

Constant Summary

CLASS_DATA = ClassData(Boleite::Image).new
CONTRACTED_METHODS = ["width()", "height()", "bpp()", "pixels()", "initialize(width, height, bpp = 32_u32)", "initialize(width, height, bpp, pixels)", "initialize(file : String)", "size()", "byte_size()", "clone()", "update(x, y, w, h, color : Colori)", "update(rect, color : Colori)", "set_pixel(x, y, color : Colori)", "set_pixel(x, y, color : Colorf)", "get_pixel(x, y)", "fill(color : Colori)", "initialize(native : ::Pointer(LibFreeImage::FIBITMAP))", "convert_16bit(pixel, index)", "convert_24bit(pixel, index)", "convert_32bit(pixel, index)"] of _
CONTRACTS = {:next_def => nil, def set_pixel(x, y, color : Colori) index = (x + (y * width)) * (@bpp // 8) if @bpp >= 8 @pixels[index + 0] = color.r end if @bpp >= 16 @pixels[index + 1] = color.g end if @bpp >= 24 @pixels[index + 2] = color.b end if @bpp >= 32 @pixels[index + 3] = color.a end end => [{:requires, "x >= 0 && x < @width", do x >= 0 && x < @width end}, {:requires, "y >= 0 && y < @height", do y >= 0 && y < @height end}], def set_pixel(x, y, color : Colorf) converted = (color * 255).to_u8 set_pixel(x, y, converted) end => [{:requires, "x >= 0 && x < @width", do x >= 0 && x < @width end}, {:requires, "y >= 0 && y < @height", do y >= 0 && y < @height end}], def get_pixel(x, y) r, g, b, a = 0_u8, 0_u8, 0_u8, 0_u8 index = (x + (y * width)) * (@bpp // 8) if @bpp >= 8 r = @pixels[index + 0] end if @bpp >= 16 g = @pixels[index + 1] end if @bpp >= 24 b = @pixels[index + 2] end if @bpp >= 32 a = @pixels[index + 3] end Colori.new(r, g, b, a) end => [{:requires, "x >= 0 && x < @width", do x >= 0 && x < @width end}, {:requires, "y >= 0 && y < @height", do y >= 0 && y < @height end}]} of _ => _
IGNORED_METHODS = ["finalize", "contract_pre_set_pixel", "contract_post_set_pixel", "contract_requires_set_pixel", "contract_ensures_set_pixel", "contract_pre_set_pixel", "contract_post_set_pixel", "contract_requires_set_pixel", "contract_ensures_set_pixel", "contract_pre_get_pixel", "contract_post_get_pixel", "contract_requires_get_pixel", "contract_ensures_get_pixel"] of _
INVARIANTS = [] of _

Class Method Summary

Macro Summary

Class Method Detail

def self.on_assert_fail(condition, type) #

[View source]
def self.on_contract_fail(contract, condition, type, method) #

[View source]

Macro Detail

macro add_contract(stage, str, &test) #

[View source]
macro add_invariant(str, &test) #

[View source]
macro ignore_method(method) #

[View source]