You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.0 KiB

import extern c "/home/alec/repos/unholy-jakt/include/dc.h" {}
class DC {
public width: i64
public height: i64
context: usize
public function blot(this, dc: DC, x: i64, y: i64) {
unsafe {
cpp {
"dc_blot(dc->context, x, y, this->context);"
}
}
}
public function copy(this, dc: DC, x: i64, y: i64) {
unsafe {
cpp {
"dc_copy(dc->context, x, y, this->context);"
}
}
}
public function create_rect(width: i64, height: i64) throws -> DC {
mut dc = DC(width: width, height: height, context: 0);
dc.init()
return dc
}
public function fill(this, color: i64) {
unsafe {
cpp {
"dc_fill(this->context, color);"
}
}
}
public function gr_dc_alias() throws -> DC {
mut dc = DC(width: 0, height: 0, context: 0);
unsafe {
cpp {
"dc->context = dc_gr_dc_alias(&dc->width, &dc->height);"
}
}
return dc
}
public function init(mut this) {
unsafe {
cpp {
"this->context = dc_new(this->width, this->height);"
}
}
}
public function integer_scale(mut this, scale_factor: i64) {
unsafe {
cpp {
"this->context = dc_integer_scale(this->context, scale_factor, &this->width, &this->height);"
}
}
}
public function load_from_file(filename: String) throws -> DC {
mut dc = DC(width: 0, height: 0, context: 0);
unsafe {
cpp {
"dc->context = dc_load_from_file(filename.c_string(), &dc->width, &dc->height);"
}
}
return dc
}
public function replace_color(this, from: i64, to: i64) {
unsafe {
cpp {
"dc_replace_color(this->context, from, to);"
}
}
}
}