kopia lustrzana https://github.com/inkstitch/inkstitch
assign thread color names in printout
rodzic
378f079e6d
commit
d4c95e080f
|
@ -55,7 +55,12 @@ class InkStitchMetadata(MutableMapping):
|
|||
# implement these five methods and we get a full dict-like interface.
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
self._find_item(name).text = json.dumps(value)
|
||||
item = self._find_item(name)
|
||||
|
||||
if value:
|
||||
item.text = json.dumps(value)
|
||||
else:
|
||||
item.getparent().remove(item)
|
||||
|
||||
def _find_item(self, name):
|
||||
tag = inkex.addNS(name, "inkstitch")
|
||||
|
|
|
@ -54,7 +54,7 @@ class _ThreadCatalog(Sequence):
|
|||
return
|
||||
|
||||
for thread in threads:
|
||||
nearest = palette.find_nearest(thread)
|
||||
nearest = palette.nearest_color(thread)
|
||||
|
||||
thread.name = nearest.name
|
||||
thread.number = nearest.number
|
||||
|
|
|
@ -24,17 +24,17 @@ function setPageNumbers() {
|
|||
|
||||
// Scale SVG (fit || full size)
|
||||
function scaleSVG(element, scale = 'fit') {
|
||||
|
||||
|
||||
// always center svg
|
||||
transform = "translate(-50%, -50%)";
|
||||
|
||||
|
||||
if(scale == 'fit') {
|
||||
var scale = Math.min(
|
||||
element.width() / element.find('svg').width(),
|
||||
element.width() / element.find('svg').width(),
|
||||
element.height() / element.find('svg').height()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
transform += " scale(" + scale + ")";
|
||||
var label = parseInt(scale*100);
|
||||
|
||||
|
@ -71,17 +71,17 @@ function setSVGTransform(figure, transform) {
|
|||
$(function() {
|
||||
setTimeout(ping, 1000);
|
||||
setPageNumbers();
|
||||
|
||||
|
||||
/* SCALING AND MOVING SVG */
|
||||
|
||||
|
||||
/* Mousewheel scaling */
|
||||
$('figure.inksimulation').on( 'DOMMouseScroll mousewheel', function (e) {
|
||||
if(e.ctrlKey == true) {
|
||||
|
||||
|
||||
var svg = $(this).find('svg');
|
||||
var transform = svg.css('transform').match(/-?[\d\.]+/g);
|
||||
var scale = parseFloat(transform[0]);
|
||||
|
||||
|
||||
if (e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0) {
|
||||
// scroll down = zoom out
|
||||
scale *= 0.97;
|
||||
|
@ -91,7 +91,7 @@ $(function() {
|
|||
//scroll up
|
||||
scale *= 1.03;
|
||||
}
|
||||
|
||||
|
||||
// set modified scale
|
||||
transform[0] = scale;
|
||||
transform[3] = scale;
|
||||
|
@ -102,19 +102,19 @@ $(function() {
|
|||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* Fit SVG */
|
||||
$('button.svg-fit').click(function() {
|
||||
var svgfigure = $(this).closest('figure');
|
||||
scaleSVG(svgfigure, 'fit');
|
||||
});
|
||||
|
||||
|
||||
/* Full Size SVG */
|
||||
$('button.svg-full').click(function() {
|
||||
var svgfigure = $(this).closest('figure');
|
||||
scaleSVG(svgfigure, '1');
|
||||
});
|
||||
|
||||
|
||||
/* Drag SVG */
|
||||
$('figure.inksimulation').on('mousedown', function(e) {
|
||||
var p0 = { x: e.pageX, y: e.pageY };
|
||||
|
@ -141,7 +141,7 @@ $(function() {
|
|||
// set it using setSVGTransform() to ensure that it's saved to the server
|
||||
setSVGTransform($(this), $(this).find('svg').css('transform'));
|
||||
});
|
||||
|
||||
|
||||
/* Apply transforms to All */
|
||||
$('button.svg-apply').click(function() {
|
||||
var transform = $(this).parent().siblings('svg').css('transform');
|
||||
|
@ -154,7 +154,7 @@ $(function() {
|
|||
|
||||
$('[contenteditable="true"]').on('focusout', function() {
|
||||
/* change svg scale */
|
||||
var content = $(this).html();
|
||||
var content = $.trim($(this).text());
|
||||
var field_name = $(this).attr('data-field-name');
|
||||
if(field_name == 'svg-scale') {
|
||||
var scale = parseInt(content);
|
||||
|
@ -295,4 +295,3 @@ $(function() {
|
|||
$.postJSON('/defaults', {'value': settings});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
|
||||
|
||||
{% if printview != 'detailedview' %}
|
||||
<div class="color-swatch">
|
||||
<div class="swatch-info">
|
||||
<svg width="100%" height="100%" class="color-swatch-svg" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect fill="rgb{{ color_block.color.rgb }}" stroke="rgb(192, 192, 192)" stroke-width="1px" width="100%" height="100%" />
|
||||
<text fill="rgb{{ color_block.color.font_color }}">
|
||||
<tspan dy="1.2em" x="2mm" y="2mm" class="color-name">{{ _('Color') }}: </tspan><tspan data-field-name="color-{{ color_block.color.hex_digits }}">{{ color_block.color.thread_name }}</tspan>
|
||||
<tspan dy="1.2em" x="2mm" y="2mm" class="color-name">{{ _('Color') }}: </tspan><tspan data-field-name="color-{{ color_block.color.hex_digits }}">{{ color_block.color.name }}</tspan>
|
||||
{# We don't want to see rgb if we have more than 7 colorSwatches #}
|
||||
{% if color_blocks|length < 7 %}
|
||||
<tspan dy="1.2em" x="2mm" class="color-rgb">{{ _('rgb') }}: {{ color_block.color.rgb }}</tspan>
|
||||
{% endif %}
|
||||
{# We don't want to see thread_used if we have more than 7 colorSwatches to show #}
|
||||
{% if color_blocks|length < 7 %}
|
||||
<tspan dy="1.2em" x="2mm" class="swatch-thread">{{ _('thread used') }}: {{ color_block.color.thread_description }}</tspan>
|
||||
{% if color_blocks|length < 7 %}
|
||||
<tspan dy="1.2em" x="2mm" class="swatch-thread" data-field-name="thread-{{ color_block.color.hex_digits }}">{{ _('thread') }}: {{ color_block.color.manufacturer }} {{ "#" + color_block.color.number if color_block.color.number }}</tspan>
|
||||
{% endif %}
|
||||
{# We don't want to see num_stitch if we have more than 49 colorSwatches to show #}
|
||||
{% if color_blocks|length < 49 %}
|
||||
|
@ -27,9 +27,9 @@
|
|||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% else %}
|
||||
|
||||
|
||||
<div class="color-swatch">
|
||||
<div class="swatch-info">
|
||||
<svg width="100%" height="100%" class="colorSwatchSVG" xmlns="http://www.w3.org/2000/svg">
|
||||
|
@ -37,9 +37,9 @@
|
|||
</svg>
|
||||
<div class="color-info">
|
||||
<div>
|
||||
<p><span class="color-name">{{ _('Color') }}:</span><span data-field-name="color-{{ color_block.color.hex_digits }}" contenteditable="true" data-placeholder="Enter thread name...">{{ color_block.color.thread_name }}</span></p>
|
||||
<p><span class="color-name">{{ _('Color') }}:</span><span data-field-name="color-{{ color_block.color.hex_digits }}" contenteditable="true" data-placeholder="Enter thread name...">{{ color_block.color.name }}</span></p>
|
||||
<p><span class="color-rgb">{{ _('rgb') }}:</span><span>{{ color_block.color.rgb }}</span></p>
|
||||
<p><span class="swatch-thread">{{ _('thread used') }}:</span><span>{{ color_block.color.thread_description }}</span></p>
|
||||
<p><span class="swatch-thread">{{ _('thread') }}:</span><span data-field-name="thread-{{ color_block.color.hex_digits }}" contenteditable="true">{{ color_block.color.manufacturer }} {{ "#" + color_block.color.number if color_block.color.number }}</span></p>
|
||||
<p><span class="swatch-stitches">{{ _('# stitches') }}:</span><span>{{ color_block.num_stitches }}</span></p>
|
||||
<p><span class="swatch-stops">{{ _('# stops') }}:</span><span>{{ color_block.num_stops }}</span></p>
|
||||
<p><span class="swatch-trims">{{ _('# trims') }}:</span><span>{{ color_block.num_trims }}</span></p>
|
||||
|
@ -47,5 +47,5 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{%endif %}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<header>
|
||||
{% include 'headline.html' %}
|
||||
</header>
|
||||
|
||||
|
||||
<main>
|
||||
<div class="operator-job-info">
|
||||
<div class="job-headline">
|
||||
|
@ -39,7 +39,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
{% for color_block in color_block_part %}
|
||||
|
||||
|
||||
<div style="display: table-row;">
|
||||
<p class="operator-svg operator-colorswatch">
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
|
@ -53,11 +53,12 @@
|
|||
{{ color_block.svg_preview|safe }}
|
||||
</p>
|
||||
<p>
|
||||
<span data-field-name="color-{{ color_block.color.hex_digits }}" contenteditable="true" data-placeholder="Enter thread name...">{{ color_block.color.thread_name }}</span>
|
||||
<span data-field-name="color-{{ color_block.color.hex_digits }}" contenteditable="true" data-placeholder="Enter thread name...">{{ color_block.color.name }}</span>
|
||||
<span>{{ color_block.color.rgb }}</span>
|
||||
<span data-field-name="thread-{{ color_block.color.hex_digits }}" contenteditable="true">{{ color_block.color.manufacturer }} {{ "#" + color_block.color.number if color_block.color.number }}</span>
|
||||
</p>
|
||||
<p>
|
||||
<span>{{ _('thread used') }}: {{ color_block.color.thread_description }}</span>
|
||||
<span>{{ _('thread used') }}:</span>
|
||||
<span>{{ _('# stitches') }}: {{ color_block.num_stitches }}</span>
|
||||
</p>
|
||||
<p>
|
||||
|
@ -71,7 +72,5 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
||||
{% include 'footer.html' %}
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue