Skip to content

Instantly share code, notes, and snippets.

@hysysk
hysysk / bw2transparent.pde
Created March 11, 2020 08:27
To export a black and white color layer with blend mode "Screen".
PImage img = loadImage("noise_bw.png");
PImage out = createImage(img.width, img.height, ARGB);
img.loadPixels();
out.loadPixels();
for(int i=0; i<img.width; i++) {
for(int j=0; j<img.height; j++) {
color c = img.pixels[j+i*img.width];
float a = brightness(c);
out.pixels[j+i*img.width] = color(255, 255, 255, a);
}
@hysysk
hysysk / text2shape.jsx
Last active January 30, 2017 04:19
Convert All Photoshop TextItem to Shape
var layers = app.activeDocument.layers;
convertToShapeLayer(layers);
function convertToShapeLayer(layers) {
for(var i=0,layersLength=layers.length; i<layersLength; i++) {
var layer = layers[i];
if(layer.typename == "LayerSet") {
convertToShapeLayer(layer.layers);
} else {
if(layer.kind == LayerKind.TEXT) {
@hysysk
hysysk / ViewController
Created February 11, 2015 13:37
Drum pad sample using AudioKit
import UIKit
class ViewController: UIViewController {
var buttons: [UIButton] = []
var notes: [AKNote] = []
let soundFiles: Array<String> = ["BassC1", "FluteC2", "glockA1", "musicboxC1", "newharpC1", "pianoguitarA2"]
func prepareSounds() {
for (index, soundFile) in enumerate(soundFiles) {
@hysysk
hysysk / fadeInOut.pde
Created September 10, 2014 14:42
Fade In/Fade Out of two images
PImage imgA, imgB;
float transparency;
float targetTransparency;
boolean isFadeAtoB;
boolean isFadeCompleted;
int currentTime;
int fadeCompletedTime;
float easing;
void setup() {
imgA = loadImage("a.jpg");
@hysysk
hysysk / zoomImage.pde
Created August 19, 2014 20:10
Zoom in and out on mouse position. You need to put a image file in the data folder.
PImage img;
float scaleValue;
float diff;
float SCALE_VALUE_MIN = 1.0;
float SCALE_VALUE_MAX = 3.0;
float EASE_VALUE = 0.2;
void setup() {
img = loadImage("image.jpg");
size(img.width, img.height);
/*
Modified from SVG Stipple Generator, v. 2.02
Copyright (C) 2012 by Windell H. Oskay, www.evilmadscientist.com
Full Documentation: http://wiki.evilmadscience.com/StippleGen
Blog post about the release: http://www.evilmadscientist.com/go/stipple2
An implementation of Weighted Voronoi Stippling:
http://mrl.nyu.edu/~ajsecord/stipples.html
/*
Modified from SVG Stipple Generator, v. 2.02
Copyright (C) 2012 by Windell H. Oskay, www.evilmadscientist.com
Full Documentation: http://wiki.evilmadscience.com/StippleGen
Blog post about the release: http://www.evilmadscientist.com/go/stipple2
An implementation of Weighted Voronoi Stippling:
http://mrl.nyu.edu/~ajsecord/stipples.html
@hysysk
hysysk / fullpage
Created August 26, 2012 01:45
Expand image to full page with JavaScript and CSS3
<!DOCTYPE html>
<html>
<head>
<title>fullpage</title>
<script>
window.onload = function() {
var body = document.getElementsByTagName('body')[0];
body.addEventListener("click", openFullPage, false);
function openFullPage(e) {
@hysysk
hysysk / aging.py
Created March 29, 2012 01:14
Make a jpeg file dartier
import Image
import glob, os, sys
counter = int(sys.argv[2])
def aging(filename, counter):
image = Image.open(filename)
image.save(filename, "JPEG", quality=10)
counter = counter - 1
if counter>0:
aging(filename, counter)