First commit
This commit is contained in:
parent
fd5e5c4099
commit
51b68a14cf
14 changed files with 98 additions and 73 deletions
|
@ -58,7 +58,9 @@ function createBartack(so, props) {
|
|||
}
|
||||
so = { ...defaults, ...so }
|
||||
|
||||
const { Path, paths } = props
|
||||
const { Path, paths, scale } = props
|
||||
|
||||
so.width *= scale
|
||||
|
||||
// Handle negative angle
|
||||
if (so.angle < 0) so.angle = 360 + (so.angle % -360)
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
export const buttonsDefs = [
|
||||
{
|
||||
name: 'button',
|
||||
def: `
|
||||
<g id="button">
|
||||
def: (scale) => `
|
||||
<g id="button"
|
||||
transform="scale(${scale})">
|
||||
<circle
|
||||
cx="0" cy="0" r="3.4"
|
||||
class="mark"
|
||||
|
@ -16,8 +17,9 @@ export const buttonsDefs = [
|
|||
},
|
||||
{
|
||||
name: 'buttonhole',
|
||||
def: `
|
||||
<g id="buttonhole">
|
||||
def: (scale) => `
|
||||
<g id="buttonhole"
|
||||
transform="scale(${scale})">
|
||||
<path
|
||||
class="mark"
|
||||
d="M -1,-5 L 1,-5 L 1,5 L -1,5 z"
|
||||
|
@ -26,8 +28,9 @@ export const buttonsDefs = [
|
|||
},
|
||||
{
|
||||
name: 'buttonhole-start',
|
||||
def: `
|
||||
<g id="buttonhole-start">
|
||||
def: (scale) => `
|
||||
<g id="buttonhole-start"
|
||||
transform="scale(${scale})">
|
||||
<path
|
||||
class="mark"
|
||||
d="M -1,-10 L 1,-10 L 1,0 L -1,0 z"
|
||||
|
@ -36,8 +39,9 @@ export const buttonsDefs = [
|
|||
},
|
||||
{
|
||||
name: 'buttonhole-end',
|
||||
def: `
|
||||
<g id="buttonhole-end">
|
||||
def: (scale) => `
|
||||
<g id="buttonhole-end"
|
||||
transform="scale(${scale})">
|
||||
<path
|
||||
class="mark"
|
||||
d="M -1,0 L 1,0 L 1,10 L -1,10 z"
|
||||
|
@ -46,16 +50,18 @@ export const buttonsDefs = [
|
|||
},
|
||||
{
|
||||
name: 'snap-stud-grad',
|
||||
def: `
|
||||
<radialGradient id="snap-stud-grad" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
|
||||
def: (scale) => `
|
||||
<radialGradient id="snap-stud-grad" cx="50%" cy="50%" r="50%" fx="50%" fy="50%"
|
||||
transform="scale(${scale})">
|
||||
<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" />
|
||||
</radialGradient>`,
|
||||
},
|
||||
{
|
||||
name: 'snap-stud',
|
||||
def: `
|
||||
<g id="snap-stud">
|
||||
def: (scale) => `
|
||||
<g id="snap-stud"
|
||||
transform="scale(${scale})">
|
||||
<circle id="snap-stud-circle-edge" cx="0" cy="0" r="3.4"
|
||||
style="stroke:#666;fill:#dddddd;stroke-width:0.3;"
|
||||
/>
|
||||
|
@ -70,8 +76,9 @@ export const buttonsDefs = [
|
|||
},
|
||||
{
|
||||
name: 'snap-socket',
|
||||
def: `
|
||||
<g id="snap-socket">
|
||||
def: (scale) => `
|
||||
<g id="snap-socket"
|
||||
transform="scale(${scale})">
|
||||
<circle id="snap-socket-circle-edge" cx="0" cy="0" r="3.4"
|
||||
style="stroke:#666;fill:#bbbbbb;stroke-width:0.3;"
|
||||
/>
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
export const cutonfoldDefs = [
|
||||
{
|
||||
name: 'cutonfoldFrom',
|
||||
def: `
|
||||
<marker orient="auto" refY="4.0" refX="0.0" id="cutonfoldFrom" style="overflow:visible;" markerWidth="12" markerHeight="8">
|
||||
<path class="note fill-note" d="M 0,4 L 12,0 C 10,2 10,6 12,8 z" />
|
||||
def: (scale) => `
|
||||
<marker orient="auto" refY="0" refX="0" id="cutonfoldFrom" style="overflow:visible;" markerWidth="12" markerHeight="8" transform="scale(${scale})">
|
||||
<path class="note fill-note" d="M 0,0 L 12,-4 C 10,-2 10,2 12,4 z" transform="scale(${scale})"/>
|
||||
</marker>`,
|
||||
},
|
||||
{
|
||||
name: 'cutonfoldTo',
|
||||
def: `
|
||||
<marker orient="auto" refY="4.0" refX="12.0" id="cutonfoldTo" style="overflow:visible;" markerWidth="12" markerHeight="8">
|
||||
<path class="note fill-note" d="M 12,4 L 0,0 C 2,2 2,6 0,8 z" />
|
||||
def: (scale) => `
|
||||
<marker orient="auto" refY="0" refX="0" id="cutonfoldTo" style="overflow:visible;" markerWidth="12" markerHeight="8" transform="scale(${scale})">
|
||||
<path class="note fill-note" d="M 0,0 L -12,-4 C -10,-2 -10,2 -12,4 z" transform="scale(${scale})"/>
|
||||
</marker>`,
|
||||
},
|
||||
]
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
export const dimensionsDefs = [
|
||||
{
|
||||
name: 'dimensionFrom',
|
||||
def: `
|
||||
<marker orient="auto" refY="4.0" refX="0.0" id="dimensionFrom" style="overflow:visible;" markerWidth="12" markerHeight="8">
|
||||
<path class="mark fill-mark" d="M 0,4 L 12,0 C 10,2 10,6 12,8 z" />
|
||||
def: (scale) => `
|
||||
<marker orient="auto" refY="0" refX="0" id="dimensionFrom" style="overflow:visible;" markerWidth="12" markerHeight="8">
|
||||
<path class="mark fill-mark" d="M 0,0 L 12,-4 C 10,-2 10,2 12,4 z" transform="scale(${scale})"/>
|
||||
</marker>`,
|
||||
},
|
||||
{
|
||||
name: 'dimensionTo',
|
||||
def: `
|
||||
<marker orient="auto" refY="4.0" refX="12.0" id="dimensionTo" style="overflow:visible;" markerWidth="12" markerHeight="8">
|
||||
<path class="mark fill-mark" d="M 12,4 L 0,0 C 2,2 2,6 0,8 z" />
|
||||
def: (scale) => `
|
||||
<marker orient="auto" refY="0" refX="0" id="dimensionTo" style="overflow:visible;" markerWidth="12" markerHeight="8">
|
||||
<path class="mark fill-mark" d="M 0,0 L -12,-4 C -10,-2 -10,2 -12,4 z" transform="scale(${scale})"/>
|
||||
</marker>`,
|
||||
},
|
||||
]
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
export const grainlineDefs = [
|
||||
{
|
||||
name: 'grainlineFrom',
|
||||
def: `
|
||||
<marker orient="auto" refY="4.0" refX="10.0" id="grainlineFrom" style="overflow:visible;" markerWidth="12" markerHeight="8">
|
||||
<path class="note fill-note" d="M 0,4 L 12,0 C 10,2 10,6 12,8 z" />
|
||||
def: (scale) => `
|
||||
<marker orient="auto" refY="0" refX="0" id="grainlineFrom" style="overflow:visible;" markerWidth="12" markerHeight="8">
|
||||
<path class="note fill-note" d="M -10,0 L 2,-4 C 0,-2 0,2 2,4 z" transform="scale(${scale})"/>
|
||||
</marker>`,
|
||||
},
|
||||
{
|
||||
name: 'grainlineTo',
|
||||
def: `
|
||||
<marker orient="auto" refY="4.0" refX="2.0" id="grainlineTo" style="overflow:visible;" markerWidth="12" markerHeight="8">
|
||||
<path class="note fill-note" d="M 12,4 L 0,0 C 2,2 2,6 0,8 z" />
|
||||
def: (scale) => `
|
||||
<marker orient="auto" refY="0" refX="0" id="grainlineTo" style="overflow:visible;" markerWidth="12" markerHeight="8">
|
||||
<path class="note fill-note" d="M 10,0 L -2,-4 C 0,-2 -2,2 -2,4 z" transform="scale(${scale})"/>
|
||||
</marker>`,
|
||||
},
|
||||
]
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
export const notchesDefs = [
|
||||
{
|
||||
name: 'notch',
|
||||
def: `
|
||||
<g id="notch">
|
||||
def: (scale) => `
|
||||
<g id="notch" transform="scale(${scale})">
|
||||
<circle cy="0" cx="0" r="1.4" class="fill-note" />
|
||||
<circle cy="0" cx="0" r="2.8" class="note" />
|
||||
</g>`,
|
||||
},
|
||||
{
|
||||
name: 'bnotch',
|
||||
def: `
|
||||
<g id="bnotch">
|
||||
def: (scale) => `
|
||||
<g id="bnotch" transform="scale(${scale})">
|
||||
<path d="M -1.1 -1.1 L 1.1 1.1 M 1.1 -1.1 L -1.1 1.1" class="note" />
|
||||
<circle cy="0" cx="0" r="2.8" class="note" />
|
||||
</g>`,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Export defs
|
||||
export const pleatDefs = [
|
||||
{
|
||||
name: 'notch',
|
||||
def: `
|
||||
<marker id="pleatTo" markerWidth="12" markerHeight="8" orient="auto" refY="4" refX="12">
|
||||
<path class="note fill-note" d="M 12,4 L 0,0 C 2,2 2,6 0,8 z" />
|
||||
name: 'pleatTo',
|
||||
def: (scale) => `
|
||||
<marker orient="auto" refY="0" refX="0" id="pleatTo" style="overflow:visible;" markerWidth="12" markerHeight="8">
|
||||
<path class="note fill-note" d="M 0,0 L -12,-4 C -10,-2 -12,2 -12,4 z" transform="scale(${scale})"/>
|
||||
</marker>
|
||||
`,
|
||||
},
|
||||
|
|
|
@ -24,6 +24,12 @@ export const scaleboxMacros = {
|
|||
return true
|
||||
}
|
||||
|
||||
const transform = function (anchor) {
|
||||
return `translate(${anchor.x}, ${anchor.y}) scale(${scale}) translate(${anchor.x * -1}, ${
|
||||
anchor.y * -1
|
||||
})`
|
||||
}
|
||||
|
||||
// Convert scale to a value between 0 and 9, inclusive.
|
||||
const scaleIndex = Math.round(10 * Math.max(0.1, Math.min(1, scale))) - 1
|
||||
|
||||
|
@ -99,7 +105,9 @@ export const scaleboxMacros = {
|
|||
so.at.y + imperialHeight / 2
|
||||
)
|
||||
// Text anchor points
|
||||
points.__scaleboxLead = new Point(so.at.x - 45 * scale, so.at.y - 15 * scale)
|
||||
points.__scaleboxLead = points.__scaleboxImperialTopLeft
|
||||
.shift(-90, 7 * scale)
|
||||
.shift(0, 2 * scale)
|
||||
points.__scaleboxTitle = points.__scaleboxLead.shift(-90, 10 * scale)
|
||||
points.__scaleboxText = points.__scaleboxTitle.shift(-90, 12 * scale)
|
||||
points.__scaleboxLink = points.__scaleboxText.shift(-90, 5 * scale)
|
||||
|
@ -148,9 +156,10 @@ export const scaleboxMacros = {
|
|||
.line(points.__scaleboxMetricTopRight)
|
||||
.close()
|
||||
// Lead
|
||||
points.__scaleboxLead = points.__scaleboxLead
|
||||
points.__scaleboxLead
|
||||
.attr('data-text', so.lead || 'FreeSewing')
|
||||
.attr('data-text-class', 'text-sm')
|
||||
.attr('data-text-transform', transform(points.__scaleboxLead))
|
||||
// Title
|
||||
if (so.title) points.__scaleboxTitle.attributes.set('data-text', so.title)
|
||||
else {
|
||||
|
@ -160,6 +169,7 @@ export const scaleboxMacros = {
|
|||
.attr('data-text', name)
|
||||
.attr('data-text', 'v' + (store.data?.version || 'No Version'))
|
||||
}
|
||||
points.__scaleboxTitle.attr('data-text-transform', transform(points.__scaleboxTitle))
|
||||
points.__scaleboxTitle.attributes.add('data-text-class', 'text-lg')
|
||||
// Text
|
||||
if (typeof so.text === 'string') {
|
||||
|
@ -170,7 +180,11 @@ export const scaleboxMacros = {
|
|||
.attr('data-text', 'freesewing.org/patrons/join')
|
||||
.attr('data-text-class', 'text-sm fill-note')
|
||||
}
|
||||
points.__scaleboxText.attr('data-text-class', 'text-xs').attr('data-text-lineheight', 4)
|
||||
points.__scaleboxLink.attr('data-text-transform', transform(points.__scaleboxLink))
|
||||
points.__scaleboxText
|
||||
.attr('data-text-transform', transform(points.__scaleboxText))
|
||||
.attr('data-text-class', 'text-xs')
|
||||
.attr('data-text-lineheight', 4)
|
||||
// Instructions
|
||||
points.__scaleboxMetric = points.__scaleboxMetric
|
||||
.attr('data-text', 'theWhiteInsideOfThisBoxShouldMeasure')
|
||||
|
@ -178,12 +192,14 @@ export const scaleboxMacros = {
|
|||
.attr('data-text', 'x')
|
||||
.attr('data-text', `${metricDisplayHeight}`)
|
||||
.attr('data-text-class', 'text-xs center')
|
||||
.attr('data-text-transform', transform(points.__scaleboxMetric))
|
||||
points.__scaleboxImperial = points.__scaleboxImperial
|
||||
.attr('data-text', 'theBlackOutsideOfThisBoxShouldMeasure')
|
||||
.attr('data-text', `${imperialDisplayWidth}`)
|
||||
.attr('data-text', 'x')
|
||||
.attr('data-text', `${imperialDisplayHeight}`)
|
||||
.attr('data-text-class', 'text-xs center ')
|
||||
.attr('data-text-transform', transform(points.__scaleboxImperial))
|
||||
},
|
||||
miniscale(so, { points, paths, scale, Point, Path }) {
|
||||
// Passing `false` will remove the miniscale
|
||||
|
|
|
@ -2,23 +2,23 @@
|
|||
export const sewtogetherDefs = [
|
||||
{
|
||||
name: 'sewTogetherStart',
|
||||
def: `
|
||||
<marker id="sewTogetherStart" markerWidth="4" markerHeight="4" orient="auto" refX="0" refY="2">
|
||||
<path class="note stroke-sm" d="M4,4 L0,2 4,0" />
|
||||
def: (scale) => `
|
||||
<marker id="sewTogetherStart" markerWidth="8" markerHeight="8" style="overflow:visible;" orient="auto" refX="0" refY="0">
|
||||
<path class="note stroke-sm" d="M 8,4 L 0,0 8,-4" transform="scale(${scale})"/>
|
||||
</marker>`,
|
||||
},
|
||||
{
|
||||
name: 'sewTogetherEnd',
|
||||
def: `
|
||||
<marker id="sewTogetherEnd" markerWidth="4" markerHeight="4" orient="auto" refX="4" refY="2">
|
||||
<path class="note stroke-sm" d="M0,0 L4,2 0,4" />
|
||||
def: (scale) => `
|
||||
<marker id="sewTogetherEnd" markerWidth="8" markerHeight="8" style="overflow:visible;" orient="auto" refX="0" refY="0">
|
||||
<path class="note stroke-sm" d="M -8,-4 L 0,0 -8,4" transform="scale(${scale})"/>
|
||||
</marker>`,
|
||||
},
|
||||
{
|
||||
name: 'sewTogetherCross',
|
||||
def: `
|
||||
<marker id="sewTogetherCross" markerWidth="4" markerHeight="4" orient="auto" refX="2" refY="2">
|
||||
<path d="M 0,0 L 4,4 M 4,0 L 0,4" class="note stroke-sm"/>
|
||||
def: (scale) => `
|
||||
<marker id="sewTogetherCross" markerWidth="8" markerHeight="8" style="overflow:visible;" orient="auto" refX="0" refY="0">
|
||||
<path d="M -4,-4 L 4,4 M 4,-4 L -4,4" class="note stroke-sm" transform="scale(${scale})"/>
|
||||
</marker>`,
|
||||
},
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue