Files
modeling-app/rust/kcl-python-bindings/files/walkie-talkie/zoo-logo.kcl
Adam Chalmers aea82e004a KCL: Convert x/y lines to use keyword arguments (#5615)
Previously, `xLine`, `xLineTo`, `yLine` and `yLineTo` used positional arguments. Now:

- `xLineTo` and `yLineTo` have been removed
- `xLine` and `yLine` both use keyword arguments:
  - `length`, optional (i.e. a relative distance along the X or Y axis)
  - `endAbsolute` optional (i.e. an absolute point along the X or Y axis)
  - `tag` optional
- Exactly one of `length` or `endAbsolute` must be given. Not both, not neither.

For example:

```
// Old way
|> xLine(6.04, %)
|> yLineTo(20, %, $base)

// New way
|> xLine(length = 6.04)
|> yLine(endAbsolute = 20, tag = $base)
```

This also improves some of the general-purpose keyword arguments code in modeling app's TS codebase.
2025-03-07 22:07:16 -06:00

83 lines
2.1 KiB
Plaintext

// Zoo logo
// Define a function to draw the ZOO "Z"
export fn zLogo(surface, origin, scale) {
zSketch = surface
|> startProfileAt([
0 + origin[0],
0.15 * scale + origin[1]
], %)
|> yLine(length = -0.15 * scale)
|> xLine(length = 0.15 * scale)
|> angledLineToX({
angle = 47.15,
to = 0.3 * scale + origin[0]
}, %, $seg1)
|> yLine(endAbsolute = 0 + origin[1], tag = $seg3)
|> xLine(length = 0.63 * scale)
|> yLine(length = 0.225 * scale)
|> xLine(length = -0.57 * scale)
|> angledLineToX({
angle = 47.15,
to = 0.93 * scale + origin[0]
}, %)
|> yLine(length = 0.15 * scale)
|> xLine(length = -0.15 * scale)
|> angledLine({
angle = 47.15,
length = -segLen(seg1)
}, %, $seg2)
|> yLine(length = segLen(seg3))
|> xLine(endAbsolute = 0 + origin[0])
|> yLine(length = -0.225 * scale)
|> angledLineThatIntersects({
angle = 0,
intersectTag = seg2,
offset = 0
}, %)
|> close()
return zSketch
}
// Define a function to draw the ZOO "O"
export fn oLogo(surface, origin, scale) {
oSketch001 = surface
|> startProfileAt([
.788 * scale + origin[0],
.921 * scale + origin[1]
], %)
|> arc({
angleStart = 47.15 + 6,
angleEnd = 47.15 - 6 + 180,
radius = .525 * scale
}, %)
|> angledLine({ angle = 47.15, length = .24 * scale }, %)
|> arc({
angleStart = 47.15 - 11 + 180,
angleEnd = 47.15 + 11,
radius = .288 * scale
}, %)
|> close()
return oSketch001
}
export fn oLogo2(surface, origin, scale) {
oSketch002 = surface
|> startProfileAt([
.16 * scale + origin[0],
.079 * scale + origin[1]
], %)
|> arc({
angleStart = 47.15 + 6 - 180,
angleEnd = 47.15 - 6,
radius = .525 * scale
}, %)
|> angledLine({ angle = 47.15, length = -.24 * scale }, %)
|> arc({
angleStart = 47.15 - 11,
angleEnd = 47.15 + 11 - 180,
radius = .288 * scale
}, %)
|> close()
return oSketch002
}