KCL: Another example of how to use hex color strings (#7195)

This commit is contained in:
Adam Chalmers
2025-05-23 22:09:37 -05:00
committed by GitHub
parent 678433d2b3
commit fa9d5a0104
4 changed files with 66 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -46,6 +46,7 @@ pub const TEST_NAMES: &[&str] = &[
"std-appearance-hexString-0",
"std-appearance-hexString-1",
"std-appearance-hexString-2",
"std-appearance-hexString-3",
"std-array-map-0",
"std-array-map-1",
"std-array-pop-0",

View File

@ -56,6 +56,37 @@
/// grid(offset = 0, red = 0)
/// ```
///
/// ```kcl
/// sideLen = 30
/// n = 4
///
/// fn cube(offset, i, red) {
/// x = floor(i / n)
/// y = rem(i, divisor = n)
/// g = 255 / n * x
/// b = 255 / n * y
/// return startSketchOn(offsetPlane(XY, offset))
/// |> circle(diameter = sideLen, center = [sideLen * x * 1.5, sideLen * y * 1.5])
/// |> extrude(length = sideLen)
/// |> appearance(color = appearance::hexString([red, g, b]), metalness = 80, roughness = 40)
/// }
///
/// fn grid(offset, red) {
/// return map(
/// [0 ..< n * n],
/// f = fn(@i) {
/// return cube(offset, i, red)
/// },
/// )
/// }
///
/// map(
/// [0..<n],
/// f = fn(@i) {
/// return grid(offset = i * sideLen * 2, red = 255 * i / n)
/// },
/// )
/// ```
@(impl = std_rust)
export fn hexString(
/// The red, blue and green components of the color.

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB