Skip to content

Instantly share code, notes, and snippets.

View antiface's full-sized avatar

A.G. antiface

View GitHub Profile
@antiface
antiface / gist:52c662e5b81e34c919a1d5458d048f26
Created August 6, 2016 14:10 — forked from RaffaeleSgarro/gist:4652027
Test random generation when reseeding each iteration
# Requires python-imaging on Ubuntu
import PIL.Image, random, time
class AlexRand(random.Random):
'''This replicates how PHP does randint()'''
def randint(self, a, b):
self.seed()
return super(AlexRand, self).randint(a, b)
image = PIL.Image.new("1",(512,512)) # Creates a 512x512 bitmap
# coding: utf-8
# Python Bitmap (bmp) Image Negation (using module struct)
import struct
with open('in.bmp', 'rb') as fd, open('out.bmp', 'wb') as out:
s = fd.read(1)
count = 1
while s:
if count < 37: # header bytes
@antiface
antiface / lemon.png
Created August 6, 2016 14:07 — forked from pfeyz/lemon.png
wxPython Flickering
lemon.png
@antiface
antiface / vn.py
Created August 6, 2016 14:06 — forked from osamaar/vn.py
Value Noise implementation in python 2.7.x
from random import random, seed
def debug_func(fn):
def new(*args, **kwargs):
print 'DEBUG: function call:', fn.func_name, args, kwargs
return fn(*args, **kwargs)
return new
#@debug_func
def octave(step, amp, bitmap, modifier):
@antiface
antiface / mkanim.py
Created August 6, 2016 14:06 — forked from takaakiaoki/mkanim.py
A simple idiom to gather bitmaps and make a movie using python and ffmpeg
#!/usr/bin/env python
import os
import glob
import shutil
import subprocess
#ffmepg parameters
# file sequence format
dstform = u'a{seq:08d}.png' # python style
@antiface
antiface / qr.py
Created August 6, 2016 14:06 — forked from flipbug/qr.py
Draw qr code as bitmap from binary representation
rawData = "1111111000001001101111111100000101010011110100000110111010000010111010111011011101011101111001011101101110100100000010101110110000010110001110010000011111111010101010101111111000000000110001000000000011111011110001011101010101111100100111100000001010001110101010101111001000110001101000110111111010001011011011101010001010111111101010100010001010001110111110110010111111100111011000011101001001001001101110110100011111111110000000000100101001000101011111111010000010101010011100000100100000110001001110111010100111111111111101011101011111010011111011101110101010110100010000110000010101000011110100011111111011000100011101011"
header = b'\x42\x4D\x4C\x00\x00\x00\x00\x00\x00\x00\x1A\x00\x00\x00\x0C\x00\x00\x00'
dimension = b'\x19\x00\x19\x00\x01\x00\x18\x00'
white = b'\xFF\xFF\xFF'
black = b'\x00\x00\x00'
data = []
@antiface
antiface / bitmapregion.py
Created August 6, 2016 14:06 — forked from tempredirect/bitmapregion.py
functions to grab the regions in a bitmap like structure
from collections import deque
try:
set()
except:
from sets import Set as set
@antiface
antiface / vectorpixels.class.py
Created August 6, 2016 14:06 — forked from codingisacopingstrategy/vectorpixels.class.py
Generate vectorpixels based on bitmaps (2 color pictures).
#!/usr/bin/python
""" Generates vectorpixels based on bitmaps (2 color pictures).
TODO: use element tree for XML; implement Floyd-Steinberg
dithering for color and greyscale images; implement vertical
and horiontal scanlines """
import Image
from sys import argv
class vectorpixel:
@antiface
antiface / image_matrix.py
Created August 6, 2016 14:06 — forked from vgmoose/image_matrix.py
Creates a C array from a bitmap file
import json
import sys
import os
print ".--=============--------------=============--."
print "| Welcome to Image Matrix Maker! |"
print ".--=============--------------=============--."
yeswords = ["yes", "y", "ya", "ok", "okay"]
@antiface
antiface / gist:3356980defe35d4faf907989ad9e2cc2
Created August 6, 2016 14:05 — forked from vgmoose/bitmap.py
number of islands in a bitmap
bitmap = [[0,0,1,1,0,0,0,1,0,0],[0,1,1,0,0,1,1,1,0,0],[0,1,0,0,0,0,0,0,0,0],[0,0,0,1,1,1,0,0,1,1],[0,0,0,0,1,1,1,1,1,0],[0,1,1,0,0,0,0,0,0,0]]
height = len(bitmap)
width = len(bitmap[0])
visited = [[0]*width for x in range(0, height)]
count = 0
def visitAll(x, y):