1
0
Fork 0

fix(dev): One-liner admonitions

This commit is contained in:
Joost De Cock 2024-09-29 07:14:59 +02:00
parent a6d656c19e
commit da41cc0fc9
60 changed files with 860 additions and 659 deletions

View file

@ -1,5 +1,5 @@
---
title: "Path._curve()"
title: 'Path._curve()'
---
The `Path._curve()` method draws a cubic Bézier curve
@ -13,7 +13,9 @@ so you do not need to provide it.
Path path._curve(Point cp2, Point to)
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -21,19 +23,20 @@ Path path._curve(Point cp2, Point to)
```js
({ Point, points, Path, paths, part }) => {
points.from = new Point(5, 20)
points.cp2 = new Point(60, 50)
points.to = new Point(90, 20)
points.from = new Point(5, 20)
points.cp2 = new Point(60, 50)
points.to = new Point(90, 20)
paths.line = new Path()
.move(points.from)
._curve(points.cp2, points.to)
.setText("Path._curve()", "text-sm center fill-note")
.attr("data-text-dy", -1)
paths.line = new Path()
.move(points.from)
.\_curve(points.cp2, points.to)
.setText("Path.\_curve()", "text-sm center fill-note")
.attr("data-text-dy", -1)
return part
return part
}
```
````
</Example>
@ -45,4 +48,4 @@ as the two following calls yield the same result:
```js
path.curve(point1, point1, point2)
path._curve(point1, point2)
```
````

View file

@ -10,7 +10,9 @@ The `Path.addClass()` method adds a CSS class to the path.
Path path.addClass(string className)
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -18,17 +20,18 @@ Path path.addClass(string className)
```js
({ Point, points, Path, paths, part }) => {
points.from = new Point(5, 10)
points.to = new Point(95, 10)
points.from = new Point(5, 10)
points.to = new Point(95, 10)
paths.line = new Path()
.move(points.from)
.line(points.to)
.addClass('note dashed')
paths.line = new Path()
.move(points.from)
.line(points.to)
.addClass('note dashed')
return part
return part
}
```
````
</Example>
## Notes
@ -39,4 +42,4 @@ as the two following calls yield the same result:
```js
path.attr('class', 'fabric')
path.addClass('fabric')
```
````

View file

@ -12,7 +12,9 @@ Path path.addText(string text, string className = '')
The second argument will optionally be used to set the CSS class for the text.
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -22,14 +24,15 @@ The second argument will optionally be used to set the CSS class for the text.
points.from = new Point(5, 10)
points.to = new Point(95, 10)
paths.line = new Path()
.move(points.from)
.line(points.to)
.addText('FreeSewing rocks')
paths.line = new Path()
.move(points.from)
.line(points.to)
.addText('FreeSewing rocks')
return part
return part
}
```
````
</Example>
## Notes
@ -40,7 +43,7 @@ as the two following calls yield the same result:
```js
path.attr('data-text', 'Hello')
path.addText('Hello')
```
````
The difference with [Path.setText()](/reference/api/path/addtext) is that this
method will add to the existing text whereas `Path.setText()` will overwrite

View file

@ -18,7 +18,9 @@ Path path.attr(
)
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -26,19 +28,20 @@ Path path.attr(
```js
({ Point, points, Path, paths, part }) => {
points.from = new Point(10, 20)
points.cp1 = new Point(20, -10)
points.cp2 = new Point(50, 50)
points.to = new Point(70, 20)
points.from = new Point(10, 20)
points.cp1 = new Point(20, -10)
points.cp2 = new Point(50, 50)
points.to = new Point(70, 20)
paths.example = new Path()
.move(points.from)
.curve(points.cp1, points.cp2, points.to)
.attr("class", "canvas")
.setText("FreeSewing rocks", "text-xs center")
paths.example = new Path()
.move(points.from)
.curve(points.cp1, points.cp2, points.to)
.attr("class", "canvas")
.setText("FreeSewing rocks", "text-xs center")
return part
return part
}
```
</Example>
@ -54,3 +57,4 @@ all call this method under the hood.
See [Using Attributes](/howtos/code/attributes)
for information about custom Attributes that can be used with Paths.
```

