1
0
Fork 0
freesewing/packages/brian/index.html

132 lines
3.8 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
2018-07-16 15:21:26 +00:00
<title>Brian</title>
</head>
<body>
<div id="svg"></div>
<script type="text/javascript" src="freesewing.js"></script>
<script type="text/javascript" src="tmp/cutonfold.js"></script>
<script type="text/javascript" src="tmp/dimension.js"></script>
<script type="text/javascript" src="tmp/logo.js"></script>
<script type="text/javascript" src="tmp/title.js"></script>
<script type="text/javascript" src="dist/browser.js"></script>
2018-07-26 13:43:45 +00:00
<script type="text/javascript" src="tmp/theme.js"></script>
<script type="text/javascript" src="tmp/designer.js"></script>
2018-08-10 13:38:02 +02:00
<script type="text/javascript" src="tmp/models.js"></script>
<script type="text/javascript" src="tmp/antmantest.js"></script>
<script>
2018-08-07 16:42:48 +02:00
var debug = {
name: 'debug',
hooks: {
2018-08-08 14:38:19 +02:00
debug: function (next, d='',e='',b='',u='',g='') {
console.log('%cDebug', 'color: #dd69dd; font-weight: bold', d,e,b,u,g);
2018-08-07 16:42:48 +02:00
next();
}
}
};
var pattern = freesewing.patterns.brian
2018-08-07 16:42:48 +02:00
.with(debug)
.with(freesewing.plugins.theme)
.with(freesewing.plugins.designer)
/*
pattern.on('preSample', function(next) {
console.log('preSample hook');
next();
});
pattern.on('postSample', function(next) {
console.log('postSample hook');
next();
});
pattern.on('preDraft', function(next) {
console.log('preDraft hook', JSON.parse(JSON.stringify(this)));
next();
});
pattern.on('postDraft', function(next) {
console.log('postDraft hook', JSON.parse(JSON.stringify(this)));
next();
});
pattern.on('preRender', function(next) {
console.log('preRender hook', this);
next();
});
pattern.on('postRender', function(next) {
console.log('postRender hook', this);
next();
});
pattern.on('preDraft', function(next) {
console.log('%cpreDraft hook', 'color: red', this);
next();
});
pattern.on('postDraft', function(next) {
console.log('%cpostDraft hook', 'color: red', this);
next();
});
pattern.on('insertText', function(next) {
console.log('%cinsertText hook', 'color: red', this.text);
this.text = this.text.toUpperCase();
next();
});
*/
pattern.on('preDraft', function(next) {
console.log('%cpreDraft hook', 'color: red', this);
for(let m in this.config.measurements) {
let measurement = this.config.measurements[m];
if(!this.context.settings.measurements[measurement]) {
this.debug('Missing measurement:', measurement);
this.debug('All measurements:', this.settings.measurements);
throw `Missing measurement: ${measurement}`;
}
}
next();
});
2018-08-07 16:42:48 +02:00
//pattern.settings.paperless = true;
2018-08-10 13:38:02 +02:00
pattern.settings.measurements = freesewing.models.men.manSize36;
2018-08-10 13:38:02 +02:00
pattern.settings.sa = 10;
pattern.settings.units = 'metric';
pattern.settings.sample = {
2018-08-09 16:51:39 +02:00
type: 'measurement',
measurement: 'shoulderToShoulder'
}
pattern.debug('debug test from index', 'foo');
//pattern.sampleOption('sleeveLengthBonus');
2018-08-10 13:38:02 +02:00
//pattern.sampleMeasurement('bicepsCircumference');
//pattern.sampleModels(freesewing.antmantest);
pattern.draft();
document.getElementById("svg").innerHTML = pattern.render();
function pointHover(evt) {
var point = evt.target;
var id = point.id;
var cx = point.getAttribute('x');
var cy = point.getAttribute('y');
var name = point.getAttribute('data-point');
var part = point.getAttribute('data-part');
console.log(name+' ('+cx+', '+cy+') @ '+part);
var scale = 2;
cx = cx-scale*cx;
cy = cy-scale*cy;
point.setAttribute("transform", 'matrix('+scale+', 0, 0, '+scale+', '+cx+', '+cy+')');
pointUnhover(id);
}
function pointUnhover(id) {
setTimeout(function(){
document.getElementById(id).removeAttribute("transform", '');
}, 500);
}
</script>
</body>
</html>