Commit 6ee8d7bc authored by antoine's avatar antoine

Merge branch 'master' of gitlab.constantvzw.org:osp/workshop.metahoguet

parents 2a2b85ce e3b6dd3c
for (( ; ; ));
for (( ; ; ));
do
mkdir -p svg eps
rm -f svg/*.svg
rm -f eps/*.eps
echo 'prologues := 3; outputtemplate := "%c.eps";' > eps/metahoguet.eps.mp
echo 'outputtemplate := "%c.svg";' > svg/metahoguet.svg.mp
curl http://osp.constantvzw.org:9999/p/metahoguet/export/txt | tee -a eps/metahoguet.eps.mp >> svg/metahoguet.svg.mp
cd svg
mpost -interaction=batchmode -s 'outputformat="svg"' metahoguet.svg.mp
cd ..
cd eps
mpost -interaction=batchmode -s 'outputformat="eps"' eps/metahoguet.eps.mp
cd ..
sleep 3
sleep 2
done
<html>
<head>
<meta charset="UTF-8">
<title>- </title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<style type="text/css" media="screen">
<head>
<meta charset="UTF-8">
<title>- </title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<style type="text/css" media="screen">
img {
height: 200px;;
width: auto;
overflow: visible;
overflow: visible;
}
footer{
bottom: 0px;
......@@ -37,81 +37,85 @@
color: grey;
}
</style>
</head>
<body>
<footer>
<button onclick="Zoom('up')">+</button>
<button onclick="Zoom('down')">-</button>
<button onclick="Compare()">Compare</button>
<span id="type"></span>
</footer>
<script>
var elt = [];
function splitHash(){
var startImg = window.location.hash;
startImg = startImg.substring(2);
elt = startImg.split("-");
}
splitHash();
if(elt.length > 0){
for(i=0; i < elt.length; i++){
console.log(elt[i]);
$( "body" ).append('<img id="letter_'+i+'" title="cliquez pour imprimer" src="svg/'+elt[i]+'.svg" />');
}
}
function Zoom(valZ){
var imgH = $('img').height();
if(valZ == 'up'){
imgH = imgH + 50;
}else if (valZ == 'down'){
imgW = imgW - 50;
}
$('img').css("height", imgW);
}
</head>
<body>
<footer>
<button onclick="Zoom('up')">+</button>
<button onclick="Zoom('down')">-</button>
<button onclick="Compare()">Compare</button>
<span id="type"></span>
</footer>
<script>
var elt = [];
function splitHash(){
var startImg = window.location.hash;
startImg = startImg.substring(2);
elt = startImg.split("-");
}
function Compare(){
$('img').toggleClass('compare');
}
splitHash();
function testing () {
$("body").keydown( function( event ) {
if (event.key == "Backspace" ) {
var startImg = window.location.hash;
var newUrl = startImg.lastIndexOf('-');
window.location.hash = startImg.substring(0, newUrl);
$('img').last().remove();
if(elt.length > 0){
for(i=0; i < elt.length; i++){
console.log(elt[i]);
$( "body" ).append('<img id="letter_'+i+'" title="cliquez pour imprimer" src="svg/'+elt[i]+'.svg?'+ (new Date()).getTime() + '" />');
}
}
}
})
$( "body" ).keypress(function(event) {
var savehash = window.location.hash;
savehash = savehash.substring(1);
$( "body" ).append('<img src="svg/'+event.keyCode+'.svg" />');
console.log(event.keyCode);
savehash += '-'+event.keyCode;
window.location.hash = savehash;
Zoom();
});
function Zoom(valZ){
var imgH = $('img').height();
if(valZ == 'up'){
imgH = imgH + 50;
}else if (valZ == 'down'){
imgW = imgW - 50;
}
$('img').css("height", imgH);
}
}
$("body").on("click", "img", function(){
var result = window.confirm('voulez-vous imprimer ce glyph ?');
function Compare(){
$('img').toggleClass('compare');
}
if(result){
var path = $(this).attr('src').replace(/svg/g, 'eps');
function testing () {
$("body").keydown( function( event ) {
if (event.key == "Backspace" ) {
var startImg = window.location.hash;
var newUrl = startImg.lastIndexOf('-');
window.location.hash = startImg.substring(0, newUrl);
$('img').last().remove();
}
})
$.get('/api/ploteps/', { epsfile : path });
}
});
setTimeout(function(){
window.location.reload(1);
}, 5000);
testing();
</script>
</body>
$( "body" ).keypress(function(event) {
var savehash = window.location.hash;
savehash = savehash.substring(1);
$( "body" ).append('<img src="svg/'+event.keyCode+'.svg?'+ (new Date()).getTime() + '" />');
console.log(event.keyCode);
savehash += '-'+event.keyCode;
window.location.hash = savehash;
Zoom();
});
}
</html>
$("body").on("click", "img", function(){
var result = window.confirm('voulez-vous imprimer ce glyph ?');
if(result){
var path = $(this).attr('src').split('?')[0].replace(/svg/g, 'eps');
$.get('/api/ploteps/', { epsfile : path });
}
});
setInterval(function(){
stamp = (new Date).getTime();
$("img").each(function () {
var src = $(this).attr('src').split('?')[0];
$(this).attr('src', src + '?' + stamp);
});
}, 7000);
testing();
</script>
</body>
</html>
......@@ -10,51 +10,81 @@ from plottertools.textbox import Textbox
from chiplotle.geometry.core.coordinate import Coordinate
from settings import db
import os.path
import shutil
from flask import Flask, Response, app, request, render_template
marginleft = 30 # margin left in mm
marginbottom = (297 / 3) # margin bottom in mm
marginbottom = (271.75 / 3) # margin bottom in mm
page = {
'left': marginleft * -40,
'right': (210 - marginleft) * 40,
'bottom': marginbottom * -40,
'top': (297 - marginbottom) * 40
'left': int(marginleft * -40),
'right': int((190 - marginleft) * 40),
'bottom': int(marginbottom * -40),
'top': int((271.75 - marginbottom) * 40)
}
pen = 1
speed = 10
force = 1
font=Font(path='fonts/converted/futural.fnt', resolution=1, scale=3)
font=Font(path='fonts/converted/futural.fnt', resolution=1, scale=4.5)
app = Flask(__name__)
@app.route("/api/ploteps/")
def ploteps():
epsfile = request.args.get('epsfile')
hpglfile = './{}.hpgl'.format(os.path.splitext(epsfile)[0])
charnum = os.path.splitext(os.path.basename(epsfile))[0]
svgfile = './svg/{}.svg'.format(charnum)
hpglfile = './hpgl/{}.hpgl'.format(charnum)
shutil.copy(svgfile, './svg/snaps/{}-{}.svg'.format(charnum, int(time.time())))
# converting eps to hpgl
subprocess.call([
'./eps2hpgl.sh',
'./{0}'.format(epsfile)
'pstoedit',
'-f',
'plot-hpgl',
epsfile,
hpglfile
])
handle = open(hpglfile)
shape = ''.join(handle.readlines()).replace('\n', '')
handle = open(hpglfile)
dirtyhpgl = ''.join(handle.readlines()).replace('\n', '')
cleanhpglchunks = []
pen = 1
pencount = 4
penmap = {}
for chunk in dirtyhpgl.split(';'):
if chunk[0:2] in ['PA', 'PR', 'PU', 'PD']:
cleanhpglchunks.append(chunk)
elif chunk[0:2] == 'SP':
sourcepen = int(chunk[2])
if not sourcepen in penmap:
pen += 1
if pen > pencount:
pen = 1
penmap[sourcepen] = pen
cleanhpglchunks.append('SP{}'.format(penmap[sourcepen]))
cleanhpgl = ';'.join(cleanhpglchunks)
textbox = Textbox(
font=font,
width = 50 * 40,
position = Coordinate(page['right'] - (55 * 40), page['bottom'] + (12 * 40)),
width = 75 * 40,
position = Coordinate(page['right'] - (80 * 40), page['bottom'] + (12 * 40)),
align = Textbox.alignLeft,
lineHeight=1.40
)
textbox.insertText('{0} \n{1} \n\ntype.code, Maison du Livre, Bruxelles'.format(hpglfile, datetime.now().strftime("%d-%m-%Y %H:%M")))
hpgl = 'SC{0},{1},{2},{3};SP{4};FS{5};VS{6};PU;{7};PU;'.format(page['left'], page['right'], page['bottom'], page['top'], pen, force, speed, shape)
hpgl = 'IN;RO90;IP0,0,7600,10870;SC{0},{1},{2},{3};FS{5};SP{4};VS{6};PU;{7};PU;'.format(page['left'], page['right'], page['bottom'], page['top'], pen, force, speed, cleanhpgl)
# hpgl += box((page['left'] + 200, page['bottom'] + 200), 200 * 40, 287 * 40)
hpgl += textbox.hpgl()
......
../pad/hpgl
\ No newline at end of file
......@@ -25,7 +25,7 @@ while True:
if plot:
try:
plotter.write(str(plot['hpgl'].decode('utf-8')))
plotter.write('IN;{};PG;'.format(str(plot['hpgl'].decode('utf-8'))))
plotter._serial_port.flush()
......
../pad/svg/
\ No newline at end of file
% To run the API
screen -S api
cd /home/pi/Documents/osp.work.metahoguet/plotter
cd /home/pi/Documents/osp.workshop.metahoguet/plotter
. /home/pi/venvs/metahoguet/bin/activate
python wsgi.py
gunicorn --bind 0.0.0.0:5555 --workers 3 wsgi:app
sudo service nginx reload
% !!! ctr+a d
% To run the plotter
screen -S plotter
cd /home/pi/Documents/osp.work.metahoguet/plotter
cd /home/pi/Documents/osp.workshop.metahoguet/plotter
. /home/pi/venvs/metahoguet/bin/activate
python runner.py
......@@ -20,7 +21,7 @@ python runner.py
% To run the mpost downloaded
screen -S mpost
cd /home/pi/Documents/osp.work.metahoguet/pad
cd /home/pi/Documents/osp.workshop.metahoguet/pad
bash exportMeta.sh
% !!! ctr+a d
......@@ -34,6 +35,6 @@ screen -r plotter
python runner.py
% !!! ctr+a d
screen -S mpost
screen -r mpost
bash exportMeta.sh
% !!! ctr+a d
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment