/data/common/media/grafx2/scripts/samples_2.4/brush/ApplyColor.lua |
---|
0,0 → 1,129 |
--BRUSH Remap: Apply PenColor |
--by Richard Fhager |
--http://hem.fyristorg.com/dawnbringer/ |
-- Copyright 2010 Richard Fhager |
-- |
-- This program is free software; you can redistribute it and/or |
-- modify it under the terms of the GNU General Public License |
-- as published by the Free Software Foundation; version 2 |
-- of the License. See <http://www.gnu.org/licenses/> |
run("../libs/dawnbringer_lib.lua") |
OK,tin,clz,fade,amt,brikeep,falloff,nobg,nopen,briweight = inputbox("Apply PenColor 2 Brush", |
"1. Tint", 1, 0,1,-1, |
"2. Colorize", 0, 0,1,-1, |
"BG->FG color Fade", 0, 0,1,0, |
"AMOUNT % (0-100)", 100, 0,100,0, |
"Preserve Brightness", 1, 0,1,0, |
"Bri/Dark FallOff", 1, 0,1,0, |
"Exclude Background", 1,0,1,0, |
"Exclude PenColor", 0,0,1,0, |
"ColMatch Bri-Weight %", 25, 0,100,0 |
); |
if OK == true then |
function cap(v) return math.min(255,math.max(v,0)); end |
w, h = getbrushsize() |
fg = getforecolor() |
bg = getbackcolor() |
fR,fG,fB = getcolor(fg) |
bR,bG,bB = getcolor(bg) |
pal = db.fixPalette(db.makePalList(256)) |
if nobg == 1 then |
pal = db.stripIndexFromPalList(pal,bg) -- Remove background color from pallist |
end |
if nopen == 1 then |
pal = db.stripIndexFromPalList(pal,fg) -- Remove Pencolor from pallist |
end |
amtA = amt / 100 |
amtR = 1 - amtA |
-- Normalize Pen Color |
lev = (fR+fG+fB)/3 |
fR = fR - lev |
fG = fG - lev |
fB = fB - lev |
--------------------------------------------------- |
-- Colorize (Colourant) (just apply colorbalance) |
-- Tint (make grayscale and apply colorbalance) |
-- |
-- I think it should be the other way around since colorize is the process of adding color to B&W film... |
-- But this is the what Brilliance and others call it |
-- |
if clz == 1 or tin == 1 then |
cols = {} |
for n = 0, 255, 1 do |
r,g,b = getcolor(n) |
a = db.getBrightness(r,g,b) |
mR,mG,mB = fR,fG,fB |
-- Fade between bg & fg pencolor across dark-bright |
if fade == 1 then |
lf = a / 255 |
lr = 1 - lf |
mR = bR*lr + fR*lf |
mG = bG*lr + fG*lf |
mB = bB*lr + fB*lf |
lev = (mR+mG+mB)/3 |
mR = mR - lev |
mG = mG - lev |
mB = mB - lev |
end |
fr,fg,fb = mR,mG,mB |
if brikeep == 1 then |
-- Loose Brightness preservation (ex: applying full red to dark colors) |
brin = db.getBrightness(cap(r+mR),cap(g+mG),cap(b+mB)) |
itot = brin - a |
fr = mR - itot |
fg = mG - itot |
fb = mB - itot |
end |
-- Falloff (Effect weakens at dark and bright colors) |
if falloff == 1 then |
fo = 1 - math.abs((a - 127.5)/127.5)^2 |
fr = fr * fo |
fg = fg * fo |
fb = fb * fo |
end |
if tin == 1 then |
--cols[n+1] = matchcolor((a+fr)*amtA + r*amtR, (a+fg)*amtA + g*amtR, (a+fb)*amtA + b*amtR) |
cols[n+1] = db.getBestPalMatchHYBRID({(a+fr)*amtA+r*amtR, (a+fg)*amtA + g*amtR, (a+fb)*amtA + b*amtR},pal,briweight / 100,true) |
end |
if clz == 1 then |
--cols[n+1] = matchcolor((r+fr)*amtA + r*amtR, (g+fg)*amtA + g*amtR, (b+fb)*amtA + b*amtR) |
cols[n+1] = db.getBestPalMatchHYBRID({(r+fr)*amtA+r*amtR, (g+fg)*amtA + g*amtR, (b+fb)*amtA + b*amtR},pal,briweight / 100,true) |
end |
end |
if nobg == 1 then cols[getbackcolor()+1] = getbackcolor(); end |
for x = 0, w - 1, 1 do |
for y = 0, h - 1, 1 do |
putbrushpixel(x, y, cols[getbrushpixel(x,y) + 1]); |
end |
end |
end; |
-- eof Colorize & Tint |
-------------------------------------------------------- |
end -- OK |
/data/common/media/grafx2/scripts/samples_2.4/brush/Fisheye.lua |
---|
0,0 → 1,31 |
--BRUSH Distortion: FishEye |
--by Richard Fhager |
--http://hem.fyristorg.com/dawnbringer/ |
-- Copyright 2010 Richard Fhager |
-- |
-- This program is free software; you can redistribute it and/or |
-- modify it under the terms of the GNU General Public License |
-- as published by the Free Software Foundation; version 2 |
-- of the License. See <http://www.gnu.org/licenses/> |
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project |
--http://goto.glocalnet.net/richard_fhager/evalion/evalion.html |
w, h = getbrushsize() |
for y = 0, h - 1, 1 do |
for x = 0, w - 1, 1 do |
ox = x / w; |
oy = y / h; |
v = (math.cos((ox-0.5)*math.pi)*math.cos((oy-0.5)*math.pi))*0.85; |
ox = (1 + ox - (ox-0.5)*v) % 1; |
oy = (1 + oy - (oy-0.5)*v) % 1; |
c = getbrushbackuppixel(math.floor(ox*w),math.floor(oy*h)); |
putbrushpixel(x, y, c); |
end |
end |
/data/common/media/grafx2/scripts/samples_2.4/brush/GrayscaleAvg.lua |
---|
0,0 → 1,24 |
--BRUSH Remap: Grayscale (average) |
--by Richard Fhager |
--http://hem.fyristorg.com/dawnbringer/ |
-- Copyright 2010 Richard Fhager |
-- |
-- This program is free software; you can redistribute it and/or |
-- modify it under the terms of the GNU General Public License |
-- as published by the Free Software Foundation; version 2 |
-- of the License. See <http://www.gnu.org/licenses/> |
w, h = getbrushsize() |
for x = 0, w - 1, 1 do |
for y = 0, h - 1, 1 do |
r, g, b = getcolor(getbrushpixel(x,y)) |
a = (r+g+b)/3 |
putbrushpixel(x, y, matchcolor(a,a,a)); |
end |
end |
/data/common/media/grafx2/scripts/samples_2.4/brush/GrayscaleDesat.lua |
---|
0,0 → 1,36 |
--BRUSH Remap: Grayscale (desaturate) |
--by Richard Fhager |
--http://hem.fyristorg.com/dawnbringer/ |
-- Copyright 2010 Richard Fhager |
-- |
-- This program is free software; you can redistribute it and/or |
-- modify it under the terms of the GNU General Public License |
-- as published by the Free Software Foundation; version 2 |
-- of the License. See <http://www.gnu.org/licenses/> |
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project |
--http://goto.glocalnet.net/richard_fhager/evalion/evalion.html |
percent = 100 |
-- |
function desaturate(percent,r,g,b) -- V1.0 by Richard Fhager |
p = percent / 100 |
a = (math.min(math.max(r,g,b),255) + math.max(math.min(r,g,b),0)) * 0.5 * p |
r = r + (a-r*p) |
g = g + (a-g*p) |
b = b + (a-b*p) |
return r,g,b |
end |
-- |
w, h = getbrushsize() |
for x = 0, w - 1, 1 do |
for y = 0, h - 1, 1 do |
putbrushpixel(x, y, matchcolor(desaturate(percent,getcolor(getbrushpixel(x,y))))); |
end |
end |
/data/common/media/grafx2/scripts/samples_2.4/brush/Halfsmooth.lua |
---|
0,0 → 1,34 |
--BRUSH: Halfsize with smoothscaling |
--by Richard Fhager |
--http://hem.fyristorg.com/dawnbringer/ |
-- Copyright 2010 Richard Fhager |
-- |
-- This program is free software; you can redistribute it and/or |
-- modify it under the terms of the GNU General Public License |
-- as published by the Free Software Foundation; version 2 |
-- of the License. See <http://www.gnu.org/licenses/> |
w, h = getbrushsize() |
setbrushsize(math.floor(w/2),math.floor(h/2)) |
for x = 0, w - 1, 2 do |
for y = 0, h - 1, 2 do |
r1,g1,b1 = getcolor(getbrushbackuppixel(x,y)); |
r2,g2,b2 = getcolor(getbrushbackuppixel(x+1,y)); |
r3,g3,b3 = getcolor(getbrushbackuppixel(x,y+1)); |
r4,g4,b4 = getcolor(getbrushbackuppixel(x+1,y+1)); |
r = (r1 + r2 + r3 + r4 ) / 4; |
g = (g1 + g2 + g3 + g4 ) / 4; |
b = (b1 + b2 + b3 + b4 ) / 4; |
c = matchcolor(r,g,b); |
putbrushpixel(x/2, y/2, c); |
end |
end |
/data/common/media/grafx2/scripts/samples_2.4/brush/Waves.lua |
---|
0,0 → 1,42 |
--BRUSH Distortion: Waves v1.0 |
--by Richard Fhager |
--http://hem.fyristorg.com/dawnbringer/ |
-- Copyright 2010 Richard Fhager |
-- |
-- This program is free software; you can redistribute it and/or |
-- modify it under the terms of the GNU General Public License |
-- as published by the Free Software Foundation; version 2 |
-- of the License. See <http://www.gnu.org/licenses/> |
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project |
-- http://goto.glocalnet.net/richard_fhager/evalion/evalion.html |
--frq = 2 |
--amp = 0.3 |
-- Adjust power of frequency & amplitude |
frq_adj = 2 |
amp_adj = 0.02 |
ok,frq,amp = inputbox("Settings", |
"Frequency 1-10", 3, 1,10,0, |
"Amplitude 1-10", 3, 1,10,0 |
); |
w, h = getbrushsize() |
for y = 0, h - 1, 1 do |
for x = 0, w - 1, 1 do |
ox = x / w; |
oy = y / h; |
ox = (1 + ox + math.sin(oy*math.pi*frq*frq_adj)*amp*amp_adj) % 1; |
c = getbrushbackuppixel(math.floor(ox*w),y); |
putbrushpixel(x, y, c); |
end |
end |