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()
18 int32_t ymax
= height
;
19 clip_range(scr
.originx
, scr
.width
, x
, xmin
, xmax
);
20 clip_range(scr
.originy
, scr
.height
, y
, ymin
, ymax
);
21 for(int32_t r
= ymin
; r
< ymax
; r
++) {
22 uint32_t* rptr
= scr
.rowptr(y
+ r
+ scr
.originy
);
23 size_t eptr
= x
+ xmin
+ scr
.originx
;
24 for(int32_t c
= xmin
; c
< xmax
; c
++, eptr
++)
25 if(r
< thickness
|| c
< thickness
|| r
>= height
- thickness
||
26 c
>= width
- thickness
)
27 outline
.apply(rptr
[eptr
]);
29 fill
.apply(rptr
[eptr
]);
37 premultiplied_color outline
;
38 premultiplied_color fill
;
42 function_ptr_luafun
gui_rectangle("gui.rectangle", [](lua_State
* LS
, const std::string
& fname
) -> int {
45 int64_t outline
= 0xFFFFFFU
;
47 uint32_t thickness
= 1;
48 int32_t x
= get_numeric_argument
<int32_t>(LS
, 1, fname
.c_str());
49 int32_t y
= get_numeric_argument
<int32_t>(LS
, 2, fname
.c_str());
50 uint32_t width
= get_numeric_argument
<uint32_t>(LS
, 3, fname
.c_str());
51 uint32_t height
= get_numeric_argument
<uint32_t>(LS
, 4, fname
.c_str());
52 get_numeric_argument
<uint32_t>(LS
, 5, thickness
, fname
.c_str());
53 get_numeric_argument
<int64_t>(LS
, 6, outline
, fname
.c_str());
54 get_numeric_argument
<int64_t>(LS
, 7, fill
, fname
.c_str());
55 premultiplied_color
poutline(outline
);
56 premultiplied_color
pfill(fill
);
57 lua_render_ctx
->queue
->add(*new render_object_rectangle(x
, y
, width
, height
, poutline
, pfill
,