1 #include "core/lua-int.hpp"
2 #include "core/render.hpp"
6 struct render_object_rectangle
: public render_object
8 render_object_rectangle(int32_t _x
, int32_t _y
, uint32_t _width
, uint32_t _height
,
9 premultiplied_color _outline
, premultiplied_color _fill
, uint32_t _thickness
) throw()
10 : x(_x
), y(_y
), width(_width
), height(_height
), outline(_outline
), fill(_fill
),
11 thickness(_thickness
) {}
12 ~render_object_rectangle() throw() {}
13 void operator()(struct screen
& scr
) throw()
15 outline
.set_palette(scr
);
16 fill
.set_palette(scr
);
20 int32_t ymax
= height
;
21 clip_range(scr
.originx
, scr
.width
, x
, xmin
, xmax
);
22 clip_range(scr
.originy
, scr
.height
, y
, ymin
, ymax
);
23 for(int32_t r
= ymin
; r
< ymax
; r
++) {
24 uint32_t* rptr
= scr
.rowptr(y
+ r
+ scr
.originy
);
25 size_t eptr
= x
+ xmin
+ scr
.originx
;
26 for(int32_t c
= xmin
; c
< xmax
; c
++, eptr
++)
27 if(r
< thickness
|| c
< thickness
|| r
>= height
- thickness
||
28 c
>= width
- thickness
)
29 outline
.apply(rptr
[eptr
]);
31 fill
.apply(rptr
[eptr
]);
39 premultiplied_color outline
;
40 premultiplied_color fill
;
44 function_ptr_luafun
gui_rectangle("gui.rectangle", [](lua_State
* LS
, const std::string
& fname
) -> int {
47 int64_t outline
= 0xFFFFFFU
;
49 uint32_t thickness
= 1;
50 int32_t x
= get_numeric_argument
<int32_t>(LS
, 1, fname
.c_str());
51 int32_t y
= get_numeric_argument
<int32_t>(LS
, 2, fname
.c_str());
52 uint32_t width
= get_numeric_argument
<uint32_t>(LS
, 3, fname
.c_str());
53 uint32_t height
= get_numeric_argument
<uint32_t>(LS
, 4, fname
.c_str());
54 get_numeric_argument
<uint32_t>(LS
, 5, thickness
, fname
.c_str());
55 get_numeric_argument
<int64_t>(LS
, 6, outline
, fname
.c_str());
56 get_numeric_argument
<int64_t>(LS
, 7, fill
, fname
.c_str());
57 premultiplied_color
poutline(outline
);
58 premultiplied_color
pfill(fill
);
59 lua_render_ctx
->queue
->add(*new render_object_rectangle(x
, y
, width
, height
, poutline
, pfill
,