Add GCD grid example

This commit is contained in:
Dimitri Lozeve 2023-03-18 18:43:54 +01:00
parent 1496a0fd12
commit 9551806b17
4 changed files with 15 additions and 1 deletions

View file

@ -22,6 +22,8 @@ cd examples
make all
#+end_src
[[./examples/gcdgrid.png]]
[[./examples/hsv.png]]
[[./examples/gradient.png]]

View file

@ -1,5 +1,5 @@
.PHONY: all
all: checkers.png random_pbm.png random_pgm.png random_ppm.png gradient.png hsv.png
all: checkers.png random_pbm.png random_pgm.png random_ppm.png gradient.png hsv.png gcdgrid.png
%.pnm: %.bqn
bqn $< > $@

12
examples/gcdgrid.bqn Normal file
View file

@ -0,0 +1,12 @@
bqngraphics"../"
Viridis•Import bqngraphics"colormaps.bqn"
HSVtoRGB•Import bqngraphics"colors.bqn"
PBM,PGM,PPM•Import bqngraphics"pnm.bqn"
# https://susam.net/blog/gcd-grid.html
GCDGrid•math.GCD˜
•Out PBM 1GCDGrid 50
#•Out PGM GCDGrid 20
#•Out PPM {⌊255×HSVtoRGB⎉1⍉(360×𝕩÷1+⌈˝𝕩)∾(2∾≢𝕩)⥊1}GCDGrid 20
#•Out PPM ⌊255×> Viridis¨ (⊢÷⌈´∘⥊) GCDGrid 20

BIN
examples/gcdgrid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B