View file

@ -11,10 +11,12 @@ A negative angle results in a clockwise arc.
:::tip
The new endpoint of this path is the same point
that
that
```js
path.end().rotate(deg, origin)
```
would return.
:::
@ -24,7 +26,9 @@ would return.
Path path.circleSegment(deg, origin)
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -48,5 +52,7 @@ paths.helper = new Path()
return part
}
```
</Example>
```

View file

@ -10,7 +10,9 @@ The `Path.close()` method closes a path by drawing a straight line from the curr
Path path.close()
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -18,18 +20,20 @@ Path path.close()
```js
({ Point, points, Path, paths, part }) => {
points.from = new Point(10, 20)
points.cp2 = new Point(60, 30)
points.to = new Point(90, 20)
points.from = new Point(10, 20)
points.cp2 = new Point(60, 30)
points.to = new Point(90, 20)
paths.line = new Path()
.move(points.from)
._curve(points.cp2, points.to)
.close()
.reverse() // To keep text from being upside-down
.setText('Path._close()', 'text-sm right fill-note')
paths.line = new Path()
.move(points.from)
.\_curve(points.cp2, points.to)
.close()
.reverse() // To keep text from being upside-down
.setText('Path.\_close()', 'text-sm right fill-note')
return part
return part
}
```
</Example>
```

View file

@ -11,7 +11,9 @@ via two control points to a given endpoint.
Path path.curve(Point cp1, Point cp2, Point to)
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -19,17 +21,19 @@ Path path.curve(Point cp1, Point cp2, Point to)
```js
({ Point, points, Path, paths, part }) => {
points.from = new Point(10, 20)
points.cp1 = new Point(40, 0)
points.cp2 = new Point(60, 40)
points.to = new Point(90, 20)
points.from = new Point(10, 20)
points.cp1 = new Point(40, 0)
points.cp2 = new Point(60, 40)
points.to = new Point(90, 20)
paths.line = new Path()
.move(points.from)
.curve(points.cp1, points.cp2, points.to)
.setText("Path.curve()", "text-sm center fill-note")
paths.line = new Path()
.move(points.from)
.curve(points.cp1, points.cp2, points.to)
.setText("Path.curve()", "text-sm center fill-note")
return part
return part
}
```
</Example>
```

View file

@ -3,7 +3,7 @@ title: Path.curve_()
---
The `Path.curve_()` method draws a cubic Bézier curve from the current position
via two control points to a given endpoint. However, the end control point is
via two control points to a given endpoint. However, the end control point is
identical to the end point.
## Signature
@ -12,16 +12,16 @@ identical to the end point.
Path path.curve_(Point cp1, Point to)
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
<Example caption="Example of the Path.curve\_() method">
```js
({ Point, points, Path, paths, part }) => {
;({ Point, points, Path, paths, part }) => {
points.from = new Point(10, 20)
points.cp1 = new Point(40, 0)
points.to = new Point(90, 20)
@ -29,12 +29,13 @@ Path path.curve_(Point cp1, Point to)
paths.line = new Path()
.move(points.from)
.curve_(points.cp1, points.to)
.setText("Path.curve_()", "text-sm center fill-note")
.attr("data-text-dy", -1)
.setText('Path.curve_()', 'text-sm center fill-note')
.attr('data-text-dy', -1)
return part
}
```
</Example>
## Notes

View file

