From 6a5d511845ef27b377af120de399d6b4471cdd02 Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Mon, 11 Nov 2024 22:30:03 +0100 Subject: [PATCH] Convert README to markdown --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ README.org | 46 ---------------------------------------------- 2 files changed, 49 insertions(+), 46 deletions(-) create mode 100644 README.md delete mode 100644 README.org diff --git a/README.md b/README.md new file mode 100644 index 0000000..fec0dd1 --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ +# Minimal graphical applications in BQN + +Bindings for [Fenster](https://github.com/zserge/fenster), providing a +set of functions for displaying a window and setting the color of +individual pixels inside. + +## Setup + +Clone the repository recursively (`git clone --recurse-submodules`) +and run `make` to build the shared library. The Makefile should work +on Linux and macOS. + +## API + +High-level API: + +- `F _display width‿height` creates a window of the given dimensions + and displays its left operand. `F` should be a function returning a + color as an RGB triplet in the (0,1) range, and taking a list of two + elements `x‿y`, where `x` and `y` are the pixel coordinates. + +Low-level API: + +- `OpenWindow w‿h‿t` opens a window of width `w` and height `h`, with + title `t`. Returns a window handle. +- `CloseWindow w` closes a window given its handle `w`. +- `F _render w` runs the function `F` at each coordinate of the window + `w` and set the corresponding pixel color. `F` is a function with + the same arguments as for `_display`. + +## Example + +See [example.bqn](./example.bqn). + +```bqn +f←•Import"fenster.bqn" + +size←500 + +Rainbow←{𝕊x‿y: + x‿y↩x‿y÷size + h←(x+y)÷2 + f.HSVtoRGB⟨360×h,1,1⟩ +} + +Rainbow f._display size‿size +``` + +![img](./example.png) diff --git a/README.org b/README.org deleted file mode 100644 index b773813..0000000 --- a/README.org +++ /dev/null @@ -1,46 +0,0 @@ -* Minimal graphical applications in BQN - -Bindings for [[https://github.com/zserge/fenster][Fenster]], providing a set of functions for displaying a -window and setting the color of individual pixels inside. - -** Setup - -Clone the repository recursively (~git clone --recurse-submodules~) -and run ~make~ to build the shared library. The Makefile should work -on Linux and macOS. - -** API - -High-level API: -- ~F _display width‿height~ creates a window of the given dimensions - and displays its left operand. ~F~ should be a function returning a - color as an RGB triplet in the (0,1) range, and taking a list of two - elements ~x‿y~, where ~x~ and ~y~ are the pixel coordinates. - -Low-level API: -- ~OpenWindow w‿h‿t~ opens a window of width ~w~ and height ~h~, with - title ~t~. Returns a window handle. -- ~CloseWindow w~ closes a window given its handle ~w~. -- ~F _render w~ runs the function ~F~ at each coordinate of the window - ~w~ and set the corresponding pixel color. ~F~ is a function with - the same arguments as for ~_display~. - -** Example - -See [[./example.bqn][example.bqn]]. - -#+begin_src bqn -f←•Import"fenster.bqn" - -size←500 - -Rainbow←{𝕊x‿y: - x‿y↩x‿y÷size - h←(x+y)÷2 - f.HSVtoRGB⟨360×h,1,1⟩ -} - -Rainbow f._display size‿size -#+end_src - -[[./example.png]]