aboutsummaryrefslogtreecommitdiff
path: root/src/transform.rs
diff options
context:
space:
mode:
authormetamuffin <yvchraiqi@protonmail.com>2022-06-05 16:17:11 +0200
committermetamuffin <yvchraiqi@protonmail.com>2022-06-05 16:17:11 +0200
commit963c729bcdc1e5f82890f96bc55f1532f6eaf763 (patch)
tree07656d74aee13d075faba4cc13ca28e13dcb7c4a /src/transform.rs
parent1b70d7d654bef22661cf3184806175fcb17e1bd6 (diff)
downloadblubcat-963c729bcdc1e5f82890f96bc55f1532f6eaf763.tar
blubcat-963c729bcdc1e5f82890f96bc55f1532f6eaf763.tar.bz2
blubcat-963c729bcdc1e5f82890f96bc55f1532f6eaf763.tar.zst
thing
Diffstat (limited to 'src/transform.rs')
-rw-r--r--src/transform.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/transform.rs b/src/transform.rs
new file mode 100644
index 0000000..8b555d1
--- /dev/null
+++ b/src/transform.rs
@@ -0,0 +1,24 @@
+use crate::{color::Color, Sample};
+
+pub struct Matrix {
+ pub inner: Box<dyn Sample>,
+ pub matrix: ((f64, f64), (f64, f64)),
+}
+impl Sample for Matrix {
+ fn sample(&mut self, x: f64, y: f64) -> Color {
+ let (x, y) = (
+ x * self.matrix.0 .0 + y * self.matrix.0 .1,
+ x * self.matrix.1 .0 + y * self.matrix.1 .1,
+ );
+ self.inner.sample(x, y)
+ }
+}
+
+pub struct Polar(pub Box<dyn Sample>);
+impl Sample for Polar {
+ fn sample(&mut self, x: f64, y: f64) -> Color {
+ let ang = x.atan2(y);
+ let dist = (x * x + y * y).sqrt();
+ self.0.sample(ang, dist)
+ }
+}