@@ -3,10 +3,10 @@ using GLMakie
33using GeometryBasics
44using Observables
55using FileIO
6- using MakieGallery
76using GeometryBasics: Pyramid
7+ using PlotUtils
88
9- scatter (1 : 4 , color= rand (RGBf0, 4 ))
9+ scatter (1 : 4 , color= rand (RGBf0, 4 )) |> display
1010scatter (1 : 4 , color= :red )
1111
1212scatter (1 : 4 , marker= ' ☼' )
@@ -69,12 +69,15 @@ contour(rand(4, 4, 4)) |> display
6969# Meshes
7070using MeshIO, FileIO
7171cat = load (GLMakie. assetpath (" cat.obj" ))
72- tex = load (GLMakie. assetpath (" diffusemap.tga" ))
72+ tex = load (GLMakie. assetpath (" diffusemap.tga" ));
7373scren = mesh (cat, color= tex)
7474
7575m = mesh ([(0.0 , 0.0 ), (0.5 , 1.0 ), (1.0 , 0.0 )], color = [:red , :green , :blue ],
7676 shading = false ) |> display
7777
78+ meshes = GeometryBasics. normal_mesh .([Sphere (Point3f0 (0.5 ), 1 ), Rect (Vec3f0 (1 , 0 , 0 ), Vec3f0 (1 ))])
79+ mesh (meshes, color= [1 , 2 ])
80+
7881# Axis
7982scene = lines (IRect (Vec2f0 (0 ), Vec2f0 (1 )))
8083axis = scene[Axis]
8588
8689# Text
8790x = text (" heyllo" ) |> display
91+
92+
93+ # Gradients
94+ data = ((x, y) -> x^ 2 + y^ 2 ). (1 : 100 , (1 : 100 )' )
95+ heatmap (data; colormap= cgrad (:RdYlBu ; categorical= true ), interpolate= true )
96+
97+
98+ # Animations
99+ function n_times (f, n= 10 , interval= 0.05 )
100+ obs = Observable (f (1 ))
101+ @async for i in 2 : n
102+ try
103+ obs[] = f (i)
104+ sleep (interval)
105+ catch e
106+ @warn " Error!" exception= CapturedException (e, Base. catch_backtrace ())
107+ end
108+ end
109+ return obs
110+ end
111+
112+ annotations (n_times (i-> map (j-> (" $j " , Point2f0 (j* 30 , 0 )), 1 : i)), textsize= 20 , limits= FRect2D (30 , 0 , 320 , 50 ))
113+ scatter (n_times (i-> Point2f0 .((1 : i). * 30 , 0 )), limits= FRect2D (30 , 0 , 320 , 50 ), markersize= 20 px)
114+ linesegments (n_times (i-> Point2f0 .((2 : 2 : 2 i). * 30 , 0 )), limits= FRect2D (30 , 0 , 620 , 50 ), markersize= 20 px)
115+ lines (n_times (i-> Point2f0 .((2 : 2 : 2 i). * 30 , 0 )), limits= FRect2D (30 , 0 , 620 , 50 ), markersize= 20 px)
116+
117+
118+ # Set up sliders to control lighting attributes
119+ s1, ambient = textslider (0f0 : 0.01f0 : 1f0 , " ambient" , start = 0.55f0 )
120+ s2, diffuse = textslider (0f0 : 0.025f0 : 2f0 , " diffuse" , start = 0.4f0 )
121+ s3, specular = textslider (0f0 : 0.025f0 : 2f0 , " specular" , start = 0.2f0 )
122+ s4, shininess = textslider (2f0 .^ (2f0 : 8f0 ), " shininess" , start = 32f0 )
123+
124+ # Set up (r, θ, ϕ) for lightposition
125+ s5, radius = textslider (2f0 .^ (0.5f0 : 0.25f0 : 20f0 ), " light pos r" , start = 2f0 )
126+ s6, theta = textslider (0 : 5 : 180 , " light pos theta" , start = 30f0 )
127+ s7, phi = textslider (0 : 5 : 360 , " light pos phi" , start = 45f0 )
128+
129+ # transform signals into required types
130+ la = map (Vec3f0, ambient)
131+ ld = map (Vec3f0, diffuse)
132+ ls = map (Vec3f0, specular)
133+ lp = map (radius, theta, phi) do r, theta, phi
134+ r * Vec3f0 (
135+ cosd (phi) * sind (theta),
136+ sind (phi) * sind (theta),
137+ cosd (theta)
138+ )
139+ end
140+
141+ scene = Scene ()
142+ contour! (scene, 0 .. 1 , 0 .. 1 , 0 .. 1 , rand (10 , 10 , 10 ), levels = 2 ;
143+ ambient = la, diffuse = ld, specular = ls, shininess = shininess,
144+ lightposition = lp)
145+ scatter! (scene, map (v -> [v], lp), color= :yellow , markersize= 0.2f0 )
146+
147+ vbox (hbox (s4, s3, s2, s1, s7, s6, s5), scene) |> display
0 commit comments