Jump to content

WebGL rotating F: Difference between revisions

julia example
(julia example)
Line 11:
;Optional extra
Allow toggling between the F shape and a classic Utah teapot.
 
 
=={{header|Julia}}==
Makie can use OpenGL as a backend for plotting (GLMakie). The code plots an 'F' as three rectangular solid-shaped scatter plots with overlapping markers, then rotates the resulting graph.
<lang julia>using Colors
using GeometryBasics: Rect3f
using GLMakie
 
topbar = vec([Point3f(i / 5, j / 5, k / 5) for i in 1:7, j in 8:3:28, k in 45:50])
stem = vec([Point3f(i / 5, j / 5, k / 5) for i in 1:7, j in 1:7, k in 1:8:56])
midbar = vec([Point3f(i / 5, j / 5, k / 5) for i in 1:7, j in 8:2:21, k in 25:29])
fig = Figure(resolution = (800, 400))
pos = fig[1, 1]
meshscatter(pos, topbar; marker = Rect3f(Vec3f(-0.5), Vec3f(16)), transparency = true,
color = [RGBA(positions[i]..., 0.5) for i in 1:length(positions)])
meshscatter!(pos, stem; marker = Rect3f(Vec3f(-0.5), Vec3f(16)), transparency = true,
color = [RGBA(positions2[i]..., 0.5) for i in 1:length(positions2)])
meshscatter!(pos, midbar; marker = Rect3f(Vec3f(-0.5), Vec3f(16)), transparency = true,
color = [RGBA(positions3[i]..., 0.5) for i in 1:length(positions3)])
for _ in 1:28
display(fig.scene)
rotate!(Accum, fig.scene, 0.25)
sleep(0.25)
end
</lang>
 
 
=={{header|Phix}}==
4,105

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.