Skip to content

Instantly share code, notes, and snippets.

pub fn actual_structure_footprint(unit_type: UnitTypeId, footprint_radius: usize) -> (usize, usize) {
match unit_type {
// 2x1
UnitTypeId::MineralField
| UnitTypeId::MineralField450
| UnitTypeId::MineralField750
| UnitTypeId::LabMineralField
| UnitTypeId::LabMineralField750
| UnitTypeId::RichMineralField
| UnitTypeId::RichMineralField750 => (2, 1),
pub fn sdf_to_grayscale_image_downscaled(src: &SDFImage, max_expressable_dst: DstT, output_size: u32) -> Box<GrayImage>
{
let (width,height) = src.dimensions();
let (mult_x, mult_y) = (width / output_size, height / output_size);
let find_min = |x: u32, y: u32| -> DstT {
let mut result: f64 = 1.0;
let mut count = 0;
for i in 0..mult_x {
@swiftcoder
swiftcoder / kira_sin_wave.rs
Last active May 1, 2021 13:25
Simple sin wave synth example using Kira
use anyhow::Result;
use kira::{
audio_stream::AudioStream,
manager::{AudioManager, AudioManagerSettings},
mixer::TrackIndex,
Frame,
};
use std::time::Duration;
// the note A
extern crate proc_macro;
use proc_macro::TokenStream;
use syn::DeriveInput;
#[proc_macro_derive(ApproxEq)]
pub fn derive_approx_eq(input: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(input as DeriveInput);
let type_name = input.ident;
@swiftcoder
swiftcoder / main.rs
Last active November 10, 2019 02:28
winit toggle fullscreen example
fn main() {
use winit::{
event,
event_loop::{ControlFlow, EventLoop},
window::Fullscreen,
};
let event_loop = EventLoop::new();
let builder = winit::window::WindowBuilder::new();
let window = builder.build(&event_loop).unwrap();
@swiftcoder
swiftcoder / primitives.rs
Last active May 11, 2019 18:42
Recursive Icosphere subdivision in rust
extern crate cgmath;
use std::collections::BTreeMap;
use cgmath::Vector3;
struct Face {
pub indices: [usize; 3],
}

Keybase proof

I hereby claim:

  • I am swiftcoder on github.
  • I am swiftcoder (https://keybase.io/swiftcoder) on keybase.
  • I have a public key whose fingerprint is 7368 AE86 95A9 81BA 29C7 D1AB 4D3C 200C 0291 607E

To claim this, I am signing this object: