Draw a sphere: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(8 intermediate revisions by 4 users not shown)
Line 1,995:
 
=={{header|Craft Basic}}==
<syntaxhighlight lang="basic">define k = 0, i = 21,let j = 2
 
for i = 21221 to 0 step j * -1
 
for k = -3.14 to 3.14 step .0701
 
dot 21221 + i * sin( sin: k ), 22222 + 21221 * cos( cos: k )
dot 21221 + 21221 * sin( sin: k ), 22222 + ( i - 1 ) * cos( cos: k )
 
wait
Line 2,010:
let j = j + 1
 
next i</syntaxhighlight>
 
end</syntaxhighlight>
 
=={{header|D}}==
Line 2,440 ⟶ 2,438:
</pre>
 
=={{header|Evaldraw}}==
 
Draw a sphere. We dont need to wrap the main () function with braces if we have no functions.
 
[[File:Evaldraw draw sphere.png|thumb|alt=A red sphere on a black background.|A red sphere, 5 units in front of camera.]]
 
<syntaxhighlight lang="C">
()
cls(0);
clz(1e32);
setcam(0,0,-5,0,0);
setcol(128,64,64);
drawsph(0,0,0,1);
end</syntaxhighlight>
 
=={{header|Factor}}==
Line 5,796 ⟶ 5,809:
eeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeee</pre>
 
=={{header|V (Vlang)}}==
Graphical
<syntaxhighlight lang="Zig">
import gg
import gx
 
const (
win_width = 600
win_height = 600
)
 
struct App {
mut:
gg &gg.Context = unsafe {nil}
}
 
fn main() {
mut app := &App{
gg: 0
}
app.gg = gg.new_context(
bg_color: gx.white
width: win_width
height: win_height
create_window: true
window_title: 'Circle'
frame_fn: frame
user_data: app
)
app.gg.run()
}
 
fn frame(app &App) {
app.gg.begin()
app.draw()
app.gg.end()
}
 
fn (app &App) draw() {
app.gg.draw_circle_filled(300, 300, 150, gx.red)
}
</syntaxhighlight>
 
=={{header|Wren}}==
{{trans|C}}
<syntaxhighlight lang="ecmascriptwren">var shades = ".:!*oe&#\%@"
var light = [30, 30, -50]
 
Line 5,939 ⟶ 5,995:
next n
end sub</syntaxhighlight>
 
=={{header|Zig}}==
{{trans|Factor}}
{{libheader|raylib}}
<syntaxhighlight lang="zig">
const std = @import("std");
const c = @cImport({
@cInclude("raylib.h");
});
 
pub fn main() !void {
c.SetConfigFlags(c.FLAG_WINDOW_RESIZABLE | c.FLAG_VSYNC_HINT);
c.InitWindow(600, 480, "Draw a Sphere");
defer c.CloseWindow();
 
const camera = c.Camera3D{
.position = .{ .x = 4.5, .y = 4.5, .z = 4.5 },
.target = .{ .x = 0, .y = 0, .z = 0 },
.up = .{ .x = 0, .y = 1, .z = 0 },
.fovy = 45.0,
.projection = c.CAMERA_PERSPECTIVE,
};
 
c.SetTargetFPS(60);
 
while (!c.WindowShouldClose()) {
c.BeginDrawing();
defer c.EndDrawing();
 
c.ClearBackground(c.BLACK);
 
{
c.BeginMode3D(camera);
defer c.EndMode3D();
 
c.DrawSphereWires(.{ .x = 0, .y = 0, .z = 0 }, 2, 20, 20, c.LIME);
}
}
}
</syntaxhighlight>
 
=={{header|zkl}}==
9,476

edits