Last active
September 8, 2015 13:12
-
-
Save baku89/ba41fe8338946cc27bd0 to your computer and use it in GitHub Desktop.
proce55ing with pipeline
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
./p5-pipe.sh pipe_invert pipe_blur --args ./sample.png |
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
#!/bin/sh | |
# parse arguments | |
sketches=() | |
while [ "$1" != "" -a "$1" != "--args" ] | |
do | |
sketches+=( "$1" ) | |
shift | |
done | |
shift | |
args="$@" | |
# execute sketches in order | |
for sketch in ${sketches[@]}; do | |
absPath=`cd "$sketch"; pwd` | |
echo start: ${absPath} >&2 | |
args=`processing-java --sketch=$absPath --run ${args[@]} | sed -e '1d' | sed -e '$d' | tail -1` | |
echo \> $args >&2 | |
done | |
echo "all done." |
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
ArrayList<String> arguments; | |
void setup() { | |
arguments = getArgs(); | |
if ( arguments.size() == 0 ) { | |
exit(); | |
} | |
String src = arguments.get(0); | |
String name = getFileName( src ); | |
String dir = getDirectory( src ); | |
String dst = dir + "/" + name + "_blurred.png"; | |
PImage img = loadImage( src ); | |
img.filter( BLUR, 6 ); | |
img.save( dst ); | |
println( dst ); | |
exit(); | |
} |
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
ArrayList<String> arguments; | |
void setup() { | |
arguments = getArgs(); | |
if ( arguments.size() == 0 ) { | |
exit(); | |
} | |
String src = arguments.get(0); | |
String name = getFileName( src ); | |
String dir = getDirectory( src ); | |
String dst = dir + "/" + name + "_inverted.png"; | |
PImage img = loadImage( src ); | |
img.filter( INVERT ); | |
img.save( dst ); | |
println( dst ); | |
exit(); | |
} |
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
ArrayList< String > getArgs() { | |
ArrayList< String > arguments = new ArrayList< String >(); | |
try { | |
for ( int i = 0; i < args.length; i++ ) { | |
arguments.add( args[i] ); | |
} | |
} catch ( Exception e ) { | |
return arguments; | |
} | |
return arguments; | |
} | |
String getFileName( String path ) { | |
String filename = new File( path ).getName(); | |
int point = filename.lastIndexOf("."); | |
if (point != -1) { | |
return filename.substring(0, point); | |
} | |
return filename; | |
} | |
String getDirectory( String path ) { | |
return new File( path ).getParent(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment