From adb568a97e9a7ba771748f7f17d12d1dd4f8b490 Mon Sep 17 00:00:00 2001 From: Lazaro Alonso Date: Sun, 18 Aug 2024 14:15:39 +0200 Subject: [PATCH] filled 3d curve --- docs/src/.vitepress/config.mts | 1 + examples/3d/lines3d/filled3d_curve.jl | 35 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 examples/3d/lines3d/filled3d_curve.jl diff --git a/docs/src/.vitepress/config.mts b/docs/src/.vitepress/config.mts index cea0b6f3..6a77ac14 100644 --- a/docs/src/.vitepress/config.mts +++ b/docs/src/.vitepress/config.mts @@ -331,6 +331,7 @@ const viteConfig = defineViteConfig({ items: [ { text: 'archimedean_spiral',link: '/examples/3d/lines3d/archimedean_spiral' }, { text: 'lines3d',link: '/examples/3d/lines3d/line3d' }, + { text: 'Filled 3d curve',link: '/examples/3d/lines3d/filled3d_curve'}, { text: 'lines_wire_contour_3d',link: '/examples/3d/lines3d/lines_wire_contour_3d' }, { text: 'wireframe_torus',link: '/examples/3d/lines3d/wireframe_torus' }, ], diff --git a/examples/3d/lines3d/filled3d_curve.jl b/examples/3d/lines3d/filled3d_curve.jl new file mode 100644 index 00000000..e12ebfd2 --- /dev/null +++ b/examples/3d/lines3d/filled3d_curve.jl @@ -0,0 +1,35 @@ +# ## Filled curve in 3d + +# From: https://discourse.julialang.org/t/fill-a-curve-in-3d/37890/8 + +using GLMakie +GLMakie.activate!() + +x = 0:0.05:3; +y = 0:0.05:3; +z = @. sin(x) * exp(-(x+y)) + +fig = Figure(; size=(600, 400)) +ax = Axis3(fig[1,1]; limits=((0,3), (0,3), (0,0.2)), + perspectiveness = 0.5, + azimuth = -0.5, + elevation = 0.3,) +lines!(Point3f.(x, 0, z), transparency=true) +lines!(Point3f.(0, y, z), transparency=true) +band!(Point3f.(x, y, 0), Point3f.(x, y, z); + color=(:orangered, 0.25), transparency=true) +lines!(Point3f.(x, y, z); color=(:orangered, 0.9), transparency=true) +fig + +# ## Filled gradient under 3D curve + +fig = Figure(; size=(600, 400)) +ax = Axis3(fig[1,1]; limits=((0,3), (0,3), (0,0.2)), + perspectiveness = 0.5, + azimuth = -0.5, + elevation = 0.3,) + +band!(Point3f.(x, y, 0), Point3f.(x, y, z); color = z, + colormap = (:Spectral, 0.85), transparency=true) +lines!(Point3f.(x, y, z); color=(:black, 0.9), transparency=true) +fig