-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
3 changed files
with
33 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,44 @@ | ||
from chafa import * | ||
|
||
config = CanvasConfig() | ||
def test_raw(): | ||
config = CanvasConfig() | ||
|
||
config.width = 36 | ||
config.height = (256 - (16+24)) // 36 + 2 | ||
config.width = 36 | ||
config.height = (256 - (16+24)) // 36 + 2 | ||
|
||
|
||
config.canvas_mode = CanvasMode.CHAFA_CANVAS_MODE_INDEXED_256 | ||
config.canvas_mode = CanvasMode.CHAFA_CANVAS_MODE_INDEXED_256 | ||
|
||
pixels = [0, 0, 0, 0] | ||
pixels = [0, 0, 0, 0] | ||
|
||
canvas = Canvas(config) | ||
canvas.draw_all_pixels( | ||
PixelType.CHAFA_PIXEL_RGBA8_PREMULTIPLIED, | ||
pixels, | ||
1, 1, 3 | ||
) | ||
canvas = Canvas(config) | ||
canvas.draw_all_pixels( | ||
PixelType.CHAFA_PIXEL_RGBA8_PREMULTIPLIED, | ||
pixels, | ||
1, 1, 3 | ||
) | ||
|
||
|
||
for row in canvas[:]: | ||
for pix in row: | ||
pix.char = "▀" | ||
pix.remove_foreground() | ||
for row in canvas[:]: | ||
for pix in row: | ||
pix.char = "▀" | ||
pix.remove_foreground() | ||
|
||
|
||
for pix in canvas[0,:16]: | ||
pix.raw_fg_color = pix.x | ||
for pix in canvas[0,:16]: | ||
pix.raw_fg_color = pix.x | ||
|
||
for row in canvas[1:-1, :]: | ||
for pix in row: | ||
pix.raw_fg_color = pix.x + 16 + ((pix.y-1) * 5 * config.width//5) | ||
for row in canvas[1:-1, :]: | ||
for pix in row: | ||
pix.raw_fg_color = pix.x + 16 + ((pix.y-1) * 5 * config.width//5) | ||
|
||
for pix in canvas[-1, :24]: | ||
pix.raw_fg_color = 255 - (23 - pix.x) | ||
for pix in canvas[-1, :24]: | ||
pix.raw_fg_color = 255 - (23 - pix.x) | ||
|
||
i = 0 | ||
for pix in canvas[-1, -5:-1]: | ||
pix.char = str(i) | ||
i+=1 | ||
pix.raw_fg_color = 3 | ||
i = 0 | ||
for pix in canvas[-1, -5:-1]: | ||
pix.char = str(i) | ||
i+=1 | ||
pix.raw_fg_color = 3 | ||
|
||
print(canvas.print().decode()) | ||
print(canvas.print().decode()) |