From 963c729bcdc1e5f82890f96bc55f1532f6eaf763 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 5 Jun 2022 16:17:11 +0200 Subject: thing --- src/transform.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/transform.rs (limited to 'src/transform.rs') 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, + 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); +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) + } +} -- cgit v1.2.3-70-g09d2