@ -10,7 +10,9 @@ The `Path.end()` method returns the Point object at the end of the path.
Point path.end()
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -18,20 +20,22 @@ Point path.end()
```js
({ Point, points, Path, paths, snippets, Snippet, part }) => {
points.A = new Point(45, 60)
points.B = new Point(10, 30)
points.BCp2 = new Point(40, 20)
points.C = new Point(90, 30)
points.CCp1 = new Point(50, -30)
points.A = new Point(45, 60)
points.B = new Point(10, 30)
points.BCp2 = new Point(40, 20)
points.C = new Point(90, 30)
points.CCp1 = new Point(50, -30)
paths.demo = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
paths.demo = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
snippets.end = new Snippet("notch", paths.demo.end())
snippets.end = new Snippet("notch", paths.demo.end())
return part
return part
}
```
</Example>
```

View file

@ -10,7 +10,9 @@ The `Path.hide()` hides the path so it does not appear in the output.
Path path.hide()
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -18,15 +20,17 @@ Path path.hide()
```js
({ Point, points, Path, paths, part }) => {
points.top = new Point(50, 0)
points.left = new Point (20,50)
points.right = new Point (80,50)
points.top = new Point(50, 0)
points.left = new Point (20,50)
points.right = new Point (80,50)
paths.a = new Path().move(points.top).line(points.right).setText('a')
paths.b = new Path().move(points.right).line(points.left).setText('b').hide()
paths.c = new Path().move(points.left).line(points.top).setText('c')
paths.a = new Path().move(points.top).line(points.right).setText('a')
paths.b = new Path().move(points.right).line(points.left).setText('b').hide()
paths.c = new Path().move(points.left).line(points.top).setText('c')
return part
return part
}
```
</Example>
```

View file

@ -11,40 +11,43 @@ operation](/reference/api/path/noop) with id `id`.
Path path.insop(string id, Path path)
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
<Example caption="Example of the Path.insop() method">
```js
({ Point, points, Path, paths, part }) => {
points.left = new Point(10,10)
points.dartLeft = new Point(40, 10)
points.dartTip = new Point(50, 50)
points.dartRight = new Point(60, 10)
points.right = new Point(90, 10)
points.left = new Point(10,10)
points.dartLeft = new Point(40, 10)
points.dartTip = new Point(50, 50)
points.dartRight = new Point(60, 10)
points.right = new Point(90, 10)
paths.withoutDart = new Path()
.move(points.left)
.line(points.dartLeft)
.noop('dart')
.line(points.right)
paths.withoutDart = new Path()
.move(points.left)
.line(points.dartLeft)
.noop('dart')
.line(points.right)
paths.withDart = paths.withoutDart
.clone()
.insop(
'dart',
new Path()
.line(points.dartTip)
.line(points.dartRight)
)
.attr('style', 'stroke-width: 2px; stroke-opacity: 0.5; stroke: orange;')
paths.withDart = paths.withoutDart
.clone()
.insop(
'dart',
new Path()
.line(points.dartTip)
.line(points.dartRight)
)
.attr('style', 'stroke-width: 2px; stroke-opacity: 0.5; stroke: orange;')
return part
return part
}
```
</Example>
## Notes
This is often used to insert darts into a path.
```

View file

@ -11,7 +11,9 @@ given point.
Path path.line(Point to)
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -19,15 +21,17 @@ Path path.line(Point to)
```js
({ Point, points, Path, paths, part }) => {
points.from = new Point(10, 10)
points.to = new Point(90, 10)
points.from = new Point(10, 10)
points.to = new Point(90, 10)
paths.line = new Path()
.move(points.from)
.line(points.to)
.setText("Path.line()", "text-sm center fill-note")
paths.line = new Path()
.move(points.from)
.line(points.to)
.setText("Path.line()", "text-sm center fill-note")
return part
return part
}
```
</Example>
```

View file

