Skip to content

Instantly share code, notes, and snippets.

View duskvirkus's full-sized avatar
🇺🇦
declare variables not war

Dusk duskvirkus

🇺🇦
declare variables not war
View GitHub Profile
@duskvirkus
duskvirkus / 10Print Javascript
Created March 29, 2019 02:00
10Print Generator for Default Terminal Size
let s = "";
for (let j = 0; j < 25; j++) {
for (let i = 0; i < 80; i++) {
Math.random() > 0.5 ? s += "/" : s += "\\";
}
s += "\n";
}
console.log(s);
@duskvirkus
duskvirkus / openframeworks_interesting_camera_movement.cpp
Created May 16, 2019 04:03
Some interesting accidental camera movement in openFrameworks.
// in ofApp.h
float angle;
float cameraDistance;
ofCamera camera;
// in setup
angle = 0;
cameraDistance = 100;
// function
@duskvirkus
duskvirkus / JarvisMarch.pde
Last active June 28, 2019 07:08
Jarvis March Algorithm, also known as gift wrapping. Coding in Processing / Java and inspired by thecodingtrain.com computational geomentry.
import java.util.*;
ArrayList<PVector> jarvisMarch(ArrayList<PVector> _input) throws InvalidJarvisInputException {
if (_input.size() < 3) throw new InvalidJarvisInputException("Input must have at least 3 PVectors in the list.");
ArrayList<PVector> output = new ArrayList<PVector>();
ArrayList<PVector> input = deepCopyArrayListPVector(_input);
Collections.sort(input, new leftSorter());
// Inital Truth Table Values
// By Fi Graham
// p5js sketch (editor.p5js.org)
// Sketch figuring out inital boolean values of a truth table.
function setup() {
createCanvas(windowWidth, windowHeight);
stroke(127);
}
@duskvirkus
duskvirkus / tasks.json
Last active July 25, 2019 22:11
Processing sketch with command line arguments for width and height. (Only tested on Linux)
// Visual Studio Code tasks.json for the sketch
// Uses Processing VS code extension (https://github.com/TobiahZ/processing-vscode)
// Width and Height are hard coded in this file for rapid prototyping.
// Ctrl + Shift + B to Run
{
"version": "2.0.0",
"tasks": [
{
"label": "All",
@duskvirkus
duskvirkus / app.js
Created November 18, 2019 06:44
simple pixi js sketch which adapts to the browser window's size
import * as PIXI from 'pixi.js';
import { setupSize, windowWidth, windowHeight } from './src/size';
import floppyImage from './assets/floppy.png';
// Globals
let app;
let canvas;
const canvasID = 'app-canvas';
let container;
@duskvirkus
duskvirkus / checkers.pde
Created November 20, 2019 02:52
Simple processing program to generate checker patterns.
int SIZE = 64;
int scale = 2;
void settings() {
size(SIZE, SIZE);
}
void setup() {
color c1 = color(255);
color c2 = color(0);
@duskvirkus
duskvirkus / proj-slash-cmake-slash-CMakeLists.txt
Created December 10, 2019 10:12
Cinder Sketch Starter, cmake is setup for project to be two levels below cinder root
cmake_minimum_required( VERSION 2.8 FATAL_ERROR )
set( CMAKE_VERBOSE_MAKEFILE ON )
project( Sketch )
get_filename_component( CINDER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../.." ABSOLUTE )
get_filename_component( APP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE )
include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" )
@duskvirkus
duskvirkus / Makefile
Created December 13, 2019 05:48
single c++ file makefile
CXX=g++
CXXFLAGS=-Wall -Wextra -Wpedantic -O3 -std=c++17 -Wfatal-errors -fno-diagnostics-show-option -Walloc-zero -Wold-style-cast -Wduplicated-branches -Wctor-dtor-privacy
main: main.o
$(CXX) $(CXXFLAGS) main.o -o main
main.o: main.cc
$(CXX) $(CXXFLAGS) main.cc -c
@duskvirkus
duskvirkus / mouse_threashold.vert
Created January 10, 2020 07:00
Mouse threashold shader.
// http://editor.thebookofshaders.com/
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;