KCL: Another example of how to use hex color strings (#7195)
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -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",
|
||||
|
@ -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 |
Reference in New Issue
Block a user