Paddel generieren (units will be millimeters)

Paddel generieren

Dxf options

Wird generiert...

Lade das Paddel herunter

Download Paddel

measurement
                        var makerjs = require("makerjs");
                        var cutlayer = "blue";
                        
                        function cone() {
                            return {
                                paths: {
                                    l1: new makerjs.paths.Line([300, 0], [300, 5]),
                                    l2: new makerjs.paths.Line([300, 5], [-2, 12]),
                                    l3: new makerjs.paths.Line([-2, 12], [-2, -12]),
                                    l4: new makerjs.paths.Line([-2, -12], [300, -5]),
                                    l5: new makerjs.paths.Line([300, -5], [300, 0]),
                                },
                                layer: cutlayer,
                            };
                        }
                        
                        function paddleModel(radius, angle, isGuitar) {
                            if (isGuitar) {
                                var guitarSvg =
                                    '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg   xmlns:dc="http://purl.org/dc/elements/1.1/"   xmlns:cc="http://creativecommons.org/ns#"   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"   xmlns:svg="http://www.w3.org/2000/svg"   xmlns="http://www.w3.org/2000/svg"   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"   inkscape:version="1.0 (4035a4fb49, 2020-05-01)"   sodipodi:docname="1547093.svg"   id="svg8"   preserveAspectRatio="xMidYMid meet"   viewBox="0 0 1280.000000 640.000000"   height="640.000000pt"   width="1280.000000pt"   version="1.0">  <defs     id="defs12" />  <sodipodi:namedview     inkscape:current-layer="g6"     inkscape:window-maximized="1"     inkscape:window-y="-9"     inkscape:window-x="70"     inkscape:cy="527.10652"     inkscape:cx="486.52095"     inkscape:zoom="1.0515451"     showgrid="false"     id="namedview10"     inkscape:window-height="1171"     inkscape:window-width="1841"     inkscape:pageshadow="2"     inkscape:pageopacity="0"     guidetolerance="10"     gridtolerance="10"     objecttolerance="10"     borderopacity="1"     bordercolor="#666666"     pagecolor="#ffffff" />  <metadata     id="metadata2">Created by potrace 1.15, written by Peter Selinger 2001-2017<rdf:RDF>  <cc:Work     rdf:about="">    <dc:format>image/svg+xml</dc:format>    <dc:type       rdf:resource="http://purl.org/dc/dcmitype/StillImage" />  </cc:Work></rdf:RDF></metadata>  <g     id="g6"     stroke="none"     fill="#000000"     transform="translate(0.000000,640.000000) scale(0.100000,-0.100000)">    <path       sodipodi:nodetypes="ssssssssssssssssssssssssssssssssssssssssssssssssssssssss"       d="m 3026.6609,5313.6389 c 63.5654,-6.6102 125.8209,-19.7952 185.8972,-39.137 48.4175,-15.5882 95.4195,-35.1754 140.5508,-58.5426 81.3426,-42.116 156.6086,-96.5115 223.133,-161.905 67.5628,-66.4142 96.7591,-107.6453 131.1814,-187.6037 28.7096,-66.6886 50.6993,-146.1219 67.0137,-239.7125 17.0909,-98.0448 27.9534,-211.6265 33.7889,-342.3691 5.8908,-131.9832 3.104,-233.2922 0,-357.6373 -1.744,-69.8616 -4.6986,-130.3891 -9.1983,-184.6879 -9.7388,-117.5181 -26.7153,-205.8599 -54.3211,-296.5071 -20.6532,-67.8176 -42.1343,-118.7816 -71.3142,-163.7925 -27.9268,-43.0778 -62.9053,-80.7029 -110.9589,-122.4307 -63.3902,-55.0455 -129.8146,-100.2104 -200.8594,-136.2747 -43.7431,-22.2052 -89.2378,-40.9603 -136.8544,-56.4475 -46.61,-15.1598 -95.2531,-27.1883 -146.2766,-36.2563 -30.9222,-5.4956 -79.5555,-8.8628 -133.0172,-10.1088 -84.9872,-1.9809 -182.1763,1.3985 -239.8141,10.1088 -82.7173,12.5004 -165.3095,29.6272 -252.6991,52.7831 -94.8612,25.1356 -195.3753,57.3753 -307.8384,98.5132 -46.8274,17.129 -95.7265,35.8007 -147.1517,56.1446 -40.6242,16.071 -83.5288,31.6833 -126.2948,46.1082 -95.2171,32.1165 -189.7473,58.3467 -256.893,70.6483 -63.5669,11.6459 -213.9867,13.3484 -272.7192,2.8337 -71.069,-12.7233 -155.3145,-34.6706 -258.9107,-68.5801 -101.37603,-33.1828 -183.33371,-56.4787 -257.0499,-72.0635 -88.92459,-18.8 -165.85629,-26.3789 -250.41498,-26.556 -35.07093,-0.073 -62.87386,0.3886 -86.7188,1.8606 -55.01943,3.3964 -88.9665,12.1693 -142.5034,32.1461 -33.97278,12.6766 -62.84828,28.2268 -85.54634,45.4713 -42.73804,32.4697 -63.57525,70.9465 -55.30106,107.5589 10.4122,46.0728 32.66404,73.2658 96.90755,100.5063 32.25086,13.675 75.0842,27.362 132.31465,43.4555 69.18611,19.4555 128.00408,41.2942 176.9061,65.8791 59.43084,29.8782 104.21616,63.8124 135.1676,102.4542 43.00271,53.6874 58.58499,87.3532 55.9247,134.8933 -1.59882,28.5714 -12.6055,60.8769 -30.61684,94.8913 -24.4338,46.1431 -61.75833,95.4309 -105.97398,142.8072 -51.78524,55.4869 -91.3616,99.2461 -124.80219,138.2073 -44.46398,51.8044 -78.08025,95.1263 -115.12508,146.2562 -27.97901,38.6171 -56.99133,77.6044 -86.22986,118.9246 -26.24489,37.0896 -52.67203,76.0588 -78.6977,118.3271 -49.36682,80.1767 -89.99728,157.9361 -99.27195,186.5397 -17.97685,55.4416 -23.75991,79.9097 -24.8554,132.0594 -0.76173,36.2614 4.71734,69.2665 16.38208,99.8078 17.50071,45.8214 48.92493,86.097 94.08642,123.5029 33.94136,28.1126 70.32481,49.0544 112.52693,63.7818 55.65546,19.4222 121.43067,28.0364 205.07017,28.0364 77.38883,0 154.04255,-7.5557 239.47365,-24.5501 79.96155,-15.9064 167.61255,-40.0815 270.75293,-74.0694 175.3754,-57.7914 223.7061,-67.7508 350.0472,-71.4141 127.2263,-3.689 197.5302,2.6674 346.9774,53.5594 69.5364,23.6796 156.2069,57.0009 273.7178,103.4383 71.6244,28.3042 138.922,53.598 202.4962,76.0082 59.7687,21.0687 116.2464,39.5886 169.9345,55.6649 116.1016,34.7654 219.1576,58.1035 314.238,71.0783 105.4134,14.3848 201.0235,16.0315 293.7397,6.3899 z"       style="stroke-width:0.625556"       id="path4" />  </g></svg>';
                                var guitarModel = makerjs.importer.fromSVGPathData(extractSvgDataPath(guitarSvg));
                                var guitarMeasure = makerjs.measure.modelExtents(guitarModel);
                                makerjs.model.scale(guitarModel, 490 / guitarMeasure.high[0]);
                                makerjs.model.center(guitarModel);
                                guitarModel.origin[0] += 490 / 2;
                                return {
                                    models: { gitarre: guitarModel },
                                    layer: cutlayer,
                                };
                            }
                            var angleWidth = 70 / Math.tan(makerjs.angle.toRadians(angle));
                        
                            var paths = {
                                l2: new makerjs.paths.Line([0, 0], [0, 25]),
                                l3: new makerjs.paths.Line([0, 25], [angleWidth, 70]),
                                l4: new makerjs.paths.Line([angleWidth, 70], [490, 70]),
                                l5: new makerjs.paths.Line([490, 70], [490, 0]),
                            };
                        
                            paths.r0 = makerjs.path.fillet(paths.l2, paths.l3, 10);
                            paths.r1 = makerjs.path.fillet(paths.l3, paths.l4, angle > 42 ? 42 : 80);
                            paths.r2 = makerjs.path.fillet(paths.l4, paths.l5, radius);
                        
                            var halfpath = { paths: paths };
                            return {
                                models: {
                                    top: halfpath,
                                    bottom: makerjs.model.mirror(halfpath, false, true),
                                },
                                layer: cutlayer,
                            };
                        }
                        
                        function textModel(font, text, subtext, offset) {
                            if (text === "" && subtext === "") return undefined;
                            var smallText = text === "" && subtext !== "";
                            var hasSubtext = subtext !== "" && !smallText;
                            var model = {
                                text: new makerjs.models.Text(font, !smallText ? text : subtext, hasSubtext || smallText ? 24 : 32),
                            };
                            makerjs.model.center(model.text);
                        
                            if (hasSubtext) {
                                model.subText = new makerjs.models.Text(font, subtext, 12);
                                makerjs.model.center(model.subText);
                                model.subText.origin[1] -= 22;
                            }
                        
                            var textGroup = makerjs.model.center({ models: model });
                            textGroup.origin = [textGroup.origin[0] + offset[0], textGroup.origin[1] + offset[1]];
                            return textGroup;
                        }
                        
                        function paddleGenerator(
                            font,
                            spacer0,
                            radius,
                            angle,
                            isGuitar,
                            //count,
                            spacer1,
                            topText,
                            topSubText,
                            topTextPosition,
                            spacer2,
                            bottomText,
                            bottomSubText,
                            bottomTextPosition,
                            spacer3,
                            showSvg,
                            svgData,
                            svgScale,
                            svgHorizontal,
                            svgVertical
                        ) {
                            var count = 1;
                            var width = 490;
                            var height = isGuitar ? 220 : 140;
                            var widthHalf = width / 2;
                            var heightHalf = height / 2;
                            var copyCount = parseInt(count, 10) || 0;
                            var angleWidth = 70 / Math.tan(makerjs.angle.toRadians(angle));
                        
                            var textVerticalPosition = 15 + (heightHalf - 15) / 2;
                            var topTextModel = textModel(font, topText, topSubText, [widthHalf + topTextPosition, textVerticalPosition]);
                            var bottomTextModel = textModel(font, bottomText, bottomSubText, [
                                widthHalf + bottomTextPosition,
                                -textVerticalPosition,
                            ]);
                        
                            var paddle = {
                                paddle: paddleModel(radius, angle, isGuitar),
                                cone: cone(),
                                topText: topTextModel,
                                bottomText: bottomTextModel,
                            };
                            makerjs.model.combine(paddle.paddle, paddle.cone, false, true, true, false);
                        
                            var svgModel = makerjs.importer.fromSVGPathData(extractSvgDataPath(svgData));
                            makerjs.model.center(svgModel);
                            var svgMeasure = makerjs.measure.modelExtents(svgModel);
                            svgModel = makerjs.model.scale(svgModel, (svgScale / height) * (heightHalf / svgMeasure.high[1]));
                            makerjs.model.center(svgModel);
                            svgModel.origin = [svgModel.origin[0] + widthHalf + svgHorizontal, svgModel.origin[1] + svgVertical];
                            if (showSvg) paddle.svg = svgModel;
                        
                            this.units = makerjs.unitType.Millimeter;
                            this.models = { models: makerjs.layout.cloneToColumn({ models: paddle }, copyCount, 20) };
                        }
                        
                        var spaceSvg =
                            '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg   xmlns:dc="http://purl.org/dc/elements/1.1/"   xmlns:cc="http://creativecommons.org/ns#"   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"   xmlns:svg="http://www.w3.org/2000/svg"   xmlns="http://www.w3.org/2000/svg"   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"   version="1.1"   id="Layer_1"   x="0px"   y="0px"   width="331.644px"   height="40.825px"   viewBox="0 0 331.644 40.825"   enable-background="new 0 0 331.644 40.825"   xml:space="preserve"   sodipodi:docname="Space.svg"   inkscape:version="1.0 (4035a4fb49, 2020-05-01)"><metadata   id="metadata27"><rdf:RDF><cc:Work       rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type         rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs   id="defs25" /><sodipodi:namedview   inkscape:document-rotation="0"   pagecolor="#ffffff"   bordercolor="#666666"   borderopacity="1"   objecttolerance="10"   gridtolerance="10"   guidetolerance="10"   inkscape:pageopacity="0"   inkscape:pageshadow="2"   inkscape:window-width="1841"   inkscape:window-height="1171"   id="namedview23"   showgrid="false"   inkscape:zoom="1.3528339"   inkscape:cx="-50.533371"   inkscape:cy="-73.81913"   inkscape:window-x="70"   inkscape:window-y="-9"   inkscape:window-maximized="1"   inkscape:current-layer="g20" /><g   id="g20">	<g   transform="translate(0.49541693,0.28479074)"   id="g20-1">	<path   sodipodi:nodetypes="ccccccccccccccccccccccccsssssccccccccsssscccsssssscccccccccccccccccccccccccccccccccccccccssccssccccsss"   style="fill:none;stroke:#000000;stroke-opacity:1"   d="m 235.006,40.806 h -10.451 l -0.883,-1.383 C 230.778,32.562 262.56,3.151 331.644,0 c 0,0 -57.986,1.956 -96.638,40.806 m 12.069,-8.203 11.275,8.222 h 11.692 l 0.484,-1.089 -16.836,-12.323 c -2.236,1.641 -4.445,3.374 -6.615,5.19 m -10.35,-17.615 h -11.551 l -0.627,1.193 12.828,9.351 c 2.43,-1.407 5.074,-2.833 7.95,-4.24 z M 29.333,25.118 H 8.754 L 8.148,24.451 v -4.402 l 0.603,-0.466 h 27.742 l 0.379,-0.927 C 35.927,16.225 33.48,15.091 28.936,15.091 H 9.665 c -6.385,0 -8.426,1.247 -8.426,6.082 v 2.844 c 0,4.841 2.041,6.086 8.426,6.086 h 20.533 l 0.645,0.566 v 4.602 l -0.526,0.718 H 6.83 V 35.967 H 0.678 c 0,0 -0.704,0.353 -0.677,0.518 0.525,3.382 2.829,4.34 8.345,4.34 h 20.987 c 6.384,0 8.486,-1.247 8.486,-6.087 v -3.543 c 0,-4.832 -2.102,-6.077 -8.486,-6.077 m 111.028,-5.433 h 28.288 c -0.436,-3.597 -2.668,-4.595 -8.33,-4.595 H 140.06 c -6.389,0 -8.427,1.247 -8.427,6.082 v 13.565 c 0,4.84 2.038,6.087 8.427,6.087 h 20.259 c 5.745,0 7.945,-1.079 8.095,-4.81 h -28.053 l -0.832,-0.783 V 20.209 Z m 39.163,-4.591 h 35.113 v 4.848 h -35.113 z m 7.894,20.663 v -6.924 l 0.799,-0.69 h 14.862 v -4.409 h -23.555 v 17.089 h 34.746 v -4.388 h -26.018 z m -88.337,-15.944 6.68,9.787 -0.37,0.948 H 90.618 l -3.771,4.639 h 21.99 l 1.524,0.928 3.414,4.709 h 8.884 L 103.186,14.775 Z M 77.292,15.094 H 49.249 l -1.039,0.777 v 24.947 h 7.763 v -9.355 l 0.741,-0.664 h 20.579 c 5.196,0 7.632,-1.398 7.632,-4.985 v -5.728 c -10e-4,-3.593 -2.436,-4.992 -7.633,-4.992 m 0,9.223 c 0,1.69 -1.118,2.041 -3.554,2.041 H 56.799 L 55.972,25.554 V 20.21 l 0.741,-0.678 h 17.025 c 2.436,0 3.554,0.347 3.554,2.045 z"   id="path18-6" /></g></g></svg>';
                        var svg =
                            '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg   xmlns:dc="http://purl.org/dc/elements/1.1/"   xmlns:cc="http://creativecommons.org/ns#"   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"   xmlns:svg="http://www.w3.org/2000/svg"   xmlns="http://www.w3.org/2000/svg"   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"   inkscape:version="1.0 (4035a4fb49, 2020-05-01)"   sodipodi:docname="ojad.svg"   id="svg36"   version="1.1"   viewBox="0 0 170 85">  <metadata     id="metadata42">    <rdf:RDF>      <cc:Work         rdf:about="">        <dc:format>image/svg+xml</dc:format>        <dc:type           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />        <dc:title></dc:title>      </cc:Work>    </rdf:RDF>  </metadata>  <defs     id="defs40" />  <sodipodi:namedview     inkscape:current-layer="g32"     inkscape:window-maximized="1"     inkscape:window-y="-9"     inkscape:window-x="70"     inkscape:cy="85.943429"     inkscape:cx="125.76557"     inkscape:zoom="1.8661765"     showgrid="false"     id="namedview38"     inkscape:window-height="1171"     inkscape:window-width="1841"     inkscape:pageshadow="2"     inkscape:pageopacity="0"     guidetolerance="10"     gridtolerance="10"     objecttolerance="10"     borderopacity="1"     bordercolor="#666666"     pagecolor="#ffffff" />  <g     id="g34"     fill-rule="evenodd"     fill="none">    <g       id="g8"       fill="#FFF" />    <g       id="g14"       fill="#FFF" />    <g       id="g20"       fill="#FFF" />    <g       id="g26"       fill="#FFF" />    <g       id="g32"       fill="#FFF">      <path         sodipodi:nodetypes="cccscccsssccsccccssscsscccccccccccsssss"         style="fill:none;stroke:#000000;stroke-opacity:1"         d="m 158.31,27.272 -2.598,-1.459 -21.57,38.605 c -1.13,-5.892 -6.305,-10.362 -12.511,-10.362 -3.953,0 -7.49,1.812 -9.83,4.647 V 27.384 l 22.517,0.058 v -8.598 c 0,-7.041 -5.718,-12.773 -12.748,-12.773 -7.028,0 -12.749,5.732 -12.749,12.773 v 48.165 h 0.072 c 0.095,6.956 5.768,12.59 12.738,12.59 5.133,0 9.562,-3.064 11.577,-7.46 l 0.024,0.014 25.079,-44.881 z m -36.74,-9.23 c -2.11333,0 -2.11333,-3.17 0,-3.17 2.11333,0 2.11333,3.17 0,3.17 z m -9.77,0.802 c 0,-5.396 4.385,-9.788 9.77,-9.788 5.388,0 9.768,4.392 9.768,9.788 v 5.606 l -8.34,-0.02 v -3.961 c 1.69354,-0.608088 2.82414,-2.212596 2.827,-4.012 -5.5e-4,-2.351042 -1.90396,-4.258038 -4.255,-4.263 -2.35097,0.0055 -4.25435,1.912024 -4.256,4.263 0.001,1.753517 1.07561,3.327593 2.708,3.968 v 3.994 l -8.221,-0.02 v -5.555 z m 9.83,57.773 c -5.388,0 -9.768,-4.393 -9.768,-9.788 0,-5.4 4.38,-9.788 9.769,-9.788 5.385,0 9.769,4.389 9.769,9.788 0,5.395 -4.384,9.788 -9.77,9.788 z"         id="path30" />    </g>  </g></svg>';
                        
                        function generateSpacer(title) {
                            var str = "--" + title + "-----------------------------".substring(2 + title.length);
                            return { title: str, type: "bool", value: false };
                        }
                        
                        paddleGenerator.metaParameters = [
                            { title: "Schriftart", type: "font", value: "#stencil" },
                            generateSpacer("Paddel"),
                            { title: "Radius", type: "range", min: 8, max: 69, step: 1, value: 30 },
                            { title: "Winkel", type: "range", min: 20, max: 90, step: 1, value: 30 },
                            { title: "Gitarrenform", type: "bool", value: false },
                            //{ title: "Paddelanzahl", type: "text", value: "1" },
                            generateSpacer("Oberer Text"),
                            { title: "Textzeile 1", type: "text", value: "V 9147 - Autonom 2" },
                            { title: "Textzeile 2", type: "text", value: "Offene Jugendarbeit Dornbirn" },
                            { title: "Textposition", type: "range", min: -200, max: 200, step: 5, value: 0 },
                            generateSpacer("Unterer Text"),
                            { title: "Textzeile 1", type: "text", value: "" },
                            { title: "Textzeile 2", type: "text", value: "" },
                            { title: "Textposition", type: "range", min: -200, max: 200, step: 5, value: 0 },
                            generateSpacer("Bild (svg)"),
                            { title: "SVG anzeigen", type: "bool", value: false },
                            { title: "SVG Daten(SVG in z.B. Inkscape öffenen, Objekte zu Pfad konvertieren, Pfade zu einem Pfad zusammenfassen, in einem Texteditor öffnen und Inhalt hier einfügen)", type: "text", value: svg },
                            { title: "Bildgröße", type: "range", min: 10, max: 140, step: 1, value: 100 },
                            { title: "Horizontale Bildposition", type: "range", min: -240, max: 240, step: 5, value: 160 },
                            { title: "Vertikale Bildposition", type: "range", min: -69, max: 69, step: 5, value: 0 },
                        ];
                        
                        module.exports = paddleGenerator;
                        
                        function extractSvgDataPath(svg) {
                            var svgdataTemp = (svg.match(/<path(.|\n)*?d="(.|\n)*?"/gm) || [""])[0].split('"');
                            return fixSvgPath(svgdataTemp[svgdataTemp.length - 2]);
                        }
                        
                        function fixSvgPath(path) {
                            var resolvedParts = [];
                            parseSvgPath(path).forEach(function (command) {
                                resolvedParts.push(command.join(" "));
                            });
                            return resolvedParts.join(" ");
                        }
                        
                        // https://github.com/jkroso/parse-svg-path/blob/master/index.js
                        var length = { a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0 };
                        var segment = /([astvzqmhlc])([^astvzqmhlc]*)/gi;
                        var number = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;
                        function parseSvgPath(path) {
                            var data = [];
                            path.replace(segment, function (_, command, args) {
                                var type = command.toLowerCase();
                                args = parseValues(args);
                        
                                // overloaded moveTo
                                if (type == "m" && args.length > 2) {
                                    data.push([command].concat(args.splice(0, 2)));
                                    type = "l";
                                    command = command == "m" ? "l" : "L";
                                }
                        
                                while (true) {
                                    if (args.length == length[type]) {
                                        args.unshift(command);
                                        return data.push(args);
                                    }
                                    if (args.length < length[type]) throw new Error("malformed path data");
                                    data.push([command].concat(args.splice(0, length[type])));
                                }
                            });
                            return data;
                        }
                        
                        function parseValues(args) {
                            var numbers = args.match(number);
                            return numbers ? numbers.map(Number) : [];
                        }