63 lines
No EOL
1.2 KiB
Text
63 lines
No EOL
1.2 KiB
Text
import "luxe: world" for World
|
|
import "luxe: draw" for Draw, PathStyle
|
|
import "luxe: io" for IO
|
|
|
|
class DrawDebug{
|
|
static Context{ __context }
|
|
|
|
static setup(world){
|
|
__context = Draw.create(World.render_set(world))
|
|
}
|
|
|
|
static commit(){
|
|
Draw.commit(__context)
|
|
}
|
|
|
|
static rect(r){
|
|
rect(r.x, r.y, r.width, r.height)
|
|
}
|
|
|
|
static rect(r, color){
|
|
rect(r.x, r.y, r.width, r.height, color)
|
|
}
|
|
|
|
static rect(x, y, w, h){
|
|
rect(x, y, w, h, [1, 0, 0, 1])
|
|
}
|
|
|
|
static rect_centered(x, y, w, h, col){
|
|
rect(x - w/2, y - h/2, w, h, col)
|
|
}
|
|
|
|
static rect(x, y, w, h, col){
|
|
var style = PathStyle.new()
|
|
style.color = col
|
|
Draw.rect(__context, x, y, 0, w, h, 0, style)
|
|
}
|
|
|
|
static line(v0, v1){
|
|
line(v0.x, v0.y, v1.x, v1.y)
|
|
}
|
|
|
|
static line(x0, y0, x1, y1){
|
|
line(x0, y0, x1, y1, [1, 0, 0, 1])
|
|
}
|
|
|
|
static line(x0, y0, x1, y1, col){
|
|
var style = PathStyle.new()
|
|
style.color = col
|
|
Draw.line(__context, x0, y0, x1, y1, 0, style)
|
|
}
|
|
}
|
|
|
|
|
|
class Holder{
|
|
static x{
|
|
System.print("%(__value) was taken from me")
|
|
return __value
|
|
}
|
|
static x=(val){
|
|
System.print("I was given %(val)")
|
|
__value = val
|
|
}
|
|
} |