Made more locale-related fixes, fixed issue 544 using codedread's help
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1550 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -7592,9 +7592,9 @@ function BatchCommand(text) {
|
||||
this.changeSelectedAttribute("opacity", val);
|
||||
};
|
||||
|
||||
this.getBlur = function() {
|
||||
this.getBlur = function(elem) {
|
||||
var val = 0;
|
||||
var elem = selectedElements[0];
|
||||
// var elem = selectedElements[0];
|
||||
|
||||
if(elem) {
|
||||
var filter_url = elem.getAttribute('filter');
|
||||
@@ -7606,68 +7606,107 @@ function BatchCommand(text) {
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
this.setBlur = function(val, noUndo) {
|
||||
// Looks for associated blur, creates one if not found
|
||||
var elem_id = selectedElements[0].id;
|
||||
var filter = getElem(elem_id + '_blur');
|
||||
|
||||
val -= 0;
|
||||
|
||||
// Blur found!
|
||||
if(filter) {
|
||||
if(val === 0) {
|
||||
$(filter).remove();
|
||||
} else {
|
||||
var elem = filter.firstChild;
|
||||
if(noUndo) {
|
||||
this.changeSelectedAttributeNoUndo('stdDeviation', val, [elem]);
|
||||
} else {
|
||||
this.changeSelectedAttribute('stdDeviation', val, [elem]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Not found, so create
|
||||
var newblur = addSvgElementFromJson({ "element": "feGaussianBlur",
|
||||
"attr": {
|
||||
"in": 'SourceGraphic',
|
||||
"stdDeviation": val
|
||||
}
|
||||
});
|
||||
|
||||
filter = addSvgElementFromJson({ "element": "filter",
|
||||
"attr": {
|
||||
"id": elem_id + '_blur'
|
||||
}
|
||||
});
|
||||
|
||||
filter.appendChild(newblur);
|
||||
findDefs().appendChild(filter);
|
||||
}
|
||||
|
||||
if(val === 0) {
|
||||
selectedElements[0].removeAttribute("filter");
|
||||
} else {
|
||||
this.changeSelectedAttribute("filter", 'url(#' + elem_id + '_blur)');
|
||||
|
||||
if(val > 3) {
|
||||
// TODO: Create algorithm here where size is based on expected blur
|
||||
assignAttributes(filter, {
|
||||
x: '-50%',
|
||||
y: '-50%',
|
||||
width: '200%',
|
||||
height: '200%',
|
||||
}, 100);
|
||||
} else {
|
||||
filter.removeAttribute('x');
|
||||
filter.removeAttribute('y');
|
||||
filter.removeAttribute('width');
|
||||
filter.removeAttribute('height');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
(function() {
|
||||
var cur_command = null;
|
||||
var filter = null;
|
||||
|
||||
canvas.setBlurNoUndo = function(val) {
|
||||
if(!filter) {
|
||||
canvas.setBlur(val);
|
||||
return;
|
||||
}
|
||||
canvas.changeSelectedAttributeNoUndo("stdDeviation", val, [filter.firstChild]);
|
||||
}
|
||||
|
||||
function finishChange() {
|
||||
var bCmd = canvas.finishUndoableChange();
|
||||
cur_command.addSubCommand(bCmd);
|
||||
addCommandToHistory(cur_command);
|
||||
cur_command = null;
|
||||
filter = null;
|
||||
}
|
||||
|
||||
canvas.setBlur = function(val, complete) {
|
||||
if(cur_command) {
|
||||
finishChange();
|
||||
return;
|
||||
}
|
||||
|
||||
// Looks for associated blur, creates one if not found
|
||||
var elem = selectedElements[0];
|
||||
var elem_id = elem.id;
|
||||
filter = getElem(elem_id + '_blur');
|
||||
|
||||
val -= 0;
|
||||
|
||||
var batchCmd = new BatchCommand();
|
||||
|
||||
// Blur found!
|
||||
if(filter) {
|
||||
if(val === 0) {
|
||||
var parent = filter.parentNode;
|
||||
$(filter).remove();
|
||||
RemoveElementCommand(filter, parent);
|
||||
filter = null;
|
||||
}
|
||||
} else {
|
||||
// Not found, so create
|
||||
var newblur = addSvgElementFromJson({ "element": "feGaussianBlur",
|
||||
"attr": {
|
||||
"in": 'SourceGraphic',
|
||||
"stdDeviation": val
|
||||
}
|
||||
});
|
||||
|
||||
filter = addSvgElementFromJson({ "element": "filter",
|
||||
"attr": {
|
||||
"id": elem_id + '_blur'
|
||||
}
|
||||
});
|
||||
|
||||
filter.appendChild(newblur);
|
||||
findDefs().appendChild(filter);
|
||||
|
||||
batchCmd.addSubCommand(new InsertElementCommand(filter));
|
||||
}
|
||||
|
||||
var changes = {filter: elem.getAttribute('filter')};
|
||||
|
||||
if(val === 0) {
|
||||
elem.removeAttribute("filter");
|
||||
batchCmd.addSubCommand(new ChangeElementCommand(elem, changes));
|
||||
} else {
|
||||
this.changeSelectedAttribute("filter", 'url(#' + elem_id + '_blur)');
|
||||
|
||||
batchCmd.addSubCommand(new ChangeElementCommand(elem, changes));
|
||||
|
||||
if(val > 3) {
|
||||
// TODO: Create algorithm here where size is based on expected blur
|
||||
assignAttributes(filter, {
|
||||
x: '-50%',
|
||||
y: '-50%',
|
||||
width: '200%',
|
||||
height: '200%',
|
||||
}, 100);
|
||||
} else {
|
||||
filter.removeAttribute('x');
|
||||
filter.removeAttribute('y');
|
||||
filter.removeAttribute('width');
|
||||
filter.removeAttribute('height');
|
||||
}
|
||||
}
|
||||
|
||||
cur_command = batchCmd;
|
||||
canvas.beginUndoableChange("stdDeviation", [filter.firstChild]);
|
||||
if(complete) {
|
||||
canvas.setBlurNoUndo(val);
|
||||
finishChange();
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
||||
this.getFillOpacity = function() {
|
||||
return cur_shape.fill_opacity;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user