-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,256 additions
and
1,304 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,6 @@ | ||
// TODO: worker run | ||
import { | ||
makeFilter, | ||
getBitmap, | ||
putBitmap, | ||
pack, | ||
packXY, | ||
swapColor, | ||
matches | ||
} from './filter/functions' | ||
import FilterFunctions from './filter/functions' | ||
|
||
import ImageFilter from './filter/index' | ||
import FilterList from './filter/index' | ||
|
||
Object.assign(ImageFilter, { | ||
pack, | ||
packXY, | ||
swapColor | ||
}) | ||
|
||
let F = ImageFilter | ||
|
||
F.filter = function (str) { | ||
return F.merge(matches(str).map(it => { | ||
return it.arr | ||
})) | ||
} | ||
|
||
/** | ||
* | ||
* multiply filters | ||
* | ||
* ImageFilter.multi('blur', 'grayscale', 'sharpen', ['blur', 3], function (bitmap) { return bitmap }); | ||
* | ||
*/ | ||
F.multi = function (...filters) { | ||
filters = filters.map(filter => { | ||
return makeFilter(filter, F); | ||
}) | ||
|
||
return function (bitmap) { | ||
return filters.reduce((bitmap, f) => { | ||
return f(bitmap); | ||
}, bitmap) | ||
} | ||
} | ||
|
||
|
||
F.merge = function (filters) { | ||
return F.multi(...filters); | ||
} | ||
|
||
/** | ||
* apply filter into special area | ||
* | ||
* F.partial({x,y,width,height}, filter, filter, filter ) | ||
* F.partial({x,y,width,height}, 'filter' ) | ||
* | ||
* @param {{x, y, width, height}} area | ||
* @param {*} filters | ||
*/ | ||
F.partial = function (area, ...filters) { | ||
var allFilter = null | ||
if (filters.length == 1 && typeof filters[0] === 'string') { | ||
allFilter = F.filter(filters[0]) | ||
} else { | ||
allFilter = F.merge(filters) | ||
} | ||
|
||
return (bitmap) => { | ||
return putBitmap(bitmap, allFilter(getBitmap(bitmap, area)), area); | ||
} | ||
} | ||
|
||
F.counter = function (filter, count = 1) { | ||
var filters = []; | ||
|
||
for (var i = 0; i < count; i++) { | ||
filters.push(filter); | ||
} | ||
|
||
return F.multi(...filters); | ||
} | ||
|
||
|
||
/** | ||
* multi filter | ||
*/ | ||
|
||
|
||
F.laplacian.grayscale = function (amount = 100) { | ||
return F.filter(`grayscale laplacian(${amount}`) | ||
} | ||
|
||
|
||
F.laplacian5x.grayscale = function () { | ||
return F.filter('grayscale laplacian5x'); | ||
} | ||
|
||
|
||
F.kirsch = function () { | ||
return F.filter('kirsch-horizontal kirsch-vertical'); | ||
} | ||
|
||
F.kirsch.grayscale = function () { | ||
return F.filter('grayscale kirsch'); | ||
} | ||
|
||
F.sobel = function () { | ||
return F.filter('sobel-horizontal sobel-vertical'); | ||
} | ||
|
||
F.sobel.grayscale = function () { | ||
return F.filter('grayscale sobel'); | ||
} | ||
|
||
F.vintage = function () { | ||
return F.filter(`brightness(15) saturation(-20) gamma(1.8)`) | ||
} | ||
|
||
export default ImageFilter | ||
export default Object.assign({}, FilterList, FilterFunctions) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import image from './image/index' | ||
import pixel from './pixel/index' | ||
import matrix from './matrix/index' | ||
import multi from './multi/index' | ||
|
||
export default { | ||
export default { | ||
...image, | ||
...pixel, | ||
...matrix | ||
...matrix, | ||
...multi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import kirsch from './kirsch' | ||
import sobel from './sobel' | ||
import vintage from './vintage' | ||
|
||
export default { | ||
kirsch, | ||
sobel, | ||
vintage | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { | ||
filter | ||
} from '../functions' | ||
|
||
export default function kirsch () { | ||
return filter('kirsch-horizontal kirsch-vertical'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { | ||
filter | ||
} from '../functions' | ||
|
||
export default function sobel () { | ||
return filter('sobel-horizontal sobel-vertical'); | ||
} |
Oops, something went wrong.