@ -12,7 +12,9 @@ with [`Path.insop()`](/reference/api/path/insop).
Path path.noop(string id)
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -20,29 +22,31 @@ Path path.noop(string id)
```js
({ Point, points, Path, paths, part }) => {
points.left = new Point(10,10)
points.dartLeft = new Point(40, 10)
points.dartTip = new Point(50, 50)
points.dartRight = new Point(60, 10)
points.right = new Point(90, 10)
points.left = new Point(10,10)
points.dartLeft = new Point(40, 10)
points.dartTip = new Point(50, 50)
points.dartRight = new Point(60, 10)
points.right = new Point(90, 10)
paths.withoutDart = new Path()
.move(points.left)
.line(points.dartLeft)
.noop('dart')
.line(points.right)
paths.withoutDart = new Path()
.move(points.left)
.line(points.dartLeft)
.noop('dart')
.line(points.right)
paths.withDart = paths.withoutDart
.clone()
.insop(
'dart',
new Path()
.line(points.dartTip)
.line(points.dartRight)
)
.attr('style', 'stroke-width: 2px; stroke-opacity: 0.5; stroke: orange;')
paths.withDart = paths.withoutDart
.clone()
.insop(
'dart',
new Path()
.line(points.dartTip)
.line(points.dartRight)
)
.attr('style', 'stroke-width: 2px; stroke-opacity: 0.5; stroke: orange;')
return part
return part
}
```
</Example>
```

View file

@ -10,7 +10,9 @@ The `Path.setClass()` method sets the CSS class(es) of the path.
Path path.setClass(string className)
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -18,17 +20,18 @@ Path path.setClass(string className)
```js
({ Point, points, Path, paths, part }) => {
points.from = new Point(5, 10)
points.to = new Point(95, 10)
points.from = new Point(5, 10)
points.to = new Point(95, 10)
paths.line = new Path()
.move(points.from)
.line(points.to)
.setClass('note dashed')
paths.line = new Path()
.move(points.from)
.line(points.to)
.setClass('note dashed')
return part
return part
}
```
````
</Example>
## Notes
@ -39,4 +42,4 @@ as the two following calls yield the same result:
```js
path.attr('class', 'fabric', true)
path.setClass('fabric')
```
````

View file

@ -11,7 +11,9 @@ value you pass it.
Path path.setHidden(bool hidden = false)
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -19,15 +21,17 @@ Path path.setHidden(bool hidden = false)
```js
({ Point, points, Path, paths, part }) => {
points.top = new Point(50, 0)
points.left = new Point (20,50)
points.right = new Point (80,50)
points.top = new Point(50, 0)
points.left = new Point (20,50)
points.right = new Point (80,50)
paths.a = new Path().move(points.top).line(points.right).setText('a')
paths.b = new Path().move(points.right).line(points.left).setText('b').setHidden(true)
paths.c = new Path().move(points.left).line(points.top).setText('c')
paths.a = new Path().move(points.top).line(points.right).setText('a')
paths.b = new Path().move(points.right).line(points.left).setText('b').setHidden(true)
paths.c = new Path().move(points.left).line(points.top).setText('c')
return part
return part
}
```
</Example>
```

View file

@ -12,7 +12,9 @@ Path path.setText(string text, string className = '')
The second argument will optionally be used to set the CSS class for the text.
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -22,14 +24,15 @@ The second argument will optionally be used to set the CSS class for the text.
points.from = new Point(5, 10)
points.to = new Point(95, 10)
paths.line = new Path()
.move(points.from)
.line(points.to)
.setText('FreeSewing rocks')
paths.line = new Path()
.move(points.from)
.line(points.to)
.setText('FreeSewing rocks')
return part
return part
}
```
````
</Example>
## Notes
@ -40,7 +43,7 @@ as the two following calls yield the same result:
```js
path.attr('data-text', 'Hello')
path.setText('Hello')
```
````
The difference with [Path.addText()](/reference/api/path/addtext) is that this
method will overwrite existing text on the path, whereas `Path.addText()` will

View file

@ -11,7 +11,9 @@ A smooth curve means it will use the reflection of the end control point of the
Path path.smurve(Point cp2, Point end)
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -19,22 +21,24 @@ Path path.smurve(Point cp2, Point end)
```js
({ Point, points, Path, paths, part }) => {
points.aFrom = new Point(10, 10)
points.aCp1 = new Point(40, 40)
points.aCp2 = new Point(70, -20)
points.aTo = new Point(100, 10)
points.aFrom = new Point(10, 10)
points.aCp1 = new Point(40, 40)
points.aCp2 = new Point(70, -20)
points.aTo = new Point(100, 10)
points.bCp2 = new Point(50,50)
points.bTo = new Point(10,50)
points.bCp2 = new Point(50,50)
points.bTo = new Point(10,50)
paths.smurve = new Path()
.move(points.aFrom)
.curve(points.aCp1, points.aCp2,points.aTo)
.smurve(points.bCp2, points.bTo)
.reverse() // Puts text at the end
.setText('Path.smurve()')
paths.smurve = new Path()
.move(points.aFrom)
.curve(points.aCp1, points.aCp2,points.aTo)
.smurve(points.bCp2, points.bTo)
.reverse() // Puts text at the end
.setText('Path.smurve()')
return part
return part
}
```
</Example>
```

