Skip to content

Instantly share code, notes, and snippets.

View malleusinferni's full-sized avatar
🔥
Alive, probably

Mako malleusinferni

🔥
Alive, probably
View GitHub Profile
@malleusinferni
malleusinferni / main.rs
Created February 1, 2019 01:32
Cubemap generator
use cgmath::prelude::*;
use image::*;
use noise::*;
pub type Vec2d = cgmath::Vector2<f64>;
pub type Vec3d = cgmath::Vector3<f64>;
pub type Mat4d = cgmath::Matrix4<f64>;
use cgmath::{Vector2, Vector3, Vector4};
#[derive(Copy, Clone, Debug)]
pub struct Params {
pub offset: f32,
pub lacunarity: f32,
pub highest_dim: f32,
pub octaves: f32,
pub gain: f32,
}
[package]
name = "planet"
version = "0.0.1"
[dependencies]
sdl2 = "0.19"
sdl2_image = "0.19"
cgmath = "*"
rand = "*"
rayon = "*"
extern crate rand;
extern crate time;
use std::path::Path;
use std::iter::Peekable;
use std::slice;
struct Parser<'input> {
input: Peekable<slice::Iter<'input, u8>>,
line: usize,
extern crate sdl2;
extern crate sdl2_image;
use sdl2::rect::Rect;
use sdl2_image::SaveSurface;
fn main() {
let _sdl = sdl2::init().unwrap();
let _img_ctx = { use sdl2_image::*; init(INIT_PNG) }.unwrap();
use std::hash::Hash;
use std::sync::mpsc::{self, Sender, Receiver};
use std::collections::HashMap;
#[cfg(test)]
mod test {
#[test]
fn simple_network() {
use super::*;
use std::ffi::{OsString};
use std::path::{Path};
const MARKPATH_KEY: &'static str = "MARKPATH";
const COMPLETE_ARG: &'static str = "--complete";
///
/// Port of some zsh code that reads a directory full of symlinks
/// and prints their names, followed by their destinations
///
@malleusinferni
malleusinferni / ray.rs
Last active August 29, 2015 14:06
Rust idiom help
fn generate(format: PixelFormat) -> Vec<Tex> {
// Helper functions for wrangling colors
fn gray(val: u8) -> Color { RGB(val, val, val) }
fn red(val: u8, other: u8) -> Color { RGB(val, other, other) }
fn green(val: u8, other: u8) -> Color { RGB(other, val, other) }
fn blue(val: u8, other: u8) -> Color { RGB(other, other, val) }
fn scale_to_dim(val: int) -> u8 {
mix(0.0, 255.0, val as f64 / 64.0) as u8
}
fn xor_shade(x: int, y: int) -> u8 {
{-# LANGUAGE RecordWildCards #-}
data Species = Species
{ speciesName :: String
, minHeight :: Int
, maxHeight :: Int
} deriving (Eq, Show, Ord)
instance Tabular Species where
readRecord = do
#!/usr/bin/env python
from __future__ import print_function
# This program takes Homestuck pesterlog files (.page) in plain text,
# colorizes them, and renders them in other formats. By default, it
# outputs a PNG file, but BBCode and HTML output are also supported.
# Planned features:
# - HTML output with classes
# - CSS output in separate files or <style> tags