I clearly don't know what I'm doing.
Go to sleep! Think, then type!
This commit is contained in:
parent
42068ebcb6
commit
2c6dc4fee5
|
|
@ -107,27 +107,30 @@ carefree_wu_line(u32* dest, size_t dest_stride, u64 x, u64 y, u64 w, u64 h, u32
|
|||
// > We translate the point (x0, y0) to the origin,
|
||||
// so y = kx where k = h/w with k <= 1
|
||||
u16 k = 0xFFFF * h / w;
|
||||
//print_i64(w); print_str(" x "); print_i64(h); print_endl();
|
||||
print_i64(k>>8); print_endl();
|
||||
u64 x1 = x + w;
|
||||
u64 y1 = y + h;
|
||||
u64 x1 = x + w - 1;
|
||||
u64 y1 = y + h - 1;
|
||||
u16 d = 0;
|
||||
while (x1 > x) {
|
||||
//print_i64(d); print_endl();
|
||||
if (d) {
|
||||
plot_pixel(dest, dest_stride, x, y, color, d >> 8);
|
||||
plot_pixel(dest, dest_stride, x1, y1, color, d >> 8);
|
||||
}
|
||||
plot_pixel(dest, dest_stride, x, y - 1, color, 0xFF - (d >> 8));
|
||||
plot_pixel(dest, dest_stride, x1, y1 - 1, color, 0xFF - (d >> 8));
|
||||
plot_pixel(dest, dest_stride, x, y + 1, color, d >> 8);
|
||||
plot_pixel(dest, dest_stride, x, y, color, 0xFF - (d >> 8));
|
||||
plot_pixel(dest, dest_stride, x1, y1, color, d >> 8);
|
||||
plot_pixel(dest, dest_stride, x1, y1 + 1, color, 0xFF - (d >> 8));
|
||||
++x;
|
||||
--x1;
|
||||
d = d + k;
|
||||
if (d > 0xFFFF) {
|
||||
x1 = x1 - 1; // "--x1" didn't work here, x1 remained unchanged.
|
||||
if (d + k >= 0xFFFF) {
|
||||
d = 0;
|
||||
// opposite (de-)increment because computer y is negative cartesian y
|
||||
++y;
|
||||
--y1;
|
||||
y1 = y1 - 1;
|
||||
} else {
|
||||
d = d + k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,8 @@ main()
|
|||
u64 h = 4 + 4 * font_Inconsolata_22_height;
|
||||
carefree_draw_box(frame_buffer, FRAME_WIDTH, 126, 126, w, h, WHITE);
|
||||
w = 200;
|
||||
for (w = 101; w < (FRAME_WIDTH - 10); w = w + 3) {
|
||||
//carefree_wu_line(frame_buffer, FRAME_WIDTH, 10, 256, 200, 100, WHITE);
|
||||
for (w = 101; w < (FRAME_WIDTH - 10); w = w + 50) {
|
||||
carefree_wu_line(frame_buffer, FRAME_WIDTH, 10, 256, w, 100, WHITE);
|
||||
}
|
||||
window_draw_frame(wid, frame_buffer);
|
||||
|
|
|
|||
Loading…
Reference in New Issue