Patterns fixes (2d) (#2197)

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* patterns fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix docs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* better autocomplete

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-04-23 10:31:20 -07:00
committed by GitHub
parent 2d8d29b345
commit c620f7269c
12 changed files with 5286 additions and 2358 deletions

View File

@ -0,0 +1,56 @@
// Lego Brick
const lbumps = 10 // number of bumps long
const wbumps = 6 // number of bumps wide
const pitch = 8.0
const clearance = 0.1
const bumpDiam = 4.8
const bumpHeight = 1.8
const height = 3.2
const t = (pitch - (2 * clearance) - bumpDiam) / 2.0
const postDiam = pitch - t // works out to 6.5
const total_length = lbumps * pitch - (2.0 * clearance)
const total_width = wbumps * pitch - (2.0 * clearance)
const lSegments = total_length / (lbumps + 1)
const wSegments = total_width / (wbumps + 1)
// make the base
const s = startSketchOn('XY')
|> startProfileAt([-total_width / 2, -total_length / 2], %)
|> line([total_width, 0], %)
|> line([0, total_length], %)
|> line([-total_width, 0], %)
|> close(%)
|> extrude(height, %)
const shellExtrude = startSketchOn(s, "start")
|> startProfileAt([
-(total_width / 2 - t),
-(total_length / 2 - t)
], %)
|> line([total_width - (2 * t), 0], %)
|> line([0, total_length - (2 * t)], %)
|> line([-(total_width - (2 * t)), 0], %)
|> close(%)
|> extrude(-(height - t), %)
const peg = startSketchOn(s, "end")
|> circle([
-(total_width / 2 - wSegments),
-(total_length / 2 - lSegments)
], bumpDiam / 2, %)
|> patternLinear2d({
axis: [1, 0],
repetitions: 5,
distance: 7
}, %)
|> patternLinear2d({
axis: [0, 1],
repetitions: 9,
distance: 7
}, %)
|> extrude(bumpHeight, %)

View File

@ -115,6 +115,15 @@ async fn serial_test_riddle_small() {
twenty_twenty::assert_image("tests/executor/outputs/riddle_small.png", &result, 0.999);
}
#[tokio::test(flavor = "multi_thread")]
async fn serial_test_lego() {
let code = include_str!("inputs/lego.kcl");
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
.await
.unwrap();
twenty_twenty::assert_image("tests/executor/outputs/lego.png", &result, 0.999);
}
#[tokio::test(flavor = "multi_thread")]
async fn serial_test_pentagon_fillet_desugar() {
let code = include_str!("inputs/pentagon_fillet_desugar.kcl");

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB