This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#ifdef _WIN32 | |
# include <malloc.h> | |
#else | |
# include <alloca.h> | |
#endif | |
#include "ospray/ospray.h" | |
// helper function to write the rendered image as PPM file | |
void writePPM(const char *path, const osp::vec2i &size, const uint32_t *pixel) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/fogleman/ln/ln" | |
) | |
const Slices = 10 | |
const Size = 1024 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import pi, sin, cos, hypot, floor | |
from pyhull.voronoi import VoronoiTess | |
from shapely.geometry import Polygon | |
import cairocffi as cairo | |
import colorsys | |
import random | |
R = 0.05 | |
FILL = 0x422B36 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
from math import pi | |
import cairo | |
COLORS = { | |
'a': (0, 0, 180), | |
'b': (175, 13, 102), | |
'c': (146, 248, 70), | |
'd': (255, 200, 47), | |
'e': (255, 118, 0), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageChops, ImageDraw | |
import os | |
def load_images(folder): | |
result = [] | |
for name in os.listdir(folder): | |
path = os.path.join(folder, name) | |
print path | |
im = Image.open(path) | |
result.append(im) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pg | |
class Window(pg.Window): | |
def setup(self): | |
self.set_clear_color(0.87, 0.81, 0.70) | |
self.wasd = pg.WASD(self, speed=0.3) | |
self.wasd.look_at((0, 0, 0), (30, -5, 30)) | |
self.context = pg.Context(pg.DirectionalLightProgram()) | |
self.context.specular_multiplier = 0.25 | |
self.context.ambient_color = (0.5, 0.5, 0.5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"image" | |
"image/png" | |
"net/http" | |
. "github.com/fogleman/pt/pt" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
class Board(object): | |
def __init__(self, size): | |
self.size = size | |
self.grid = {} | |
def move(self, color, x, y): | |
self.set(color, x, y) | |
for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1)]: | |
nx = x + dx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import math | |
# https://www.wolframalpha.com/input/?i=1,6,90,2520,113400 | |
# a(n) = (2n)! / 2^n | |
# https://oeis.org/A000680 | |
def f(n): | |
return math.factorial(2 * n) / (2 ** n) | |
def brute(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "github.com/fogleman/gg" | |
func main() { | |
const S = 1024 | |
dc := gg.NewContext(S, S) | |
dc.SetRGB(1, 1, 1) | |
dc.Clear() | |
dc.LoadFontFace("/Library/Fonts/Impact.ttf", 96) |