explanatory preview for contrast, sharpening and dithering

This commit is contained in:
Teja 2015-08-10 22:43:45 +02:00
parent b2a9c392fe
commit 383326932e
12 changed files with 105 additions and 38 deletions

View file

@ -28,7 +28,7 @@ table th.settings_plugin_svgtogcode_profiles_key,table td.settings_plugin_svgtog
}
.slider_manual_input.noleftspace{
margin-left: 0em;
margin-left: 0;
}
svg text {
@ -38,4 +38,30 @@ svg text {
cursor: default;
pointer-events: none;
}
}
.img_slider{
margin-bottom: 24px;
}
.img_preprocessing_preview {
background-size: 150px;
display: inline-block;
width: 150px;
height: 150px;
}
.img_preprocessing_preview.after {
position:relative;
}
.img_preprocessing_preview.after>div {
position: absolute;
top:0;
left:0;
}
.img_preprocessing_preview.after .contrast,
.img_preprocessing_preview.after .sharpened,
.img_preprocessing_preview.after .sharpened_contrast {
opacity: 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -42,6 +42,21 @@ $(function(){
self.imgDithering = ko.observable(false);
self.imgSharpening = ko.observable(1);
self.imgContrast = ko.observable(1);
// preprocessing preview
self.sharpenedPreview = ko.computed(function(){
if(self.imgDithering()) return 0;
else {
return (self.imgSharpening() - 1) - (self.imgContrast() - 1)/2;
}
}, self);
self.contrastPreview = ko.computed(function(){
if(self.imgDithering()) return 0;
else {
return (self.imgContrast() - 1) - (self.imgSharpening() - 1)/2;
}
}, self);
self.maxSpeed.subscribe(function(val){
self._configureFeedrateSlider();
@ -271,7 +286,7 @@ $(function(){
self.files.conversion = self;
self._configureIntensitySlider();
self._configureFeedrateSlider();
// self._configureImgSliders();
self._configureImgSliders();
};
self._configureIntensitySlider = function() {
@ -331,24 +346,30 @@ $(function(){
};
self._configureImgSliders = function() {
self.intensitySlider = $("#svgtogcode_img_intensity_slider").slider({
//id: "svgtogcode_img_intensity_slider_impl",
//reversed: false,
//selection: "after",
// orientation: "horizontal",
// min: 0,
// max: 1000,
// step: 1,
value: [200,500],
// enabled: true,
//formatter: function(value) { return "" ; }
}).on("slideStop", function(ev){
//self.imgIntensity(ev.value);
//console.log(ev.value);
self.contrastSlider = $("#svgtogcode_contrast_slider").slider({
step: .1,
min: 1,
max: 2,
value: 1,
tooltip: 'hide',
}).on("slide", function(ev){
self.imgContrast(ev.value);
});
self.sharpeningSlider = $("#svgtogcode_sharpening_slider").slider({
step: .1,
min: 1,
max: 2,
value: 1,
class: 'img_slider',
tooltip: 'hide',
}).on("slide", function(ev){
self.imgSharpening(ev.value);
});
};
}
ADDITIONAL_VIEWMODELS.push([VectorConversionViewModel,

View file

@ -231,10 +231,14 @@ Snap.plugin(function (Snap, Element, Paper, global) {
this.data('ftCallbacks').push(callback);
}
};
Element.prototype.ftDisableRotate = function(){
this.data('block_rotation', true);
};
});
function rectObjFromBB ( bb ) {
return { x: bb.x, y: bb.y, width: bb.width, height: bb.height }
return { x: bb.x, y: bb.y, width: bb.width, height: bb.height };
}
function elementDragStart( mainEl, x, y, ev ) {
@ -292,11 +296,13 @@ Snap.plugin(function (Snap, Element, Paper, global) {
var unscale = mainEl.data('unscale');
handle.attr({ cx: +handle.data('ocx') + dx*unscale, cy: +handle.data('ocy') + dy*unscale });
var angle = Snap.angle( mainBB.cx, mainBB.cy, handle.attr('cx'), handle.attr('cy') ) - 180;
if(event.shiftKey){
angle = Math.round(angle/30) * 30;
}
mainEl.data("angle", angle );
if(!mainEl.data('block_rotation')){
var angle = Snap.angle( mainBB.cx, mainBB.cy, handle.attr('cx'), handle.attr('cy') ) - 180;
if(event.shiftKey){
angle = Math.round(angle/30) * 30;
}
mainEl.data("angle", angle );
}
var distance = calcDistance( mainBB.cx, mainBB.cy, handle.attr('cx'), handle.attr('cy') );
var scale = distance / mainEl.data("scaleFactor");

View file

@ -406,6 +406,7 @@ $(function(){
newImg.attr({id: previewId, filter: 'url(#grayscale_filter)'});
snap.select("#userContent").append(newImg);
newImg.transformable();
newImg.ftDisableRotate();
newImg.ftRegisterCallback(self.svgTransformUpdate);
file.id = previewId;
file.previewId = previewId;

View file

@ -58,28 +58,41 @@
</div>
</div>
<div class="control-group" data-bind="visible: showExpertSettings">
<label class="control-label">{{ _('Preprocessing') }}</label>
<p >{{ _('Image Preprocessing') }}</p>
<div class="controls">
<div class="img_preprocessing_preview before" style="background-image:url(/plugin/svgtogcode/static/img/kitty_grayscale.png);" >before</div>
<div class="img_preprocessing_preview after" style="background-image:url(/plugin/svgtogcode/static/img/kitty_grayscale.png);" >after
<div class="img_preprocessing_preview contrast" style="background-image:url(/plugin/svgtogcode/static/img/kitty_contrast.png);" data-bind="style: { opacity: contrastPreview }" ></div>
<div class="img_preprocessing_preview sharpened" style="background-image:url(/plugin/svgtogcode/static/img/kitty_sharpened.png);" data-bind="style: { opacity: sharpenedPreview }" ></div>
<div class="img_preprocessing_preview dithered" style="background-image:url(/plugin/svgtogcode/static/img/kitty_dithered_150.png);" data-bind="visible: imgDithering"></div>
</div>
</div>
<div data-bind="disable:imgDithering ">
<label class="control-label">{{ _('Contrast') }}</label>
<div class="controls img_slider">
<input id="svgtogcode_contrast_slider" type="text" data-bind="value: imgContrast" >
</div>
<div style="clear:both"></div>
<label class="control-label">{{ _('Sharpening') }}</label>
<div class="controls img_slider">
<input id="svgtogcode_sharpening_slider" class="uninitialized" type="text" data-bind="value: imgSharpening">
</div>
<div style="clear:both"></div>
</div>
<label class="control-label">{{ _('Dithering') }}</label>
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: imgDithering">{{ _('Dithering') }}
</label>
</div>
<div class="controls">
<label class="XXcontrol-label">
<input id="svgtogcode_img_sharpening" class="" size="2" type="text" data-bind="value: imgContrast">
{{ _('Contrast') }}</label>
</div>
<div class="controls">
<label class="XXcontrol-label">
<input id="svgtogcode_img_sharpening" class="" size="2" type="text" data-bind="value: imgSharpening">
{{ _('Sharpening') }}</label>
</div>
</div>
</div>
<p>{{ _('Store GCode after conversion:') }}</p>
<div class="control-group" data-bind="visible: showExpertSettings ">
<label class="control-label">{{ _('GCode Filename') }}</label>
<div class="controls">