Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
55
Task/Draw-a-cuboid/Ada/draw-a-cuboid.adb
Normal file
55
Task/Draw-a-cuboid/Ada/draw-a-cuboid.adb
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
with Ada.Text_IO;
|
||||
|
||||
procedure Main is
|
||||
type Char_Matrix is
|
||||
array (Positive range <>, Positive range <>) of Character;
|
||||
|
||||
function Create_Cuboid
|
||||
(Width, Height, Depth : Positive)
|
||||
return Char_Matrix
|
||||
is
|
||||
Result : Char_Matrix (1 .. Height + Depth + 3,
|
||||
1 .. 2 * Width + Depth + 3) := (others => (others => ' '));
|
||||
begin
|
||||
-- points
|
||||
Result (1, 1) := '+';
|
||||
Result (Height + 2, 1) := '+';
|
||||
Result (1, 2 * Width + 2) := '+';
|
||||
Result (Height + 2, 2 * Width + 2) := '+';
|
||||
Result (Height + Depth + 3, Depth + 2) := '+';
|
||||
Result (Depth + 2, 2 * Width + Depth + 3) := '+';
|
||||
Result (Height + Depth + 3, 2 * Width + Depth + 3) := '+';
|
||||
-- width lines
|
||||
for I in 1 .. 2 * Width loop
|
||||
Result (1, I + 1) := '-';
|
||||
Result (Height + 2, I + 1) := '-';
|
||||
Result (Height + Depth + 3, Depth + I + 2) := '-';
|
||||
end loop;
|
||||
-- height lines
|
||||
for I in 1 .. Height loop
|
||||
Result (I + 1, 1) := '|';
|
||||
Result (I + 1, 2 * Width + 2) := '|';
|
||||
Result (Depth + I + 2, 2 * Width + Depth + 3) := '|';
|
||||
end loop;
|
||||
-- depth lines
|
||||
for I in 1 .. Depth loop
|
||||
Result (Height + 2 + I, 1 + I) := '/';
|
||||
Result (1 + I, 2 * Width + 2 + I) := '/';
|
||||
Result (Height + 2 + I, 2 * Width + 2 + I) := '/';
|
||||
end loop;
|
||||
return Result;
|
||||
end Create_Cuboid;
|
||||
|
||||
procedure Print_Cuboid (Width, Height, Depth : Positive) is
|
||||
Cuboid : Char_Matrix := Create_Cuboid (Width, Height, Depth);
|
||||
begin
|
||||
for Row in reverse Cuboid'Range (1) loop
|
||||
for Col in Cuboid'Range (2) loop
|
||||
Ada.Text_IO.Put (Cuboid (Row, Col));
|
||||
end loop;
|
||||
Ada.Text_IO.New_Line;
|
||||
end loop;
|
||||
end Print_Cuboid;
|
||||
begin
|
||||
Print_Cuboid (2, 3, 4);
|
||||
end Main;
|
||||
35
Task/Draw-a-cuboid/Odin/draw-a-cuboid.odin
Normal file
35
Task/Draw-a-cuboid/Odin/draw-a-cuboid.odin
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package cuboid
|
||||
|
||||
import rl "vendor:raylib"
|
||||
|
||||
main :: proc() {
|
||||
rl.InitWindow(640, 480, "Rosetta Code - draw a cuboid")
|
||||
|
||||
camera: rl.Camera3D
|
||||
camera.fovy = 45
|
||||
camera.position = {0, 5, 10}
|
||||
camera.up = {0, 1, 0}
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.UpdateCamera(&camera, .ORBITAL)
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RAYWHITE)
|
||||
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
rl.DrawGrid(25, .5)
|
||||
|
||||
cube := rl.Vector3 {2, 3, 4}
|
||||
|
||||
rl.DrawCubeV({}, cube, rl.LIME)
|
||||
rl.DrawCubeWiresV({}, cube, rl.DARKGREEN)
|
||||
|
||||
rl.EndMode3D()
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
||||
32
Task/Draw-a-cuboid/V-(Vlang)/draw-a-cuboid.v
Normal file
32
Task/Draw-a-cuboid/V-(Vlang)/draw-a-cuboid.v
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
fn cuboid(dx int, dy int, dz int) {
|
||||
println("cuboid $dx $dy $dz:")
|
||||
cub_line(dy + 1, dx, 0, "+-|")
|
||||
for i in 1 .. dy + 1 {
|
||||
cub_line(dy - i + 1, dx, i - 1, "/ |")
|
||||
}
|
||||
cub_line(0, dx, dy, "+-|")
|
||||
for _ in 0 .. (4 * dz - dy - 2) {
|
||||
cub_line(0, dx, dy, "| |")
|
||||
}
|
||||
cub_line(0, dx, dy, "| +")
|
||||
for i in 1 .. dy + 1 {
|
||||
cub_line(0, dx, dy - i, "| /")
|
||||
}
|
||||
last_line := "+-"
|
||||
print("".repeat(1) + last_line[0].ascii_str())
|
||||
println(last_line[1].ascii_str().repeat(9 * dx - 1) + last_line[0].ascii_str())
|
||||
}
|
||||
|
||||
fn cub_line(nir int, dx int, dy int, cde string) {
|
||||
if cde.len < 3 { return }
|
||||
print(" ".repeat(nir + 1) + cde[0].ascii_str())
|
||||
print(cde[1].ascii_str().repeat(9 * dx - 1))
|
||||
print(cde[0].ascii_str())
|
||||
println(" ".repeat(dy + 1) + cde[2].ascii_str())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
cuboid(2, 3, 4)
|
||||
cuboid(1, 1, 1)
|
||||
cuboid(6, 2, 1)
|
||||
}
|
||||
48
Task/Draw-a-cuboid/VBScript/draw-a-cuboid.vbs
Normal file
48
Task/Draw-a-cuboid/VBScript/draw-a-cuboid.vbs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
x = 6 : y = 2 : z = 3
|
||||
|
||||
Sub cuboid(nx, ny, nz)
|
||||
WScript.StdOut.WriteLine "Cuboid " & nx & " " & ny & " " & nz & ":"
|
||||
lx = X * nx : ly = y * ny : lz = z * nz
|
||||
|
||||
'define the array
|
||||
Dim area(): ReDim area(ly+lz, lx+ly)
|
||||
For i = 0 to ly+lz
|
||||
For j = 0 to lx+ly : area(i,j) = " " : Next
|
||||
Next
|
||||
|
||||
'drawing lines
|
||||
For i = 0 to nz-1 : drawLine area, lx, 0, Z*i, "-" : Next
|
||||
For i = 0 to ny : drawLine area, lx, y*i, lz+y*i, "-" : Next
|
||||
For i = 0 to nx-1 : drawLine area, lz, x*i, 0, "|" : Next
|
||||
For i = 0 to ny : drawLine area, lz, lx+y*i, y*i, "|" : Next
|
||||
For i = 0 to nz-1 : drawLine area, ly, lx, z*i, "/" : Next
|
||||
For i = 0 to nx : drawLine area, ly, x*i, lz, "/" : Next
|
||||
|
||||
'output the cuboid (in reverse)
|
||||
For i = UBound(area,1) to 0 Step -1
|
||||
linOut = ""
|
||||
For j = 0 to UBound(area,2) : linOut = linOut & area(i,j) : Next
|
||||
WScript.StdOut.WriteLine linOut
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Sub drawLine(arr, n, sx, sy, c)
|
||||
Select Case c
|
||||
Case "-"
|
||||
dx = 1 : dy = 0
|
||||
Case "|"
|
||||
dx = 0 : dy = 1
|
||||
Case "/"
|
||||
dx = 1 : dy = 1
|
||||
End Select
|
||||
For i = 0 to n
|
||||
xi = sx + (i * dx) : yi = sy + (i * dy)
|
||||
If arr(yi, xi) = " " Then
|
||||
arr(yi, xi) = c
|
||||
Else
|
||||
arr(yi, xi) = "+"
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
cuboid 2,3,4
|
||||
Loading…
Add table
Add a link
Reference in a new issue