Add a readme and license
This commit is contained in:
parent
f15977009e
commit
3021529d92
3 changed files with 76 additions and 0 deletions
28
LICENSE
Normal file
28
LICENSE
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
BSD 3-Clause License
|
||||||
|
|
||||||
|
Copyright (c) 2024, Dimitri Lozeve
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of the copyright holder nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
48
README.org
Normal file
48
README.org
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
* 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
|
||||||
|
|
||||||
|
- ~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~ should be a function
|
||||||
|
returning a color as an RGB triplet in the (0,1) range, and taking a
|
||||||
|
list of three elements ~x‿y‿t~, where ~x~ and ~y~ are the pixel
|
||||||
|
coordinates and ~t~ is the time.
|
||||||
|
|
||||||
|
** Example
|
||||||
|
|
||||||
|
See [[./example.bqn][example.bqn]].
|
||||||
|
|
||||||
|
#+begin_src bqn
|
||||||
|
f←•Import "fenster.bqn"
|
||||||
|
|
||||||
|
size←500
|
||||||
|
|
||||||
|
w←f.OpenWindow size‿size‿"bqn-fenster example"
|
||||||
|
|
||||||
|
Rainbow←{𝕊x‿y‿t:
|
||||||
|
x‿y↩x‿y÷size
|
||||||
|
t↩(100|t)÷100
|
||||||
|
h←(x+y)÷2
|
||||||
|
f.HSVtoRGB⟨360×h,1,1⟩
|
||||||
|
}
|
||||||
|
|
||||||
|
Rainbow f._render w
|
||||||
|
|
||||||
|
•Delay 3
|
||||||
|
|
||||||
|
f.CloseWindow w
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
[[./example.png]]
|
BIN
example.png
Normal file
BIN
example.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 712 KiB |
Loading…
Add table
Add a link
Reference in a new issue