1
0
Fork 0

First attempt

This commit is contained in:
Wouter van Wageningen 2023-04-19 06:08:26 +00:00
parent ccf2ff3931
commit 5dcaa15f32
10 changed files with 117 additions and 16 deletions

View file

@ -1,6 +1,7 @@
const defs = [
// button
`
{
name: 'button',
def: `
<g id="button">
<circle
cx="0" cy="0" r="3.4"
@ -11,8 +12,10 @@ const defs = [
<circle cx="1" cy="1" r="0.5" class="no-stroke fill-mark" />
<circle cx="-1" cy="1" r="0.5" class="no-stroke fill-mark" />
</g>`,
// buttonhole
`
},
{
name: 'buttonhole',
def: `
<g id="buttonhole">
<path
class="mark"
@ -31,8 +34,10 @@ const defs = [
d="M -1,0 L 1,0 L 1,10 L -1,10 z"
/>
</g>`,
// snaps
`
},
{
name: 'snaps',
def: `
<radialGradient id="snap-stud-grad" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
<stop offset="30%" style="stop-color:rgb(235,235,235); stop-opacity:1"/>
<stop offset="80%" style="stop-color:rgb(100,100,100);stop-opacity:1" />
@ -61,6 +66,7 @@ const defs = [
d="M -1.7,-1 L -1.7,1 M 1.7,-1 L 1.7,1" id="snap-socket-lines"
/>
</g>`,
},
]
// Export hooks
@ -68,7 +74,7 @@ export const buttonsHooks = {
preRender: [
function (svg) {
for (const def of defs) {
if (svg.defs.indexOf(def) === -1) svg.defs += def
svg.defs.setIfUnset(def.name, def.def)
}
},
],

View file

@ -11,7 +11,7 @@ const markers = `
export const cutonfoldHooks = {
preRender: [
function (svg) {
if (svg.defs.indexOf(markers) === -1) svg.defs += markers
svg.defs.setIfUnset('cutonfold', markers)
},
],
}

View file

@ -74,7 +74,7 @@ function lleader(so, type, props, id) {
export const dimensionsHooks = {
preRender: [
function (svg) {
if (svg.defs.indexOf(markers) === -1) svg.defs += markers
svg.defs.setIfUnset('dimensions', markers)
},
],
}

View file

@ -12,7 +12,7 @@ const dflts = { text: 'grainline' }
export const grainlineHooks = {
preRender: [
function (svg) {
if (svg.defs.indexOf(markers) === -1) svg.defs += markers
svg.defs.setIfUnset('grainline', markers)
},
],
}

View file

@ -5,7 +5,7 @@ const logo = (scale) =>
export const logoHooks = {
preRender: [
function (svg) {
if (svg.defs.indexOf('id="logo"') === -1) svg.defs += logo(svg.pattern.settings[0].scale)
svg.defs.setIfUnset('logo', logo(svg.pattern.settings[0].scale))
},
],
}

View file

@ -12,7 +12,7 @@ const markers = `
export const notchesHooks = {
preRender: [
function (svg) {
if (svg.defs.indexOf(`id="notch"`) === -1) svg.defs += markers
svg.defs.setIfUnset('notch', markers)
},
],
}

View file

@ -8,7 +8,7 @@ const markers = `
export const pleatHooks = {
preRender: [
function (svg) {
if (svg.defs.indexOf(markers) === -1) svg.defs += markers
svg.defs.setIfUnset('pleat', markers)
},
],
}

View file

@ -14,7 +14,7 @@ const markers = `
export const sewtogetherHooks = {
preRender: [
function (svg) {
if (svg.defs.indexOf(markers) === -1) svg.defs += markers
svg.defs.setIfUnset('sewTogether', markers)
},
],
}