Skip to content

Commit

Permalink
Merge pull request #53 from quephird/add_parameter_labels
Browse files Browse the repository at this point in the history
Add parameter labels to all public API call sites
  • Loading branch information
quephird committed Nov 27, 2023
2 parents 4241862 + ff3fe94 commit 9da9c78
Show file tree
Hide file tree
Showing 40 changed files with 729 additions and 544 deletions.
19 changes: 11 additions & 8 deletions Examples/BallWithAreaLight/BallWithAreaLight.swift
Expand Up @@ -11,14 +11,17 @@ import ScintillaLib
@main
struct BallWithAreaLight: ScintillaApp {
var world: World = World {
AreaLight(
Point(-5, 5, -5),
Vector(2, 0, 0), 10,
Vector(0, 2, 0), 10)
Camera(400, 400, PI/3, .view(
Point(0, 2, -5),
Point(0, 1, 0),
Vector(0, 1, 0)))
AreaLight(corner: Point(-5, 5, -5),
uVec: Vector(2, 0, 0),
uSteps: 10,
vVec: Vector(0, 2, 0),
vSteps: 10)
Camera(width: 400,
height: 400,
viewAngle: PI/3,
from: Point(0, 2, -5),
to: Point(0, 1, 0),
up: Vector(0, 1, 0))
Sphere()
.translate(0, 1, 0)
.material(.solidColor(1, 0, 0))
Expand Down
14 changes: 8 additions & 6 deletions Examples/BarthSextic/BarthSextic.swift
Expand Up @@ -14,12 +14,14 @@ let φ: Double = 1.61833987
@main
struct BarthSextic: ScintillaApp {
var world: World = World {
PointLight(Point(-5, 5, -5))
Camera(400, 400, PI/3, .view(
Point(0, 0, -5),
Point(0, 0, 0),
Vector(0, 1, 0)))
ImplicitSurface((0.0, 0.0, 0.0), 2.0) { x, y, z in
PointLight(position: Point(-5, 5, -5))
Camera(width: 400,
height: 400,
viewAngle: PI/3,
from: Point(0, 0, -5),
to: Point(0, 0, 0),
up: Vector(0, 1, 0))
ImplicitSurface(center: (0.0, 0.0, 0.0), radius: 2.0) { x, y, z in
4.0*(φ*φ*x*x-y*y)*(φ*φ*y*y-z*z)*(φ*φ*z*z-x*x) - (1.0+2.0*φ)*(x*x+y*y+z*z-1.0)*(x*x+y*y+z*z-1.0)
}
.material(.solidColor(0.9, 0.9, 0.0))
Expand Down
15 changes: 9 additions & 6 deletions Examples/Blob/Blob.swift
Expand Up @@ -12,12 +12,15 @@ import ScintillaLib
@main
struct Blob: ScintillaApp {
var world = World {
PointLight(Point(-10, 10, -10))
Camera(400, 400, PI/3, .view(
Point(0, 0, -5),
Point(0, 0, 0),
Vector(0, 1, 0)))
ImplicitSurface((-2, -2, -2), (2, 2, 2), { x, y, z in
PointLight(position: Point(-10, 10, -10))
Camera(width: 400,
height: 400,
viewAngle: PI/3,
from: Point(0, 0, -5),
to: Point(0, 0, 0),
up: Vector(0, 1, 0))
ImplicitSurface(bottomFrontLeft: (-2, -2, -2),
topBackRight: (2, 2, 2), { x, y, z in
x*x + y*y + z*z + sin(4*x) + sin(4*y) + sin(4*z) - 1.0
})
.material(.solidColor(0.2, 1, 0.5))
Expand Down
28 changes: 16 additions & 12 deletions Examples/Breather/Breather.swift
Expand Up @@ -26,18 +26,22 @@ func z(u: Double, v: Double) -> Double {
@main
struct Breather: ScintillaApp {
var world = World {
PointLight(Point(-10, 10, -10))
Camera(400, 400, PI/3, .view(
Point(0, 0, -15),
Point(0, 0, 0),
Vector(0, 1, 0)))
ParametricSurface(
(-8, -5, -5), (8, 5, 5),
(-15, 15), (-38, 38),
0.001, 1.0,
{ (u, v) in x(u: u, v: v) },
{ (u, v) in y(u: u, v: v) },
{ (u, v) in z(u: u, v: v) })
PointLight(position: Point(-10, 10, -10))
Camera(width: 400,
height: 400,
viewAngle: PI/3,
from: Point(0, 0, -15),
to: Point(0, 0, 0),
up: Vector(0, 1, 0))
ParametricSurface(bottomFrontLeft: (-8, -5, -5),
topBackRight: (8, 5, 5),
uRange: (-15, 15),
vRange: (-38, 38),
accuracy: 0.001,
maxGradient: 1.0,
fx: { (u, v) in x(u: u, v: v) },
fy: { (u, v) in y(u: u, v: v) },
fz: { (u, v) in z(u: u, v: v) })
.material(.solidColor(0.1, 0.2, 1.0))
.rotateY(PI/8.0)
Plane()
Expand Down
30 changes: 17 additions & 13 deletions Examples/Cavatappi/Cavatappi.swift
Expand Up @@ -12,19 +12,23 @@ import ScintillaLib
@main
struct Cavatappi: ScintillaApp {
var world = World {
PointLight(Point(-10, 10, -10))
Camera(400, 400, PI/3, .view(
Point(0, 7, -15),
Point(0, 7, 0),
Vector(0, 1, 0)))
ParametricSurface(
(-3.5, 0, -3.5), (3.5, 15.0, 3.5),
(0, 2*PI), (0, 7*PI),
0.001, 1.0,
{ (u, v) in (2 + cos(u) + 0.1*cos(8*u))*cos(v) },
{ (u, v) in 2 + sin(u) + 0.1*sin(8*u) + 0.5*v },
{ (u, v) in (2 + cos(u) + 0.1*cos(8*u))*sin(v) })
.material(.solidColor(1.0, 0.8, 0))
PointLight(position: Point(-10, 10, -10))
Camera(width: 400,
height: 400,
viewAngle: PI/3,
from: Point(0, 7, -15),
to: Point(0, 7, 0),
up: Vector(0, 1, 0))
ParametricSurface(bottomFrontLeft: (-3.5, 0, -3.5),
topBackRight: (3.5, 15.0, 3.5),
uRange: (0, 2*PI),
vRange: (0, 7*PI),
accuracy: 0.001,
maxGradient: 1.0,
fx: { (u, v) in (2 + cos(u) + 0.1*cos(8*u))*cos(v) },
fy: { (u, v) in 2 + sin(u) + 0.1*sin(8*u) + 0.5*v },
fz: { (u, v) in (2 + cos(u) + 0.1*cos(8*u))*sin(v) })
.material(.solidColor(1.0, 0.8, 0))
Plane()
.material(.solidColor(1, 1, 1))
.translate(0, -3.0, 0)
Expand Down
15 changes: 9 additions & 6 deletions Examples/DecoCube/DecoCube.swift
Expand Up @@ -23,12 +23,15 @@ func decoCubeColor(_ x: Double, _ y: Double, _ z: Double) -> (Double, Double, Do
@main
struct DecoCube: ScintillaApp {
var world = World {
PointLight(Point(-10, 10, -10))
Camera(600, 600, PI/3, .view(
Point(2, 1, -6),
Point(0, 0, 0),
Vector(0, 1, 0)))
ImplicitSurface((-2.5, -2.5, -2.5), (2.5, 2.5, 2.5), { x, y, z in
PointLight(position: Point(-10, 10, -10))
Camera(width: 600,
height: 600,
viewAngle: PI/3,
from: Point(2, 1, -6),
to: Point(0, 0, 0),
up: Vector(0, 1, 0))
ImplicitSurface(bottomFrontLeft: (-2.5, -2.5, -2.5),
topBackRight: (2.5, 2.5, 2.5), { x, y, z in
decoCubeShape(x, y, z)
})
.material(.colorFunction(.hsl) { x, y, z in
Expand Down
18 changes: 10 additions & 8 deletions Examples/Die/Die.swift
Expand Up @@ -15,25 +15,27 @@ struct Die: ScintillaApp {
.reflective(0.2)

return World {
PointLight(Point(-10, 10, -10))
Camera(800, 600, PI/3, .view(
Point(0, 5, -10),
Point(0, 0, 0),
Vector(0, 1, 0)))
PointLight(position: Point(-10, 10, -10))
Camera(width: 800,
height: 600,
viewAngle: PI/3,
from: Point(0, 5, -10),
to: Point(0, 0, 0),
up: Vector(0, 1, 0))
Cube()
.material(orange)
.intersection {
Sphere()
.material(orange)
.scale(1.55, 1.55, 1.55)
Cylinder(-2, 2, true)
Cylinder(bottomY: -2, topY: 2, isCapped: true)
.material(orange)
.scale(1.35, 1.35, 1.35)
Cylinder(-2, 2, true)
Cylinder(bottomY: -2, topY: 2, isCapped: true)
.material(orange)
.scale(1.35, 1.35, 1.35)
.rotateX(PI/2)
Cylinder(-2, 2, true)
Cylinder(bottomY: -2, topY: 2, isCapped: true)
.material(orange)
.scale(1.35, 1.35, 1.35)
.rotateZ(PI/2)
Expand Down
25 changes: 14 additions & 11 deletions Examples/HappyHalloween/HappyHalloween.swift
Expand Up @@ -24,38 +24,41 @@ func stem(x: Double, y: Double, z: Double) -> Double {
@main
struct HappyHalloween: ScintillaApp {
var world: World = World {
PointLight(Point(-2, 5, -5))
Camera(600, 600, PI/3, .view(
Point(0, 2, -5),
Point(0, 0, 0),
Vector(0, 1, 0)))
ImplicitSurface((0.0, 0.0, 0.0), 2.0) { x, y, z in
PointLight(position: Point(-2, 5, -5))
Camera(width: 600,
height: 600,
viewAngle: PI/3,
from: Point(0, 2, -5),
to: Point(0, 0, 0),
up: Vector(0, 1, 0))
ImplicitSurface(center: (0.0, 0.0, 0.0), radius: 2.0) { x, y, z in
pumpkin(x: x, y: y, z: z)
}
.material(.solidColor(1.0, 0.5, 0.0))
.scale(2.0, 1.5, 2.0)
.difference {
Prism(-1.0, 1.5, [(0.0, 0.5), (-0.25, 0), (0.25, 0.0)]) // Right eye
Prism(bottomY: -1.0, topY: 1.5, xzPoints: [(0.0, 0.5), (-0.25, 0), (0.25, 0.0)]) // Right eye
.material(.solidColor(1.0, 0.8, 0.0))
.rotateX(-PI/2.0)
.translate(-0.5, 0.4, -1.5)
Prism(-1.0, 1.5, [(0.0, 0.5), (-0.25, 0), (0.25, 0.0)]) // Left eye
Prism(bottomY: -1.0, topY: 1.5, xzPoints: [(0.0, 0.5), (-0.25, 0), (0.25, 0.0)]) // Left eye
.material(.solidColor(1.0, 0.8, 0.0))
.rotateX(-PI/2.0)
.translate(0.5, 0.4, -1.5)
Prism(-1.0, 1.5, [(0.0, 0.25), (-0.1, 0), (0.1, 0.0)]) // Nose
Prism(bottomY: -1.0, topY: 1.5, xzPoints: [(0.0, 0.25), (-0.1, 0), (0.1, 0.0)]) // Nose
.material(.solidColor(1.0, 0.8, 0.0))
.rotateX(-PI/2.0)
.translate(0.0, 0.3, -1.5)
Prism(-1.0, 1.5, [(-0.75, 0.0), (-0.5, -0.25), // Mouth
Prism(bottomY: -1.0, topY: 1.5, xzPoints: [(-0.75, 0.0), (-0.5, -0.25), // Mouth
(-0.4, -0.25), (-0.4, -0.15), (-0.3, -0.15), (-0.3, -0.25),
(0.5, -0.25), (0.75, 0.0),
(0.4, 0.0), (0.4, -0.1), (0.3, -0.1), (0.3, 0.0)])
.material(.solidColor(1.0, 0.8, 0.0))
.rotateX(-PI/2.0)
.translate(0.0, 0.1, -1.7)
}
ImplicitSurface((-1.5, 0, -1.5), (1.5, 1, 1.5)) { x, y, z in
ImplicitSurface(bottomFrontLeft: (-1.5, 0, -1.5),
topBackRight: (1.5, 1, 1.5)) { x, y, z in
stem(x: x, y: y, z: z)
}
.material(.solidColor(0.9, 0.9, 0.7))
Expand Down
12 changes: 7 additions & 5 deletions Examples/HollowedSphere/HollowedSphere.swift
Expand Up @@ -11,11 +11,13 @@ import ScintillaLib
@main
struct HollowedSphere: ScintillaApp {
var world = World {
PointLight(Point(-10, 10, -10))
Camera(400, 400, PI/3, .view(
Point(0, 1.5, -2),
Point(0, 0, 0),
Vector(0, 1, 0)))
PointLight(position: Point(-10, 10, -10))
Camera(width: 400,
height: 400,
viewAngle: PI/3,
from: Point(0, 1.5, -2),
to: Point(0, 0, 0),
up: Vector(0, 1, 0))
Sphere()
.material(.solidColor(0, 0, 1))
.intersection {
Expand Down
30 changes: 17 additions & 13 deletions Examples/Hourglass/Hourglass.swift
Expand Up @@ -12,19 +12,23 @@ import ScintillaLib
@main
struct Hourglass: ScintillaApp {
var world = World {
PointLight(Point(-10, 10, -10))
Camera(400, 400, PI/3, .view(
Point(0, 1, -5),
Point(0, 0, 0),
Vector(0, 1, 0)))
ParametricSurface(
(-1.0, -1.0, -1.0), (1.0, 1.0, 1.0),
(0, 2*PI), (0, 2*PI),
0.001, 1.0,
{ (u, v) in cos(u)*sin(2*v) },
{ (u, v) in sin(v) },
{ (u, v) in sin(u)*sin(2*v) })
.material(.solidColor(0.9, 0.5, 0.5, .hsl))
PointLight(position: Point(-10, 10, -10))
Camera(width: 400,
height: 400,
viewAngle: PI/3,
from: Point(0, 1, -5),
to: Point(0, 0, 0),
up: Vector(0, 1, 0))
ParametricSurface(bottomFrontLeft: (-1.0, -1.0, -1.0),
topBackRight: (1.0, 1.0, 1.0),
uRange: (0, 2*PI),
vRange: (0, 2*PI),
accuracy: 0.001,
maxGradient: 1.0,
fx: { (u, v) in cos(u)*sin(2*v) },
fy: { (u, v) in sin(v) },
fz: { (u, v) in sin(u)*sin(2*v) })
.material(.solidColor(0.9, 0.5, 0.5, .hsl))
Plane()
.material(.solidColor(1, 1, 1))
.translate(0, -1.0, 0)
Expand Down
12 changes: 7 additions & 5 deletions Examples/QuickStart/QuickStart.swift
Expand Up @@ -11,11 +11,13 @@ import ScintillaLib
@main
struct QuickStart: ScintillaApp {
var world = World {
PointLight(Point(-10, 10, -10))
Camera(400, 400, PI/3, .view(
Point(0, 2, -2),
Point(0, 0, 0),
Vector(0, 1, 0)))
PointLight(position: Point(-10, 10, -10))
Camera(width: 400,
height: 400,
viewAngle: PI/3,
from: Point(0, 2, -2),
to: Point(0, 0, 0),
up: Vector(0, 1, 0))
Sphere()
.material(.solidColor(1, 0, 0))
}
Expand Down
14 changes: 8 additions & 6 deletions Examples/RainbowBall/RainbowBall.swift
Expand Up @@ -10,13 +10,15 @@ import ScintillaLib

@available(macOS 12.0, *)
@main
struct QuickStart: ScintillaApp {
struct RainbowBall: ScintillaApp {
var world = World {
PointLight(Point(-10, 10, -10))
Camera(400, 400, PI/3, .view(
Point(0, 2, -2),
Point(0, 0, 0),
Vector(0, 1, 0)))
PointLight(position: Point(-10, 10, -10))
Camera(width: 400,
height: 400,
viewAngle: PI/3,
from: Point(0, 2, -2),
to: Point(0, 0, 0),
up: Vector(0, 1, 0))
Sphere()
.material(.colorFunction(.hsl) { x, y, z in
((atan2(z, x)+PI)/PI/2.0, 1.0, 0.5)
Expand Down
28 changes: 16 additions & 12 deletions Examples/Rings/Rings.swift
Expand Up @@ -12,18 +12,22 @@ import ScintillaLib
@main
struct Rings: ScintillaApp {
var world = World {
PointLight(Point(-10, 10, -10))
Camera(400, 400, PI/3, .view(
Point(-10, 7, -10),
Point(0, 0, 0),
Vector(0, 1, 0)))
ParametricSurface(
(-6, -3, -6), (6, 3, 6),
(0, 2*PI), (0, 2*PI),
0.001, 3.0,
{ (u, v) in (4*(1 + 0.25*sin(3.0*v)) + cos(u))*cos(2.0*v) },
{ (u, v) in sin(u) + 2.0*cos(3*v) },
{ (u, v) in (4*(1 + 0.25*sin(3.0*v)) + cos(u))*sin(2.0*v) })
PointLight(position: Point(-10, 10, -10))
Camera(width: 400,
height: 400,
viewAngle: PI/3,
from: Point(-10, 7, -10),
to: Point(0, 0, 0),
up: Vector(0, 1, 0))
ParametricSurface(bottomFrontLeft: (-6, -3, -6),
topBackRight: (6, 3, 6),
uRange: (0, 2*PI),
vRange: (0, 2*PI),
accuracy: 0.001,
maxGradient: 3.0,
fx: { (u, v) in (4*(1 + 0.25*sin(3.0*v)) + cos(u))*cos(2.0*v) },
fy: { (u, v) in sin(u) + 2.0*cos(3*v) },
fz: { (u, v) in (4*(1 + 0.25*sin(3.0*v)) + cos(u))*sin(2.0*v) })
.material(.solidColor(0.1, 1.0, 0.2))
Plane()
.material(.solidColor(1, 1, 1))
Expand Down

0 comments on commit 9da9c78

Please sign in to comment.