mirror of
https://git.sleeping.town/mirrors/foxy-moxy
synced 2024-11-15 00:27:43 +00:00
Merge branch 'master' of github.com:Patreon/foxy-moxy
This commit is contained in:
commit
173798d345
3 changed files with 159 additions and 159 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1,3 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
|
.DS_Store
|
||||||
|
images/*
|
||||||
|
|
0
images/.placeholder
Normal file
0
images/.placeholder
Normal file
32
server.js
32
server.js
|
@ -173,32 +173,30 @@ var radial = function(ctx,width,height){
|
||||||
|
|
||||||
var Canvas = require('canvas');
|
var Canvas = require('canvas');
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
|
app.use(express.static(__dirname + '/images'));
|
||||||
|
|
||||||
app.get('/:width', function(req, res) {
|
app.get('/:width', function(req, res) {
|
||||||
|
|
||||||
var width = Math.min(1000, Math.max(0, parseInt(req.params.width) || 500));
|
var width = 200;
|
||||||
var height = width;
|
var height = 200;
|
||||||
|
var Canvas = require('canvas');
|
||||||
|
var Image = Canvas.Image;
|
||||||
var Canvas = require('canvas')
|
var canvas = new Canvas(width, height);
|
||||||
, Image = Canvas.Image
|
var ctx = canvas.getContext('2d');
|
||||||
, canvas = new Canvas(width, height)
|
|
||||||
, ctx = canvas.getContext('2d');
|
|
||||||
|
|
||||||
textIcon(canvas, width, height);
|
textIcon(canvas, width, height);
|
||||||
res.send(canvas.toDataURL());
|
|
||||||
/*
|
|
||||||
var img = new Buffer(canvas.toDataURL(), 'base64');
|
var img = new Buffer(canvas.toDataURL(), 'base64');
|
||||||
console.log(img.length);
|
var fileName = "fox" + Math.floor(Math.random() * 10000) + ".png";
|
||||||
|
|
||||||
res.writeHead(200, {
|
fs.writeFile(__dirname + '/images/' + fileName, canvas.toBuffer(), function(err) {
|
||||||
'Content-Type': 'image/png',
|
console.log('error', err);
|
||||||
'Content-Length': img.length
|
|
||||||
});
|
});
|
||||||
res.end();
|
|
||||||
*/
|
console.log(fileName);
|
||||||
|
res.redirect(301, fileName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue