Skip to content

Instantly share code, notes, and snippets.

View lucasdinonolte's full-sized avatar
:shipit:

Lucas Dino Nolte lucasdinonolte

:shipit:
View GitHub Profile
@lucasdinonolte
lucasdinonolte / canvas.js
Created November 28, 2023 08:53
With Dithering
const width = 1000;
const height = 1000;
const background = '#f1f1f1';
const canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext('2d');
ctx.fillStyle = background;
@lucasdinonolte
lucasdinonolte / generateConfig.js
Created October 8, 2023 16:25
Reads in CSS file(s) and turns custom properties and custom media queries into an object format that can be passed to Tailwind or UnoCSS config
import { readFileSync } from 'fs';
import postcss from 'postcss';
const customMediaNameRegExp = /^custom-media$/i;
const customMediaParamsRegExp = /^(--[A-z][\w-]*)\s+([\W\w]+)\s*$/;
const customMediaValueRegExp = /min-width:[ ]?([0-9]+px|rem|em)/;
/**
* @param {import('postcss').Node} node
* @returns boolean
@lucasdinonolte
lucasdinonolte / broad-nib-simulator.js
Last active April 5, 2021 15:15
Simulating a broad nib pen around a drawn letter skeleton using Paper.js
var path;
var penAngle = -20;
var textItem = new PointText(new Point(20, 30));
textItem.fillColor = 'black';
textItem.content = 'Click and drag to draw a line.';
function onMouseDown(event) {
// If we produced a path before, deselect it:
if (path) {
@lucasdinonolte
lucasdinonolte / screensaver-animation.pde
Created January 7, 2020 15:17
Parametric Equation in Processing emulating 90's screensaver vibes.
// For exporting the video
import com.hamoid.*;
static final int NUM_LINES = 20;
float t;
VideoExport videoExport;
void setup() {
size(500, 500);
@lucasdinonolte
lucasdinonolte / overshoot-reporter.py
Created November 2, 2018 22:42
Overshoot Reporter
print "Name\t\t\tMax\t\t\tMin"
for thisLayer in Glyphs.font.selectedLayers:
capHeight = Glyphs.font.masters[thisLayer.associatedMasterId].capHeight
xHeight = Glyphs.font.masters[thisLayer.associatedMasterId].xHeight
ascender = Glyphs.font.masters[thisLayer.associatedMasterId].ascender
maxY = 0
minY = 1000
for path in thisLayer.paths:
for node in path.nodes:
@lucasdinonolte
lucasdinonolte / batch-update-sidebearings.py
Created October 7, 2018 17:34
Glyphs App Batch Update Sidebearings by factor
scale = 1.166666667
for char in Glyphs.font.selectedLayers:
if char.LSB < 0:
char.LSB = round(char.LSB/scale)
else:
char.LSB = round(char.LSB*scale)
if char.RSB < 0:
char.RSB = round(char.RSB/scale)
else:
@lucasdinonolte
lucasdinonolte / _quotes.sass
Created October 11, 2017 13:24
Language specific quotation marks
// Wrap the quotes
// in language specific
// quotation marks if a
// language is specified
// ---------------------
// German Quotes
.c-quote--german &,
html:lang(de) &
&::before
content: '„'
@lucasdinonolte
lucasdinonolte / _transitions.sass
Created August 22, 2017 14:35
SASS Mixins for nice transitions
// These default values could be overwritten in a potentially cleaned up global config file ;-)
$transition--easing: cubic-bezier(0.4, 0, 0.2, 1) !default
$transition--slow: '0.2s 0.1s' !default
$transition--fast: '0.1s' !default
// The main mixin
=transition($speed, $properties...)
$transitions: ()
// Timing is fast, unless 'slow' is specified
# Linter Options
options:
merge-default-rules: false
formatter: stylish
max-warnings: 50
# File Options
files:
include: '**/*.s+(a|c)ss'
# type your Python code here and press cmd+Return to run.
reference = "n"
glyph = Glyphs.font.glyphs[reference].layers[0]
referenceWidth = glyph.width - glyph.LSB - glyph.RSB
print "Reference:", reference, referenceWidth
for char in ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]:
curGlyph = Glyphs.font.glyphs[char].layers[0]
width = curGlyph.width - curGlyph.LSB - curGlyph.RSB