View file

@ -13,7 +13,9 @@ A smooth curve means it will use the reflection of the end control point of the
Path path.smurve_(Point cp2, Point end)
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -21,21 +23,23 @@ Path path.smurve_(Point cp2, Point end)
```js
({ Point, points, Path, paths, part }) => {
points.aFrom = new Point(10, 10)
points.aCp1 = new Point(40, 40)
points.aCp2 = new Point(70, -20)
points.aTo = new Point(100, 10)
points.aFrom = new Point(10, 10)
points.aCp1 = new Point(40, 40)
points.aCp2 = new Point(70, -20)
points.aTo = new Point(100, 10)
points.bTo = new Point(10,50)
points.bTo = new Point(10,50)
paths.smurve = new Path()
.move(points.aFrom)
.curve(points.aCp1, points.aCp2,points.aTo)
.smurve_(points.bTo)
.reverse() // Puts text at the end
.setText('Path.smurve()')
paths.smurve = new Path()
.move(points.aFrom)
.curve(points.aCp1, points.aCp2,points.aTo)
.smurve\_(points.bTo)
.reverse() // Puts text at the end
.setText('Path.smurve()')
return part
return part
}
```
</Example>
```

View file

@ -10,7 +10,9 @@ The `Path.start()` method returns the Point object at the start of the path.
Point path.start()
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -18,20 +20,22 @@ Point path.start()
```js
({ Point, points, Path, paths, snippets, Snippet, part }) => {
points.A = new Point(45, 60)
points.B = new Point(10, 30)
points.BCp2 = new Point(40, 20)
points.C = new Point(90, 30)
points.CCp1 = new Point(50, -30)
points.A = new Point(45, 60)
points.B = new Point(10, 30)
points.BCp2 = new Point(40, 20)
points.C = new Point(90, 30)
points.CCp1 = new Point(50, -30)
paths.demo = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
paths.demo = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
snippets.end = new Snippet("notch", paths.demo.start())
snippets.end = new Snippet("notch", paths.demo.start())
return part
return part
}
```
</Example>
```

View file

@ -2,7 +2,7 @@
title: Path.unhide()
---
The `Path.unhide()` method unhides the path so it appears in the output. By
The `Path.unhide()` method unhides the path so it appears in the output. By
default, paths are not hidden. So you should only call this on path previously
hidden via `Path.hide()`.
@ -12,7 +12,9 @@ hidden via `Path.hide()`.
Path path.unhide()
```
:::tipThis method is chainable as it returns the `Path` object:::
:::tip
This method is chainable as it returns the `Path` object
:::
## Example
@ -20,15 +22,17 @@ Path path.unhide()
```js
({ Point, points, Path, paths, part }) => {
points.top = new Point(50, 0)
points.left = new Point (20,50)
points.right = new Point (80,50)
points.top = new Point(50, 0)
points.left = new Point (20,50)
points.right = new Point (80,50)
paths.a = new Path().move(points.top).line(points.right).setText('a')
paths.b = new Path().move(points.right).line(points.left).setText('b').hide().unhide()
paths.c = new Path().move(points.left).line(points.top).setText('c')
paths.a = new Path().move(points.top).line(points.right).setText('a')
paths.b = new Path().move(points.right).line(points.left).setText('b').hide().unhide()
paths.c = new Path().move(points.left).line(points.top).setText('c')
return part
return part
}
```
</Example>
```