mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
box-drawing: {h,v}line(): handle both start/end point being too small *and* too large
This commit is contained in:
parent
a8496eef03
commit
bd42986a8b
1 changed files with 8 additions and 2 deletions
|
|
@ -24,8 +24,11 @@ thickness(float pts, int dpi)
|
|||
static void
|
||||
_hline(uint8_t *buf, int x1, int x2, int y, int thick, int width, int height, int stride)
|
||||
{
|
||||
x1 = min(max(x1, 0), width);
|
||||
x2 = min(max(x2, 0), width);
|
||||
|
||||
for (size_t row = max(y, 0); row < min(y + thick, height); row++) {
|
||||
for (size_t col = max(x1, 0); col < min(x2, width); col++) {
|
||||
for (size_t col = x1; col < x2; col++) {
|
||||
size_t idx = col / 8;
|
||||
size_t bit_no = col % 8;
|
||||
buf[row * stride + idx] |= 1 << bit_no;
|
||||
|
|
@ -38,7 +41,10 @@ _hline(uint8_t *buf, int x1, int x2, int y, int thick, int width, int height, in
|
|||
static void
|
||||
_vline(uint8_t *buf, int y1, int y2, int x, int thick, int width, int height, int stride)
|
||||
{
|
||||
for (size_t row = max(y1, 0); row < min(y2, height); row++) {
|
||||
y1 = min(max(y1, 0), height);
|
||||
y2 = min(max(y2, 0), height);
|
||||
|
||||
for (size_t row = y1; row < y2; row++) {
|
||||
for (size_t col = max(x, 0); col < min(x + thick, width); col++) {
|
||||
size_t idx = col / 8;
|
||||
size_t bit_no = col % 8;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue