Syntax
svgpolylineofCPL(fid,CPL,[stroke,width,fill])
Input Parameter
fid : | | File Identifyer |
CPL : | | Close Contour List |
stroke : | | red, blue, etc. |
width : | | 1, 3 |
fill : | | none, or red, blue, etc. |
Examples
CPLwriteSVG(CPLsample(10))
Copyright 2015-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, svgpolylineofCPL
, is designed to write closed contour lists (CPLs) as polygons or polyline elements in SVG format, typically for use with a laser cutter. The function is part of the SG-Library and was created by Tim Lueth.
Input Parameters
- fid: A file identifier where the SVG content will be written.
- CPL: A Close Contour List, which is a list of points defining the shape to be drawn.
- stroke (optional): The color of the line, defaulting to 'red'.
- width (optional): The width of the line, defaulting to 0.1.
- fill (optional): The fill color of the shape, defaulting to 'none'.
Algorithm Steps
- Initialize default values for
stroke
, width
, and fill
if they are not provided in varargin
.
- Convert the input
CPL
to a format suitable for processing using CPLofPL
.
- Determine the number of separate contours in
CPL
using separateNaN
.
- Iterate over each contour:
- Extract the current contour using
separateNaN
.
- Check if the contour is closed by comparing the first and last points.
- If closed, write a
<polygon>
element to the file. If not, write a <polyline>
and issue a warning.
- For each point in the contour, write its coordinates to the file in the format
x,y
.
- Complete the SVG element with the specified
stroke
, stroke-width
, and fill
attributes.
Algorithm explaination created using ChatGPT on 2025-08-19 07:33. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21