Skip to content

Instantly share code, notes, and snippets.

@oxbowmantella
Forked from dribnet/.block
Last active May 19, 2017 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oxbowmantella/4f599d888fe8caea7f6c83ffe8f1272f to your computer and use it in GitHub Desktop.
Save oxbowmantella/4f599d888fe8caea7f6c83ffe8f1272f to your computer and use it in GitHub Desktop.
17.1.MDDN242 PS3
license: mit
downloads
resized
colorgrid
smartgrid
customgrid
// note: this file is poorly named - it can generally be ignored.
// helper functions below for supporting blocks/purview
function saveBlocksImages(doZoom) {
if(doZoom == null) {
doZoom = false;
}
// generate 960x500 preview.jpg of entire canvas
// TODO: should this be recycled?
var offscreenCanvas = document.createElement('canvas');
offscreenCanvas.width = 960;
offscreenCanvas.height = 500;
var context = offscreenCanvas.getContext('2d');
// background is flat white
context.fillStyle="#FFFFFF";
context.fillRect(0, 0, 960, 500);
context.drawImage(this.canvas, 0, 0, 960, 500);
// save to browser
var downloadMime = 'image/octet-stream';
var imageData = offscreenCanvas.toDataURL('image/jpeg');
imageData = imageData.replace('image/jpeg', downloadMime);
p5.prototype.downloadFile(imageData, 'preview.jpg', 'jpg');
// generate 230x120 thumbnail.png centered on mouse
offscreenCanvas.width = 230;
offscreenCanvas.height = 120;
// background is flat white
context = offscreenCanvas.getContext('2d');
context.fillStyle="#FFFFFF";
context.fillRect(0, 0, 230, 120);
if(doZoom) {
// pixelDensity does the right thing on retina displays
var pd = this._pixelDensity;
var sx = pd * mouseX - pd * 230/2;
var sy = pd * mouseY - pd * 120/2;
var sw = pd * 230;
var sh = pd * 120;
// bounds checking - just displace if necessary
if (sx < 0) {
sx = 0;
}
if (sx > this.canvas.width - sw) {
sx = this.canvas.width - sw;
}
if (sy < 0) {
sy = 0;
}
if (sy > this.canvas.height - sh) {
sy = this.canvas.height - sh;
}
// save to browser
context.drawImage(this.canvas, sx, sy, sw, sh, 0, 0, 230, 120);
}
else {
// now scaledown
var full_width = this.canvas.width;
var full_height = this.canvas.height;
context.drawImage(this.canvas, 0, 0, full_width, full_height, 0, 0, 230, 120);
}
imageData = offscreenCanvas.toDataURL('image/png');
imageData = imageData.replace('image/png', downloadMime);
p5.prototype.downloadFile(imageData, 'thumbnail.png', 'png');
}

PS3 MDDN 242 2017

FINAL(Different Game Art styles CustomGrid montage)

in this version i decided to go back to the "Different Game Art styles montage", because i felt that trying to compare something that is really similar to each other, would be a good way to see what the smart/custom grid is capible of.

overall the outcome of the custom grid was what i expected, i pinned two very different images to see how it would group around it, first i groupings of similar armor and body styles, whether they be robotic or ancient. the grid was able to see this similaritry and group the ones that related to theme fairly well, and it also seemed to group the similar art styles together as well, i.e. if they were shell shaded or drawn etc. If it looks like some of the images have been cut from the head up, artstation had the images posted that way from what it looks like.

overall the custom grid was able to make figure out the difference between what is a human figure to something that is man made (non natural)/cartoony. overall the grouping are evident and does show the different zones within the custom grid, something interesting i found was how it reads, looking from left to right, the image shows a sense or agression from the left to the right, i.e. the more agressive armors and shapes are to the left, and as it goes to the right it become more "friendly" i.e the art style isnt so agressive that it looks scary.i also found it interesting that it was able to group the mechs together in the top left corner, i was thinking that since there are lots of art styles it might to recognise the diffence, but for the most part it was able to see that those were different from the rest.

the reasoning for picking my left and right images are i wanted to have 2 completly different things, one being a object and one being "being" and it turned out fairly interesting in how it decided to group the rest of the images around it.

NOTE: the site i used was artstation and the tab was "top picks", this has 2 small problems, for some reason artstation has about 4 different sizes for each image and when scraping it will pull multiples of each file, which need to be filtered, and second is that it is a rolling site, so it updates quite often and has new content on the page, so the montage will probably look completly different, and i think that art station has changed some of there privacy setting so it may not gather the images like they did for my one.

#!/bin/bash
# show commands and stop if there is an error
set -ex
# make the directory if it is not there
mkdir -p downloads
# clean the directory if there are old results
rm -f downloads/*
# get 5 pages
for PAGE in {1..15}
do
# this is an example with a group
URL='https://www.artstation.com/artwork?sorting=picks' # artstation
#URL='http://www.beeple-crap.com/everydays_ten.php' #beeple-round10- 2016
echo "about to fetch URL: " $URL
sleep 3
# fetch the images
wget --adjust-extension \
--random-wait \
--limit-rate=100k \
--span-hosts \
--convert-links \
--backup-converted \
--no-directories \
--timestamping \
--recursive \
--level 2 \
--page-requisites \
--directory-prefix=downloads \
--execute robots=off \
--accept=.jpg \
$URL
# other unused arguments
# --recursive \
# --level 1 \
# --domains en.wikipedia.org \
# --reject-regex="-[0-9]+x[0-9]+.jpg" \
done
#!/bin/bash
if [ ! -d "/usr/local/anaconda/extras" ]; then
# Control will enter here if DIRECTORY doesn't exist.
echo "smartgrid program not found"
echo "please first install using directions on blackboard"
exit 1
fi
# show commands and stop if there is an error
set -ex
HOME="/usr/local/anaconda/extras/home"
export PATH="/usr/local/anaconda/bin:$PATH"
python /usr/local/anaconda/extras/smartgrid.py \
--aspect-ratio 2 \
--input-glob 'resized/*' \
--left-image 'resized/dd741496c909d1110beb47e4d5fcbc95.jpg' \
--right-image 'resized/0fb61b5c7c29a35719122e70132f7bd5.jpg' \
--output-path customgrid
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"></script>
<style>
body {padding: 0; margin: 0;}
#image-map {
width: 960;
height: 500;
border: 1px solid #ccc;
margin-bottom: 10px;
}
</style>
</head>
<body style="background-color:white">
<div id="image-map"></div>
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script language="javascript" type="text/javascript" src="zoom_image.js"></script>
<br>
<a href="montage.jpg">full size montage</a><br>
<a href="left_right.jpg">left right images</a><br>
<a href="tsne.png">tsne</a><br>
<a href="tsne_spun.png">tsne spun</a><br>
<a href="movement.png">movement</a><br>
</body>
#!/bin/bash
if [ -d "/usr/local/anaconda/extras" ]; then
# Control will enter here if DIRECTORY doesn't exist.
echo "smartgrid program already installed"
exit 1
fi
# show commands and stop if there is an error
set -ex
# make the directory if it is not there
mkdir -p /tmp/smartgrid
# clean the directory if there are old results
rm -f /tmp/smartgrid/*
cd /tmp/smartgrid
wget http://deeptom.staff.vuw.ac.nz:9000/smartgrid.tgz
cd /usr/local
tar xvfz /tmp/smartgrid/smartgrid.tgz
echo "DONE: smartgrid program installed"
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment