Skip to content

Instantly share code, notes, and snippets.

@line0
line0 / StackedNto16
Last active December 27, 2015 19:49
function StackedNto16(clip c, int n)
{
Assert(8 <= n <= 15, "StackedNto16: bitdepth should be in range 8-15")
h = c.Height / 2
msb = c.Crop(0,0,0,-h)
lsb = c.Crop(0,h,0,0)
shamt = string(16-n)
msb16 = (n != 8) ? msb.mt_lutxy(lsb, "x " + shamt + " << y 8 " + shamt + " - >> +", v=3, u=3) : lsb
lsb16 = (n != 8) ? lsb.mt_lut("x " + shamt + " << 255 &u", v=3, u=3) : msb
@line0
line0 / nnedi3_resize16_v3.0_gpumod.avsi
Last active December 28, 2015 18:59
nnedi3_resize16 v3.0 by mawen1250, modded to use nnedi3ocl with gpu=true
###### nnedi3_resize16 v3.0 ###### by mawen1250 ###### 2013.11.15 ######
###### from v2.8 on, nnedi3_resize16 only supports AviSynth v2.6 ######
###### Requirements: masktools v2.0a48, dither v1.24.0, nnedi3 v0.9.4, ######
###### SmoothAdjust v2.90, Contra-Sharpen mod 3.4, ######
###### FTurn v1.3.5 (not necessarily required but will improve speed) ######
###### Accept Y8, YV12, YV16, YV24 input, use nnedi3 and Dither_resize16(nr) for scaling ######
###### output format can be 8bit/16bit Y8/YV12/YV16/YV24 or RGB32/RGB24/RGB48YV12/RGB48Y ######
Function nnedi3_resize16(clip input, int "target_width", int "target_height", float "src_left", float "src_top",
@line0
line0 / RGB48YV12toRGB48Y.avsi
Last active December 29, 2015 11:49
converts RGB48YV12 to RGB48Y
function RGB48YV12toRGB48Y(clip c)
{
vers = VersionNumber()
tPref = IsFunction("FTurnLeft") ? "F" : ""
w = c.Width
h = c.Height
y = (vers < 2.60) ? c : c.ConvertToY8()
u = (vers < 2.60) ? c.UtoY() : c.UtoY8()
v = (vers < 2.60) ? c.VtoY() : c.VtoY8()
src=last
Spline36Resize(width*2,height*2)
a=tcolormask("$ffffb5 $ecc96c $eff1ac $eeecbf $ecc250 $eef1ee",14,false,true).mt_expand_multi(sw=4, sh=4).mt_inflate().Spline36Resize(1920,1080)
b=tcolormask("$ffffb5 $ecc96c $eff1ac $eeecbf $ecc250 $dcc85f",11,false,true).mt_expand_multi(sw=6, sh=6).mt_inpand_multi(sw=2,sh=2).Spline36Resize(1920,1080)
ribbon=src.tcolormask("$e57f7f",16).mt_expand_multi(sw=3, sh=3).mt_inflate()
exclude=src.tcolormask("$65a2a6 $2f91a6 $357d98 $47a9c0 $84b0af",12,false,true).mt_expand_multi(sw=8,sh=8).mt_inpand_multi(sw=8,sh=8).RemoveGrain(17).mt_invert()
b.Crop(0,0,1232,0).StackHorizontal(a.mt_logic(exclude,"and").Crop(1232,0,0,0)).mt_logic(ribbon, "or")
HiAA(aa="sangnom2", preaa=True, ss="nnedi3")
mt_invert().ConvertToY8()
@line0
line0 / GetPixelColor.py
Created April 26, 2014 19:33
GetPixelColor AvsPmod macro
import wx
import ctypes as ct
class GetPoint(ct.Structure):
_fields_ = [("x", ct.c_long), ("y", ct.c_long)]
def get_mousepos():
pt = GetPoint()
ct.windll.user32.GetCursorPos(ct.byref(pt))
return int(pt.x), int(pt.y)
@line0
line0 / Copy Glyph Selection.py
Last active August 29, 2015 14:02
Fontlab Macro: copy glyph selection into clipboard
from Tkinter import Tk
tk = Tk()
import json
glyphs = fl.font.glyphs
sel = []
for i in range(len(glyphs)):
if fl.Selected(i):
sel.append({'name':glyphs[i].name, 'unicode':glyphs[i].unicode})
@line0
line0 / Paste Glyph Selection.py
Created May 30, 2014 18:13
Fontlab Macro: paste glyph selection from clipboard
from Tkinter import Tk
tk = Tk()
import json
tk.withdraw()
sel = json.loads(tk.clipboard_get())
tk.destroy()
glyphs = fl.font.glyphs
fl.Unselect()
@line0
line0 / Raster Glyph.py
Last active August 29, 2015 14:02
FontLab Macro: raster/pixel selected glyphs. also useful for introducing aliasing.
import robofab
import random
def drawRaster(glyph, raster, box):
colCnt = len(raster)
rowCnt = len(raster[0])
pen = glyph.getPen()
offY = box[1]
offX = box[0]
@line0
line0 / Select glyphs for stripping.py
Last active August 29, 2015 14:03
Fontlab Macro: select glyphs to be stripped from an hardcoded list, doesn't handle linked glyphs (multiple code points) properly, yet
sel = [
{"name": ".notdef", "unicode": None},
{"name": "cid1", "unicode": 0},
{"name": "cid2", "unicode": 33},
{"name": "cid3", "unicode": 34},
{"name": "cid4", "unicode": 35},
{"name": "cid5", "unicode": 36},
{"name": "cid6", "unicode": 37},
{"name": "cid7", "unicode": 38},
{"name": "cid8", "unicode": 39},
@line0
line0 / Texture Glyphs.py
Created September 10, 2014 09:51
Fontlab script: adds texture to selected glyphs by intersecting them with a glyph named "texture"
def process(f, g, t, index):
fl.SetUndo(index)
upm = f.upm
g.RemoveOverlap()
outlines = Glyph(g)
g.Distance(upm/100, upm/100, 1)
g.RemoveOverlap()
outlines.Bsubtract(t)
g.Bsubtract(outlines)