diff --git a/.gitignore b/.gitignore
index 4bddc8e..9e8addb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,10 @@
-**/target
-**/*.rs.bk
-**/.cargo/*
-**/Cargo.lock
+# .cargo/*
+
+*.rs.bk
+Cargo.lock
+wasm-pack.log
+
+target/
+bin/
+pkg/
+wasm-pack/
diff --git a/tutorial/wasm-game-of-life/Cargo.toml b/Cargo.toml
similarity index 100%
rename from tutorial/wasm-game-of-life/Cargo.toml
rename to Cargo.toml
diff --git a/README.md b/README.md
index b3d59bc..2dab778 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,72 @@
+
+
+## About
+
+[**📚 Read this template tutorial! 📚**][template-docs]
+
+This template is designed for compiling Rust libraries into WebAssembly and
+publishing the resulting package to NPM.
+
+Be sure to check out [other `wasm-pack` tutorials online][tutorials] for other
+templates and usages of `wasm-pack`.
+
+[tutorials]: https://rustwasm.github.io/docs/wasm-pack/tutorials/index.html
+[template-docs]: https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html
+
+## 🚴 Usage
+
+### 🐑 Use `cargo generate` to Clone this Template
+
+[Learn more about `cargo generate` here.](https://github.com/ashleygwilliams/cargo-generate)
+
+```
+cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project
+cd my-project
+```
+
+### 🛠️ Build with `wasm-pack build`
+
+```
+wasm-pack build
+```
+
+### 🔬 Test in Headless Browsers with `wasm-pack test`
+
+```
+wasm-pack test --headless --firefox
+```
+
+### 🎁 Publish to NPM with `wasm-pack publish`
+
+```
+wasm-pack publish
+```
+
+## 🔋 Batteries Included
+
+* [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating
+ between WebAssembly and JavaScript.
+* [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook)
+ for logging panic messages to the developer console.
+* [`wee_alloc`](https://github.com/rustwasm/wee_alloc), an allocator optimized
+ for small code size.
# Rust playground
Things I have recently done while learning the Rust programming language.
diff --git a/branches/Cargo.lock b/branches/Cargo.lock
deleted file mode 100644
index 4ca0c2d..0000000
--- a/branches/Cargo.lock
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-[[package]]
-name = "branches"
-version = "0.1.0"
-
diff --git a/branches/Cargo.toml b/branches/Cargo.toml
deleted file mode 100644
index 55d1a68..0000000
--- a/branches/Cargo.toml
+++ /dev/null
@@ -1,9 +0,0 @@
-[package]
-name = "branches"
-version = "0.1.0"
-authors = ["Georg Hopp "]
-edition = "2018"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
diff --git a/branches/src/main.rs b/branches/src/main.rs
deleted file mode 100644
index a654126..0000000
--- a/branches/src/main.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-//
-// Control Flow Examples
-//
-// Georg Hopp
-//
-// Copyright © 2019 Georg Hopp
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-//
-
-fn main() {
- let condition = true;
- let number = if condition {
- 5
- } else {
- 6
- };
-
- println!("The value of number is: {}", number);
-}
diff --git a/fractional/.swp b/fractional/.swp
deleted file mode 100644
index 78dff2c..0000000
Binary files a/fractional/.swp and /dev/null differ
diff --git a/fractional/Cargo.toml b/fractional/Cargo.toml
deleted file mode 100644
index d1ca54c..0000000
--- a/fractional/Cargo.toml
+++ /dev/null
@@ -1,12 +0,0 @@
-[package]
-name = "fractional"
-version = "0.1.0"
-authors = ["Georg Hopp "]
-edition = "2018"
-
-[dependencies]
-lazy_static = "1.4.0"
-libc = "0.2"
-gl = "0.5.2"
-x11 = { version = "2.3", features = ["glx"] }
-xcb = { version = "0.8", features = ["dri2", "randr", "thread", "xlib_xcb", "shm"] }
diff --git a/fractional/notes/09e-textures.pdf b/fractional/notes/09e-textures.pdf
deleted file mode 100644
index b3a1c9b..0000000
Binary files a/fractional/notes/09e-textures.pdf and /dev/null differ
diff --git a/fractional/notes/frontier-map.url b/fractional/notes/frontier-map.url
deleted file mode 100644
index 9c74fc2..0000000
--- a/fractional/notes/frontier-map.url
+++ /dev/null
@@ -1 +0,0 @@
-http://www.jongware.com/galaxy1.html
diff --git a/fractional/notes/html5 b/fractional/notes/html5
deleted file mode 100644
index b2cb4e1..0000000
--- a/fractional/notes/html5
+++ /dev/null
@@ -1,7 +0,0 @@
-I really would like to see a HTML5 canvas as canvas for the 3D code.
-
-Some URLs:
-- https://stackoverflow.com/questions/42806037/modify-canvas-from-wasm
-- https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.HtmlCanvasElement.html
-- https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.CanvasRenderingContext2d.html
-- https://stackoverflow.com/questions/49935207/editing-canvas-pixel-data-in-webassembly-rust
diff --git a/fractional/notes/math.url b/fractional/notes/math.url
deleted file mode 100644
index b2b55d3..0000000
--- a/fractional/notes/math.url
+++ /dev/null
@@ -1 +0,0 @@
-https://www.themathpage.com/Alg/reciprocals.htm
diff --git a/fractional/notes/polyhedra.pdf b/fractional/notes/polyhedra.pdf
deleted file mode 100644
index 92e1eef..0000000
Binary files a/fractional/notes/polyhedra.pdf and /dev/null differ
diff --git a/fractional/notes/texmap.pdf b/fractional/notes/texmap.pdf
deleted file mode 100644
index 82fe327..0000000
Binary files a/fractional/notes/texmap.pdf and /dev/null differ
diff --git a/fractional/notes/texture-mapping.url b/fractional/notes/texture-mapping.url
deleted file mode 100644
index 88914ef..0000000
--- a/fractional/notes/texture-mapping.url
+++ /dev/null
@@ -1,15 +0,0 @@
-https://en.wikipedia.org/wiki/Texture_mapping
-http://www.gamers.org/dEngine/quake/papers/checker_texmap.html
-https://www.cs.uic.edu/~jbell/CourseNotes/ComputerGraphics/TextureMapping.html
-http://www.decew.net/OSS/References/chapter_2_texture_mapping.pdf
-
-# example affine texture mapping
-http://archive.gamedev.net/archive/reference/articles/article852.html
-
-
-http://www.lysator.liu.se/~mikaelk/doc/perspectivetexture/
-
-# Shader... This also describes z-Buffer... :)
-https://people.ece.cornell.edu/land/OldStudentProjects/cs490-95to96/GUO/report.html
-https://software.intel.com/en-us/articles/the-basics-of-the-art-of-lighting-part-3-lighting-and-shaders/
-https://docs.unity3d.com/Manual/Lighting.html
diff --git a/fractional/src/continuous.rs b/fractional/src/continuous.rs
deleted file mode 100644
index 673410a..0000000
--- a/fractional/src/continuous.rs
+++ /dev/null
@@ -1,115 +0,0 @@
-//
-// A «continued fraction» is a representation of a fraction as a vector
-// of integrals… Irrational fractions will result in infinite most of the
-// time repetitive vectors. They can be used to get a resonable approximation
-// for sqrt on fractionals.
-//
-// Georg Hopp
-//
-// Copyright © 2019 Georg Hopp
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-//
-use crate::Fractional;
-
-#[derive(Debug)]
-pub struct Continuous (Vec);
-
-impl Continuous {
- // calculate a sqrt as continued fraction sequence. Taken from:
- // https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#
- // Continued_fraction_expansion
- pub fn sqrt(x :i64, a0 :i64) -> Self {
- fn inner(v :&mut [i64], x :i64, a0 :i64, mn :i64, dn :i64, an :i64) {
- let mn_1 = dn * an - mn;
- let dn_1 = (x - mn_1 * mn_1) / dn;
- let an_1 = (a0 + mn_1) / dn_1;
-
- v[0] = an;
- // The convergence criteria „an_1 == 2 * a0“ is not good for
- // very small x thus I decided to break the iteration at constant
- // time. Which is the 5 below.
- if v.len() > 1 {
- inner(&mut v[1..], x, a0, mn_1, dn_1, an_1);
- }
- }
-
- let mut v :Vec = vec!(0; 5);
- inner(&mut v, x, a0, 0, 1, a0);
- Continuous(v)
- }
-
- // general continous fraction form of a fractional...
- pub fn from_prec(f :&Fractional, prec :Option) -> Self {
- fn inner(v :&mut Vec, f :Fractional, prec :Option) {
- let mut process = |prec :Option| {
- let Fractional(n, d) = f;
- let a = n / d;
- let Fractional(_n, _d) = f.noreduce_sub(a.into());
-
- v.push(a);
- match _n {
- 1 => v.push(_d),
- 0 => {},
- _ => inner(v, Fractional(_d, _n), prec),
- }
- };
-
- match prec {
- Some(0) => {},
- None => process(None),
- Some(p) => process(Some(p - 1)),
- }
- }
-
- let mut v = match prec {
- None => Vec::with_capacity(100),
- Some(p) => Vec::with_capacity(p + 1),
- };
-
- inner(&mut v, *f, prec);
- Continuous(v)
- }
-
- pub fn into_prec(&self, prec :Option) -> Fractional {
- let Continuous(c) = self;
- let p = match prec {
- Some(p) => if p <= c.len() { p } else { c.len() },
- None => c.len(),
- };
-
- let to_frac = |acc :Fractional, x :&i64| {
- let Fractional(an, ad) = acc.noreduce_add((*x).into());
- Fractional(ad, an)
- };
-
- let Fractional(n, d) = c[..p]
- . into_iter()
- . rev()
- . fold(Fractional(0, 1), to_frac);
- Fractional(d, n)
- }
-}
-
-impl From<&Fractional> for Continuous {
- fn from(x :&Fractional) -> Self {
- Self::from_prec(x, None)
- }
-}
-
-impl Into for &Continuous {
- fn into(self) -> Fractional {
- (&self).into_prec(None)
- }
-}
diff --git a/fractional/src/fractional.rs b/fractional/src/fractional.rs
deleted file mode 100644
index 0f8376d..0000000
--- a/fractional/src/fractional.rs
+++ /dev/null
@@ -1,252 +0,0 @@
-//
-// Some code to support fractional numbers for full precision rational number
-// calculations. (At least for the standard operations.)
-// This also implements a sqrt on fractional numbers, which can not be precise
-// because of the irrational nature of most sqare roots.
-// Fractions can only represent rational numbers precise.
-//
-// Georg Hopp
-//
-// Copyright © 2019 Georg Hopp
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-//
-use std::cmp::Ordering;
-use std::convert::{TryFrom, TryInto};
-use std::fmt::{Formatter, Display};
-use std::num::TryFromIntError;
-use std::ops::{Add,Sub,Neg,Mul,Div};
-
-use crate::continuous::Continuous;
-
-#[derive(Debug, Eq, Clone, Copy)]
-pub struct Fractional (pub i64, pub i64);
-
-#[inline]
-fn hcf(x :i64, y :i64) -> i64 {
- match y {
- 0 => x,
- _ => hcf(y, x % y),
- }
-}
-
-pub fn from_vector(xs: &Vec) -> Vec {
- xs.iter().map(|x| Fractional(*x, 1)).collect()
-}
-
-impl Fractional {
- #[inline]
- pub fn gcd(self, other: Self) -> i64 {
- let Fractional(_, d1) = self;
- let Fractional(_, d2) = other;
- (d1 * d2) / hcf(d1, d2)
- }
-
- #[inline]
- pub fn reduce(self) -> Self {
- let Fractional(n, d) = self;
- let (_n, _d) = if n > d { (n, d) } else { (d, n) };
-
- // if the difference from _n % _d to _n is very big we are close to
- // a whole number and can ignore the fractional part... this reduces
- // the precision but ensures smaller numbers for numerator and
- // denominator.
- if _d > 1 && (_n % _d) * 10000000 < _n {
- if n == _n {
- Self(_n / _d, 1)
- } else {
- Self(1, _n / _d)
- }
- } else {
- // Self(n / hcf(n, d), d / hcf(n, d))
- // The above reduces prcisely but results in very large numerator
- // or denominator occasionally. The below is less precise but
- // keeps the numbers small… the bad point is, that it is not very
- // fast.
- let cont = Continuous::from_prec(&self, Some(5));
- (&cont).into()
- }
- }
-
- pub fn noreduce_add(self, other: Self) -> Self {
- let Fractional(n1, d1) = self;
- let Fractional(n2, d2) = other;
- let n = n1 * (self.gcd(other) / d1) + n2 * (self.gcd(other) / d2);
- Self(n, self.gcd(other))
- }
-
- pub fn noreduce_sub(self, other: Self) -> Self {
- self.noreduce_add(other.noreduce_neg())
- }
-
- pub fn noreduce_neg(self) -> Self {
- let Fractional(n, d) = self;
- Self(-n, d)
- }
-}
-
-impl From for Fractional {
- fn from(x: i64) -> Self {
- Self(x, 1)
- }
-}
-
-impl From for Fractional {
- fn from(x: i32) -> Self {
- Self(x as i64, 1)
- }
-}
-
-impl TryFrom for Fractional {
- type Error = &'static str;
-
- fn try_from(x: usize) -> Result {
- let v = i64::try_from(x);
- match v {
- Err(_) => Err("Conversion from usize to i32 failed"),
- Ok(_v) => Ok(Self(_v, 1)),
- }
- }
-}
-
-impl TryInto for Fractional {
- type Error = TryFromIntError;
-
- fn try_into(self) -> Result {
- let n :i32 = self.0.try_into()?;
- let d :i32 = self.1.try_into()?;
- Ok(f64::from(n) / f64::from(d))
- }
-}
-
-impl TryInto<(i32, i32)> for Fractional {
- type Error = TryFromIntError;
-
- fn try_into(self) -> Result<(i32, i32), Self::Error> {
- let a :i32 = (self.0 / self.1).try_into()?;
- let b :i32 = (self.0 % self.1).try_into()?;
- Ok((a, b))
- }
-}
-
-impl Display for Fractional {
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
- write!(f, "({}/{})", self.0, self.1)
- }
-}
-
-impl PartialEq for Fractional {
- fn eq(&self, other: &Self) -> bool {
- let Fractional(n1, d1) = self;
- let Fractional(n2, d2) = other;
- n1 * (self.gcd(*other) / d1) == n2 * (self.gcd(*other) / d2)
- }
-}
-
-impl PartialOrd for Fractional {
- fn partial_cmp(&self, other: &Self) -> Option {
- Some(self.cmp(other))
- }
-}
-
-impl Ord for Fractional {
- fn cmp(&self, other: &Self) -> Ordering {
- let Fractional(n1, d1) = self;
- let Fractional(n2, d2) = other;
- let x = n1 * (self.gcd(*other) / d1);
- let y = n2 * (self.gcd(*other) / d2);
- x.cmp(&y)
- }
-}
-
-impl Add for Fractional {
- type Output = Self;
-
- fn add(self, other: Self) -> Self {
- self.noreduce_add(other).reduce()
- }
-}
-
-impl Sub for Fractional {
- type Output = Self;
-
- fn sub(self, other: Self) -> Self {
- self + -other
- }
-}
-
-impl Neg for Fractional {
- type Output = Self;
-
- fn neg(self) -> Self {
- let Fractional(n, d) = self;
- Self(-n, d)
- }
-}
-
-impl Mul for Fractional {
- type Output = Self;
-
- fn mul(self, other :Self) -> Self {
- let Fractional(n1, d1) = self;
- let Fractional(n2, d2) = other;
- Self(n1 * n2, d1 * d2).reduce()
- }
-}
-
-impl Div for Fractional {
- type Output = Self;
-
- fn div(self, other: Self) -> Self {
- let Fractional(n, d) = other;
- self * Fractional(d, n)
- }
-}
-
- /* some stuff that could be tested...
- let x = Fractional(1, 3);
- let y = Fractional(1, 6);
-
- println!(
- "Greatest common denominator of {} and {}: {}", x, y, x.gcd(y));
- println!("Numerator of {}: {}", x, x.numerator());
- println!("Denominator of {}: {}", x, x.denominator());
- assert_eq!(Fractional(1, 3), Fractional(2, 6));
- assert_eq!(Fractional(1, 3), Fractional(1, 3));
- assert_eq!(y < x, true);
- assert_eq!(y > x, false);
- assert_eq!(x == y, false);
- assert_eq!(x == x, true);
- assert_eq!(x + y, Fractional(1, 2));
- println!("{} + {} = {}", x, y, x + y);
- assert_eq!(x - y, Fractional(1, 6));
- println!("{} - {} = {}", x, y, x - y);
- assert_eq!(y - x, Fractional(-1, 6));
- println!("{} - {} = {}", y, x, y - x);
- assert_eq!(-x, Fractional(-1, 3));
- println!("-{} = {}", x, -x);
- assert_eq!(x * y, Fractional(1, 18));
- println!("{} * {} = {}", x, y, x * y);
- assert_eq!(x / y, Fractional(2, 1));
- println!("{} / {} = {}", x, y, x / y);
- assert_eq!(y / x, Fractional(1, 2));
- println!("{} / {} = {}", y, x, y / x);
-
- println!("Fractional from 3: {}", Fractional::from(3));
- let z :f64 = Fractional::into(x);
- println!("Floating point of {}: {}", x, z);
- let (d, r) = Fractional::into(x);
- println!("(div, rest) of {}: ({}, {})", x, d, r);
- */
-
diff --git a/fractional/src/geometry.rs b/fractional/src/geometry.rs
deleted file mode 100644
index f4c38ec..0000000
--- a/fractional/src/geometry.rs
+++ /dev/null
@@ -1,376 +0,0 @@
-//
-// Basic geometric things...
-//
-// Georg Hopp
-//
-// Copyright © 2019 Georg Hopp
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-//
-use std::convert::{From, Into};
-use std::ops::{Add,Sub,Neg,Mul,Div};
-use std::fmt::Debug;
-
-use crate::easel::{Canvas, Coordinate, Coordinates, Polygon};
-use crate::transform::{TMatrix, Transformable};
-use crate::trigonometry::Trig;
-use crate::vector::Vector;
-
-#[derive(Debug, Clone)]
-pub struct Face
-where T: Add + Sub + Neg + Mul + Div + Copy + Trig {
- corners :Vec,
- normal :Option>,
-}
-
-#[derive(Debug, PartialEq, Eq, Clone, Copy)]
-pub struct Point(pub Vector, T)
- where T: Add + Sub + Neg + Mul + Div + PartialEq + Copy + Trig;
-
-impl Point
-where T: Add