Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
GuardKenzie committed Feb 11, 2023
2 parents ead448b + 466a302 commit 1dfc763
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
4 changes: 2 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- [x] Peeking at config
- [x] inspect characters at (x, y)
- [x] inspect color at (x, y)
- [ ] raw color
- [x] raw color
- [x] **DOCS**
- [x] What argument type should `draw_pixels` accept for the pixel array? <- This is pretty much done
1. array (pretty fast)
Expand Down Expand Up @@ -72,6 +72,6 @@

- [x] Docs for the loader

- [ ] Write a tutorial
- [x] Write a tutorial
- [x] Add some examples
- [x] Installation
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "chafa.py"
version = "1.0.2"
version = "1.1.0"
license = "LGPL-3.0"

authors = [
Expand Down Expand Up @@ -95,7 +95,7 @@ test-command = "MAGICK_HOME=/opt/homebrew/Cellar/imagemagick pytest -rP {package

[tool.cibuildwheel.windows]

test-command = "pytest -rP {package}/tests/0_PIL_test.py"
test-command = "pytest -rP {package}/tests/0_PIL_test.py {package}/tests/2_raw_test.py {package}/tests/3_capabilities_test.py"

[tool.hatch.build]
exclude = [
Expand Down
57 changes: 29 additions & 28 deletions tests/2_raw_test.py
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())

0 comments on commit 1dfc763

Please sign in to comment.