chore(markdown): Updating final Point docs for v3
This commit is contained in:
parent
aea681ab92
commit
e314e58e33
9 changed files with 118 additions and 108 deletions
|
@ -18,17 +18,19 @@ float point.angle(Point pointB)
|
|||
```js
|
||||
({ Point, points, Path, paths, part }) => {
|
||||
|
||||
points.sun = new Point(10, 5);
|
||||
points.moon = points.sun.shift(-15, 70);
|
||||
points.sun = new Point(10, 5)
|
||||
points.moon = points.sun.shift(-15, 70)
|
||||
points.text = points.sun
|
||||
.shiftFractionTowards(points.moon, 0.8)
|
||||
.attr("data-text", points.sun.angle(points.moon)+"°")
|
||||
.attr("data-text-class", "text-sm fill-note center");
|
||||
.setText(
|
||||
points.sun.angle(points.moon)+"°",
|
||||
"text-sm fill-note center"
|
||||
)
|
||||
|
||||
paths.line = new Path()
|
||||
.move(points.sun)
|
||||
.line(points.moon)
|
||||
.attr("class", "dashed");
|
||||
.setClass("dashed")
|
||||
|
||||
return part
|
||||
}
|
||||
|
|
2
markdown/dev/reference/api/point/dist/en.md
vendored
2
markdown/dev/reference/api/point/dist/en.md
vendored
|
@ -27,7 +27,7 @@ float point.dist(Point point)
|
|||
paths.line = new Path()
|
||||
.move(points.from)
|
||||
.line(points.to)
|
||||
.attr('class', 'dashed')
|
||||
.setClass('dashed')
|
||||
|
||||
return part
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ Point point.flipX(Point mirror = false)
|
|||
.line(points._out2)
|
||||
.line(points._in1)
|
||||
.line(points._out1)
|
||||
.close();
|
||||
.close()
|
||||
|
||||
paths.mirror = new Path()
|
||||
.move(points.top)
|
||||
|
|
|
@ -18,38 +18,38 @@ Point point.flipY(Point mirror = false)
|
|||
```js
|
||||
({ Point, points, Path, paths, part }) => {
|
||||
|
||||
points.start = new Point(0, 50);
|
||||
points.churchTowerWallLeft = new Point(10, 50);
|
||||
points.churchTowerRoofLeft = new Point(10, 30);
|
||||
points.churchTowerTop = new Point(15, 10);
|
||||
points.churchTowerRoofRight = new Point(20, 30);
|
||||
points.churchRoofRight = new Point(50, 30);
|
||||
points.churchWallRight = new Point(50, 50);
|
||||
points.houseWallLeft = new Point(65, 50);
|
||||
points.houseRoofLeft = new Point(65, 35);
|
||||
points.houseRoofTop = new Point(75, 25);
|
||||
points.houseRoofRight = new Point(85, 35);
|
||||
points.houseWallRight = new Point(85, 50);
|
||||
points.end = new Point(95, 50);
|
||||
points.start = new Point(0, 50)
|
||||
points.churchTowerWallLeft = new Point(10, 50)
|
||||
points.churchTowerRoofLeft = new Point(10, 30)
|
||||
points.churchTowerTop = new Point(15, 10)
|
||||
points.churchTowerRoofRight = new Point(20, 30)
|
||||
points.churchRoofRight = new Point(50, 30)
|
||||
points.churchWallRight = new Point(50, 50)
|
||||
points.houseWallLeft = new Point(65, 50)
|
||||
points.houseRoofLeft = new Point(65, 35)
|
||||
points.houseRoofTop = new Point(75, 25)
|
||||
points.houseRoofRight = new Point(85, 35)
|
||||
points.houseWallRight = new Point(85, 50)
|
||||
points.end = new Point(95, 50)
|
||||
|
||||
points.mirror = new Point(0, 60);
|
||||
points.mirrorLineEnd = new Point(95, 60);
|
||||
points.mirror = new Point(0, 60)
|
||||
points.mirrorLineEnd = new Point(95, 60)
|
||||
|
||||
points._start = points.start.flipY(points.mirror);
|
||||
points._churchTowerWallLeft = points.churchTowerWallLeft.flipY(points.mirror);
|
||||
points._churchTowerRoofLeft = points.churchTowerRoofLeft.flipY(points.mirror);
|
||||
points._churchTowerTop = points.churchTowerTop.flipY(points.mirror);
|
||||
points._start = points.start.flipY(points.mirror)
|
||||
points._churchTowerWallLeft = points.churchTowerWallLeft.flipY(points.mirror)
|
||||
points._churchTowerRoofLeft = points.churchTowerRoofLeft.flipY(points.mirror)
|
||||
points._churchTowerTop = points.churchTowerTop.flipY(points.mirror)
|
||||
points._churchTowerRoofRight = points.churchTowerRoofRight.flipY(
|
||||
points.mirror
|
||||
);
|
||||
points._churchRoofRight = points.churchRoofRight.flipY(points.mirror);
|
||||
points._churchWallRight = points.churchWallRight.flipY(points.mirror);
|
||||
points._houseWallLeft = points.houseWallLeft.flipY(points.mirror);
|
||||
points._houseRoofLeft = points.houseRoofLeft.flipY(points.mirror);
|
||||
points._houseRoofTop = points.houseRoofTop.flipY(points.mirror);
|
||||
points._houseRoofRight = points.houseRoofRight.flipY(points.mirror);
|
||||
points._houseWallRight = points.houseWallRight.flipY(points.mirror);
|
||||
points._end = points.end.flipY(points.mirror);
|
||||
)
|
||||
points._churchRoofRight = points.churchRoofRight.flipY(points.mirror)
|
||||
points._churchWallRight = points.churchWallRight.flipY(points.mirror)
|
||||
points._houseWallLeft = points.houseWallLeft.flipY(points.mirror)
|
||||
points._houseRoofLeft = points.houseRoofLeft.flipY(points.mirror)
|
||||
points._houseRoofTop = points.houseRoofTop.flipY(points.mirror)
|
||||
points._houseRoofRight = points.houseRoofRight.flipY(points.mirror)
|
||||
points._houseWallRight = points.houseWallRight.flipY(points.mirror)
|
||||
points._end = points.end.flipY(points.mirror)
|
||||
|
||||
paths.skylineTop = new Path()
|
||||
.move(points.start)
|
||||
|
@ -64,7 +64,7 @@ Point point.flipY(Point mirror = false)
|
|||
.line(points.houseRoofTop)
|
||||
.line(points.houseRoofRight)
|
||||
.line(points.houseWallRight)
|
||||
.line(points.end);
|
||||
.line(points.end)
|
||||
|
||||
return part
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@ Point point.rotate(float angle, Point center)
|
|||
```js
|
||||
({ Point, points, Path, paths, Snippet, snippets, part }) => {
|
||||
|
||||
points.sun = new Point(40, 40);
|
||||
points.moon = new Point(70, 40);
|
||||
let step = 360 / 36;
|
||||
points.sun = new Point(40, 40)
|
||||
points.moon = new Point(70, 40)
|
||||
let step = 360 / 36
|
||||
for (let i = 1; i < 37; i++) {
|
||||
let angle = step * i;
|
||||
points[`moon${i}`] = points.moon.rotate(angle, points.sun);
|
||||
paths[`moon${i}`] = new Path().move(points.sun).line(points[`moon${i}`]);
|
||||
let angle = step * i
|
||||
points[`moon${i}`] = points.moon.rotate(angle, points.sun)
|
||||
paths[`moon${i}`] = new Path().move(points.sun).line(points[`moon${i}`])
|
||||
}
|
||||
|
||||
return part
|
||||
|
|
|
@ -21,32 +21,31 @@ Point point.shiftFractionTowards(Point target, float fraction)
|
|||
```js
|
||||
({ Point, points, Path, paths, macro, part }) => {
|
||||
|
||||
points.A = new Point(90, 70).attr("data-text", "Point A");
|
||||
points.B = new Point(10, 10).attr("data-text", "Point B");
|
||||
points.A = new Point(90, 70).setText("Point A", "text-sm")
|
||||
points.B = new Point(10, 10).setText("Point B", "text-sm")
|
||||
points.C = points.A.shiftFractionTowards(points.B, 0.5)
|
||||
.attr(
|
||||
"data-text",
|
||||
"Point C is point A shifted 50%\nin the direction of point B"
|
||||
.setText(
|
||||
"Point C is point A shifted 50%\nin the direction of point B",
|
||||
"center text-sm"
|
||||
)
|
||||
.attr("data-text-class", "center")
|
||||
.attr("data-text-lineheight", 6);
|
||||
.attr("data-text-lineheight", 6)
|
||||
|
||||
paths.direction = new Path()
|
||||
.move(points.A)
|
||||
.line(points.B)
|
||||
.attr("class", "note dashed");
|
||||
.setClass("note dashed")
|
||||
|
||||
macro("ld", {
|
||||
from: points.C,
|
||||
to: points.A,
|
||||
d: -10
|
||||
});
|
||||
})
|
||||
|
||||
macro("ld", {
|
||||
from: points.B,
|
||||
to: points.A,
|
||||
d: 20
|
||||
});
|
||||
})
|
||||
|
||||
return part
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ bool point.sitsOn(Point check)
|
|||
.move(new Point(0,0))
|
||||
.move(new Point(90,70))
|
||||
|
||||
|
||||
return part
|
||||
}
|
||||
```
|
||||
|
|
|
@ -2,41 +2,47 @@
|
|||
title: Point.sitsRoughlyOn()
|
||||
---
|
||||
|
||||
Returns `true` if this point has roughly (rounded to the nearest millimeter) the same coordinates as the one you pass to it.
|
||||
The `Point.sitsRoughlyOn()` method returns `true` if this point has roughly
|
||||
(rounded to the nearest millimeter) the same coordinates as the one you pass to
|
||||
it.
|
||||
|
||||
## Point.sitsRoughlyOn() signature
|
||||
## Signature
|
||||
|
||||
```js
|
||||
bool point.sitsRoughlyOn(Point check)
|
||||
```
|
||||
|
||||
<Note>
|
||||
|
||||
###### How rough?
|
||||
|
||||
The difference between this method and [`Point.sitsOn()`](/reference/api/point/sitson/) is
|
||||
that this one rounds things down to the nearest integer (thus mm) before checking.
|
||||
|
||||
</Note>
|
||||
|
||||
## Point.sitsRoughlyOn() example
|
||||
|
||||
<Example part="point_sitsroughlyon">
|
||||
An example of the Point.sitsRoughlyOn() method
|
||||
</Example>
|
||||
## Example
|
||||
|
||||
<Example caption="An example of the Point.sitsRoughlyOn() method">
|
||||
```js
|
||||
let { Point, points, Snippet, snippets } = part.shorthand();
|
||||
({ Point, points, Path, paths, Snippet, snippets, part }) => {
|
||||
|
||||
box(part);
|
||||
let s
|
||||
for (let i = 0; i < 10; i++) {
|
||||
points[`a${i}`] = new Point(i * 10, 40)
|
||||
points[`b${i}`] = new Point(i * 10, i * 8)
|
||||
if (points[`a${i}`].sitsRoughlyOn(points[`b${i}`])) s = "notch"
|
||||
else s = "bnotch"
|
||||
snippets[`b${i}`] = new Snippet(s, points[`b${i}`])
|
||||
snippets[`a${i}`] = new Snippet(s, points[`a${i}`])
|
||||
}
|
||||
|
||||
let s;
|
||||
for (let i = 0; i < 10; i++) {
|
||||
points[`a${i}`] = new Point(i * 10, 40);
|
||||
points[`b${i}`] = new Point(i * 10, i * 8);
|
||||
if (points[`a${i}`].sitsRoughlyOn(points[`b${i}`])) s = "notch";
|
||||
else s = "bnotch";
|
||||
snippets[`b${i}`] = new Snippet(s, points[`b${i}`]);
|
||||
snippets[`a${i}`] = new Snippet(s, points[`a${i}`]);
|
||||
// Prevent clipping
|
||||
paths.diag = new Path()
|
||||
.move(new Point(0,0))
|
||||
.move(new Point(90,70))
|
||||
|
||||
return part
|
||||
}
|
||||
```
|
||||
</Example>
|
||||
|
||||
|
||||
## Notes
|
||||
|
||||
The difference between this method and
|
||||
[`Point.sitsOn()`](/reference/api/point/sitson/) is that this one rounds things
|
||||
down to the nearest integer (thus mm) before checking.
|
||||
|
||||
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
title: Point.translate()
|
||||
---
|
||||
|
||||
Returns a new `Point` with a [translate transform](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/translate) applied.
|
||||
The `Point.translate()` method returns a new `Point` with a [translate
|
||||
transform](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/translate)
|
||||
applied.
|
||||
|
||||
## Point.translate() signature
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Point point.translate(float deltaX, float deltaY)
|
||||
|
@ -15,34 +17,36 @@ In other words, this will:
|
|||
- Add `deltaX` to the point's X-coordinate
|
||||
- Add `deltaY` to the point's Y-coordinate
|
||||
|
||||
Positive values for `deltaX` will move the point to the right. Positive values for `deltaY` will move the point downwards.
|
||||
Positive values for `deltaX` will move the point to the right.
|
||||
Positive values for `deltaY` will move the point downwards.
|
||||
|
||||
## Point.translate() example
|
||||
## Example
|
||||
|
||||
<Example part="point_translate">
|
||||
An example of the Point.translate() method
|
||||
<Example caption="An example of the Point.translate() method">
|
||||
```js
|
||||
({ Point, points, Snippet, snippets, macro, part }) => {
|
||||
|
||||
points.A = new Point(10, 10).setText("Point A", "text-sm")
|
||||
points.B = points.A.translate(120, 60)
|
||||
.setText(
|
||||
"Point B is point A with a\ntranslate(120, 60)\ntransform applied",
|
||||
"right text-sm"
|
||||
)
|
||||
.attr("data-text-dy", -6)
|
||||
.attr("data-text-lineheight", 6)
|
||||
|
||||
snippets.A = new Snippet("x", points.A)
|
||||
snippets.B = new Snippet("x", points.B)
|
||||
|
||||
macro("ld", {
|
||||
from: points.A,
|
||||
to: points.B,
|
||||
text: "translate(120,60)",
|
||||
noStartMarker: true
|
||||
})
|
||||
|
||||
return part
|
||||
}
|
||||
```
|
||||
</Example>
|
||||
|
||||
```js
|
||||
let { Point, points, Snippet, snippets, macro } = part.shorthand();
|
||||
|
||||
points.A = new Point(10, 10).attr("data-text", "Point A");
|
||||
points.B = points.A.translate(120, 60)
|
||||
.attr(
|
||||
"data-text",
|
||||
"Point B is point A with a\ntranslate(120, 60)\ntransform applied"
|
||||
)
|
||||
.attr("data-text-class", "right")
|
||||
.attr("data-text-dy", -6)
|
||||
.attr("data-text-lineheight", 6);
|
||||
|
||||
snippets.A = new Snippet("x", points.A);
|
||||
snippets.B = new Snippet("x", points.B);
|
||||
|
||||
macro("ld", {
|
||||
from: points.A,
|
||||
to: points.B,
|
||||
text: "translate(120,60)",
|
||||
noStartMarker: true
|
||||
});
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue