Add entry points for GPU

This commit is contained in:
2026-06-27 18:25:41 -04:00
parent 6671475c75
commit 44b71c2692
11 changed files with 202 additions and 104 deletions
+8 -5
View File
@@ -5,7 +5,7 @@
//! but produce more interesting images once we add variations.
use crate::variation::Variation;
use bytemuck::{Pod, Zeroable};
use glam::{Affine2, Vec2};
use glam::{Affine2, UVec2, Vec2};
use rand::Rng;
/// Affine transform for use in the [`chaos_game`](crate::chaos_game).
@@ -13,12 +13,12 @@ use rand::Rng;
#[repr(C)]
pub struct Transform {
coefficients: Affine2,
variation_range: [u16; 2],
variation_range: UVec2,
}
impl Transform {
/// Create a new transform from an affine transformation matrix
pub fn new(coefficients: Affine2, variation_range: [u16; 2]) -> Self {
pub fn new(coefficients: Affine2, variation_range: UVec2) -> Self {
Transform {
coefficients,
variation_range,
@@ -35,8 +35,11 @@ impl Transform {
let point = self.coefficients.transform_point2(point);
let mut point_output = Vec2::ZERO;
let variation_range = self.variation_range[0] as usize..self.variation_range[1] as usize;
for variation in variations[variation_range].iter() {
let variation_start = self.variation_range.x;
let variation_end = self.variation_range.y;
for variation_index in variation_start..variation_end {
let ref variation = variations[variation_index as usize];
point_output += variation.transform_point(point, rng, &self.coefficients)
}