-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SVG Plugin]: SVG exporting does not carry over path specific stokeStyles #3
Comments
I ended up writing: function changeGraphics(data, graphicOptions) {
const options = {
fillStyle: graphicOptions.fillStyle || '#F00',
strokeStyle: graphicOptions.strokeStyle || '#F0F',
lineWidth: graphicOptions.lineWidth || 2,
lineCap: graphicOptions.lineCap || 'round',
lineJoin: graphicOptions.lineJoin || 'round',
miterLimit: graphicOptions.miterLimit || 10,
};
for (const opt in options) {
const val = options[opt];
data.sketch.callStack.push({ property: opt, value: val });
}
} Which seems to be working. The whole thing: mousedownBefore: function (elem, data, evt) {
var brushType = getBrushType();
if (brushType == 'eraser') {
// There is a method to set the brush in eraser mode.
data.options.graphics.lineWidth = 20;
data.sketch.eraser();
} else if (brushType == 'pencil') {
const color = getBrushColor() ?? "black";
// There is a method to get the default mode (pencil) back.
data.options.graphics.lineWidth = 2;
data.options.graphics.strokeStyle = color;
changeGraphics(data, data.options.graphics);
data.sketch.pencil();
}
} |
Hi, thanks for reporting. I believe you can use var brush = new jSketch('yourCanvas');
brush.saveGraphics({strokeStyle:'lime'}).restoreGraphics(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@luileito thanks for a great plugin. Super easy to use.
I have the following code in the
mousedownBefore
event.The function named
getBrushColor
is similar to yourgetBrushType
function. It returns a HEX color of the color selected on the page.Example UI:
However, when I execute the "svg.create" method the contents returned only use black.
Am I doing something wrong? Is this supported?
The text was updated successfully, but these errors were encountered: