Skip to content

Commit

Permalink
batch export stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmorris committed Mar 2, 2017
1 parent 2c75089 commit 5c41ae4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ There are lots of examples of researchers constructing self-similarity matrices
### Note on canned data

`public/canned` contains a bunch of text files with examples of verse (pop songs, poems, nursery rhymes, etc.). Some of these works are in the public domain, and some are not. I don't own any of that content (and the license on the software in this repo does not extend to those files). My use of the songs which are under copyright is presumed to be fair, given the transformativeness of the use, and that purpose of use is educational and non-commercial.

### Generating matrix image files

This comment has been minimized.

Copy link
@ruponkar

ruponkar Jun 23, 2018

my favorite singer justin bieber hart tacing [song


(This is mostly a note to myself so I don't forget.)

- set config.debug = true
- in browser, press 'batch export' button
- (this will respect all current settings wrt color, single-word matches, etc.)
- unzip
- run pngify.sh
- move pngs to public/img/gallery (or wherever else they're needed)
11 changes: 11 additions & 0 deletions pngify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

imgsize=800
#dest=public/img/gallery/
dest='./'
for path in "$@"
do
fname=$(basename "$path")
base="${fname%.*}"
inkscape -z -e "${dest}${base}.png" -w $imgsize $path
done
12 changes: 7 additions & 5 deletions src/Songsim.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,10 @@ class Songsim extends Component {
}

/** Only used to generate SVGs for gallery. Super hacky. **/
batchExportSVGs = () => {
batchExportSVGs = (max) => {
let zip = new JSZip();
let i = 0;
let dur = 3000;
var max = 333;
for (let canned of CANNED_SONGS) {
window.setTimeout(() => {
SongSelector.loadSong( (verse) => {
Expand All @@ -163,8 +162,6 @@ class Songsim extends Component {
saveAs(c, 'matrices.zip');
});
}, dur * Math.min(max, CANNED_SONGS.length));
//var blob = new Blob(['hello world'], {type: 'text/plain'});
//saveAs(blob, 'hello.txt');
}

get focal_rowcols() {
Expand Down Expand Up @@ -297,7 +294,12 @@ class Songsim extends Component {
{rects.length} rects
</p>
<p>Custom: {JSON.stringify(this.state.verse.isCustom())}</p>
<button onClick={this.batchExportSVGs}>Do stuff</button>
<button onClick={()=>(this.batchExportSVGs(11222))}>
Batch export (SLOW)
</button>
<button onClick={()=>(this.batchExportSVGs(4))}>
Mini batch export (only a little SLOW)
</button>
<a href={this.props.router.createHref('custom/' + config.testingFBKey)}>
Custom song.
</a>
Expand Down

0 comments on commit 5c41ae4

Please sign in to comment.