stroke() in Cairo applies a stroke of a single specified width to a line path.
I'd like to draw a path with a varying width (thinner when the user was drawing faster, thicker when slower). Is this possible in Cairo?
Use cairo_set_line_width to set it and "split" the path in more than one piece. Unluckly as you noticed cairo_set_line_width is the width for the whole current path (since it sets the attribute as if you are choosing a pen to draw that path):
cairo_set_line_width
«As with the other stroke parameters, the current line width is examined by cairo_stroke(), cairo_stroke_extents(), and cairo_stroke_to_path(), but does not have any effect during path construction.»
Related
I have an SVG (https://drive.google.com/open?id=1SBA2Xsi228agUO65FmtLwjg6Zuoq59-5) which is shifted. I have tried to change parameters such as width, height, viewBox, and transform attributes. I do not have a clear understanding of this area and it is not as simple as I estimated. I need to draw only the below part and remove the padding.
I do not want to use JS for this. Everything should be in the SVG file and I use it in the tag. The SVG file should not hard code the width and height and should scale as per the tag. It appears that the SVG file draws with left padding by default. I am trying to find the line in SVG that does it.
I am new to inkscape and I would like to know if there is anyway to increase/change the width of a line without changing its stroke width.
I want the line to have a fill color and a narrow black stroke (preferably 2px).
Thanks
You can convert a thick-stroked curve using the Stroke to path command (in the Path menu): this won't change its aspect, but instead of being defined as a line with a given width, this will give a polygonal shape (a sort of ribbon). Then you can give this ribbon a stroke colour and thickness (Shift-click on the chosen colour).
In the Inkscape version 1.0 there are four buttons on the right side of the toolbar. The first one is responsible for enabling of scaling the stroke while changing the width of an object. Click it to disable this kind of scaling.
There's a small trick to change the width line as Inkscape doesn't provide a mechanism.
Close the current file in Inkscape
Edit your file in a normal ASCII Editor
Find your object (e.g. a spline), it will be a path ... statement
Change the "stroke-width" manually e.g. as
<path style="fill:none;stroke:#80ffff;stroke-width:0.164583px; ....
Tip: If you have a large file, you can assign your object a unique color (here 80FFFF) and you can then search that color code "80FFFF" in your ASCII Editor.
I want to convert a svg to a png with the inkscape command line tool. Despite of what is specified in the svg i want to set both the width of the resulting png and the dpi to be used. From the inkscape docu it seems this is not possible:
-w WIDTH, --export-width=WIDTH
The width of generated bitmap in pixels. This value overrides the --export-dpi setting (or the DPI hint if used with --export-use-hints).
I can't really understand how this could be as the width and the dpi used should not be directly related. How can I achieve to set both values.
Thanks, Martin
Ok got it I think, here as it goes in my concrete example:
In the svg the width is 2480 pixel (what you need for DinA4 300 dpi print). Now my mistake was to add "-d 300" to the inkscape call which doesn't make sense if the svg does not give the width in some unit. When doing so the resultant image has a width of 2480 * 300 / 90 = 8267 pixel . So if working with pixel in the svg you need to be aware of the fact the inkscape interprets this as 90 dpi ...
Well i guess only my confusion here yet happy to share ;-)
I am trying to mimic the behavior of markers on white boards and was wondering if it I can do it with svg polylines. I know the stroke width can be set but can be it changed to vary depending on the velocity of the mouse which I can figure out or is it just a constant value for the stroke?
Or if you wanted to use SVG, instead of using a <polyline>, use a series of connected <line>s
You can't have multiple stroke widths in a single polyline element. I think canvas is probably a better fit for this task.
I have a big (12 MB) SVG file containing many curved paths all having the same stroke width. Now I'd like to transform the stroke-width in a way that it depends on some mathematical function which takes the coordinates of the path segment (or even better: of the actual points on the path segment) as input.
The only way i found so far is to cut the paths in segments using inkscape and then modifying the stroke-width using the etree library for python. But what I really want is continuously decreasing/increasing stroke width like in inkscapes calligraphy tool.