Initial commit

This commit is contained in:
b12f 2024-08-17 20:20:42 +02:00
commit 070e71d28e
Signed by: b12f
GPG key ID: 729956E1124F8F26
6 changed files with 2971 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
target
core

2801
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

8
Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "mezza-rs"
version = "0.1.0"
edition = "2021"
[dependencies]
nannou = "0.19"
noise = "0.9.0"

58
flake.lock Normal file
View file

@ -0,0 +1,58 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1722555600,
"narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "8471fe90ad337a8074e957b69ca4d0089218391d",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1723688146,
"narHash": "sha256-sqLwJcHYeWLOeP/XoLwAtYjr01TISlkOfz+NG82pbdg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "c3d4ac725177c030b1e289015989da2ad9d56af0",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1722555339,
"narHash": "sha256-uFf2QeW7eAHlYXuDktm9c25OxOyCoUOQmh5SZ9amE5Q=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

43
flake.nix Normal file
View file

@ -0,0 +1,43 @@
{
description = "evoke";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs@{ self, ... }:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.flake-parts.flakeModules.easyOverlay
];
systems = [ "x86_64-linux" ];
perSystem = {
system,
pkgs,
config,
...
}:
{
devShells.default = pkgs.mkShell rec {
buildInputs = [
pkgs.libxkbcommon
pkgs.vulkan-loader
pkgs.wayland
];
packages = [
pkgs.cargo
pkgs.clippy
pkgs.gcc
];
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}";
RUST_BACKTRACE = "true";
};
};
};
}

59
src/main.rs Normal file
View file

@ -0,0 +1,59 @@
use std::io::*;
use nannou::prelude::*;
use noise::{NoiseFn, Perlin, Seedable};
const BLACK: (f64, f64, f64) = (26.0 / 255.0, 24.0 / 255.0, 26.0 / 255.0);
const WHITE: (f64, f64, f64) = (229.0 / 255.0, 196.0 / 255.0, 99.0 / 255.0);
const X_SCALE: f64 = 0.015;
const Y_SCALE: f64 = 0.02;
const GRID_SIZE: f64 = 20.0;
fn main() {
nannou::app(model)
.update(update)
.simple_window(view)
.run();
}
struct Model {
perlin: Perlin,
ticks: f64,
}
fn model(_app: &App) -> Model {
Model {
perlin: Perlin::new(1),
ticks: 0.0,
}
}
fn update(_app: &App, _model: &mut Model, _update: Update) {
_model.ticks = _model.ticks + 1.0;
}
fn view(_app: &App, _model: &Model, frame: Frame){
let black = Rgb::from_components(BLACK);
let white = Rgb::from_components(WHITE);
frame.clear(black);
let draw = _app.draw();
let count = _model.ticks / 10.0;
let rect = _app.window_rect();
let w = <f64 as From<f32>>::from(rect.w());
let h = <f64 as From<f32>>::from(rect.h());
let mut x = -0.5 * w;
while x < 0.5 * w {
x += GRID_SIZE;
let mut y = -0.5 * h;
while y < 0.5 * h {
y += GRID_SIZE;
let noise_value = ((_model.perlin.get([(x * X_SCALE) + count, (y * Y_SCALE) + count, count]) + 1.0) / 2.0) as f32;
draw.rect()
.color(white)
.x_y(x as f32, y as f32)
.w(GRID_SIZE as f32 * noise_value)
.h(GRID_SIZE as f32 * noise_value);
}
}
draw.to_frame(_app, &frame).unwrap();
}