Skip to content

Instantly share code, notes, and snippets.

@weihanglo
weihanglo / draw_gradient_pillow.py
Last active May 8, 2024 09:09
Draw gradient color with Pillow
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from PIL import Image, ImageDraw
im = Image.open('img_original.png')
def interpolate(f_co, t_co, interval):
det_co =[(t - f) / interval for f , t in zip(f_co, t_co)]
for i in range(interval):
'use strict';
const X = [0.1, 0.5, 0.9, 1.3, 1.7];
const Y = [-2.3026, -0.69315, -0.10536, 0.26236, 0.53063];
const x = 0.8;
// const n = 3;
// var splines = new Array(X.length).fill({a:null,b:null,c:null,d:null,x:null});
var splines = [];
for (let i =0; i < X.length; i++){
splines.push({a:null,b:null,c:null,d:null,x:null});
@alexjlockwood
alexjlockwood / flatten.js
Created December 11, 2016 22:00 — forked from timo22345/flatten.js
Flatten.js, general SVG flattener. Flattens transformations of SVG shapes and paths. All shapes and path commands are supported.
<!doctype html>
<html>
<title>Flatten.js, General SVG Flattener</title>
<head>
<script>
/*
Random path and shape generator, flattener test base: http://jsfiddle.net/xqq5w/embedded/result/
Basic usage example: http://jsfiddle.net/Nv78L/3/embedded/result/
@hawkz
hawkz / SVG Stroke Text Effect.markdown
Created September 5, 2015 17:30
SVG Stroke Text Effect
@staltz
staltz / introrx.md
Last active May 12, 2025 23:22
The introduction to Reactive Programming you've been missing
@mhartington
mhartington / CustomTheme
Last active December 8, 2018 20:35
If you want to make a custom theme for ionic, and are using scss, this is a base to get you started
//Custom Theme test
// Colors
// -------------------------------
$custom: #057b6c !default;
// Buttons
// -------------------------------
$button-custom-bg: $custom !default;
@lilydjwg
lilydjwg / ttc2ttf
Last active May 2, 2025 05:29
Convert .ttc to several .ttf files into the current directory
#!/usr/bin/env python3
import sys
import fontforge
def main(file):
for font in fontforge.fontsInFile(file):
f = fontforge.open(u'%s(%s)' % (file, font))
f.generate('%s.ttf' % font)
@thomir
thomir / svg2png.py
Created December 21, 2013 22:21
Various ways to convert SVG -> PNG
#!/usr/bin/env python
"""Convert an SVG file to a PNG file."""
from argparse import ArgumentParser
import subprocess
import os.path
def main():
@codeguy
codeguy / slugify.js
Created September 24, 2013 13:19
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@zeffii
zeffii / _.md
Created February 4, 2013 22:42
Pattern grid - raster

[ Launch: Pattern grid - raster ] 4710427 by zeffii[ Launch: Pattern grid - raster ] 4659977 by roundrobin[ Launch: Pattern grid - 2 ] 4659021 by roundrobin[ Launch: Pattern grid - stripes ] 4657513 by roundrobin[ Launch: Pattern grid - wave ] 4647105 by roundrobin[ Launch: Pattern grid - elector ] 4647086 by roundrobin[ Launch: Pattern grid - elector ] 4647080 by roundrobin[ Launch: Pattern grid - 50-50 circles ] 4647076 by roundrobin[ Launch: Pattern grid - double quater circles ] 4647019 by roundrobin[ L