Draw shapes through Camera2D
ASPL 0.7.0 · Current release
Native only. Up to 20 frames show a rotated rectangle, circle, thick line and triangle in camera coordinates. A pixel and border use screen coordinates after EndMode2D. Success prints camera shapes complete without a trailing newline and returns 0.
On this page
Prepare the native host
Native only, published ASPL 0.7.0. Up to 20 frames show a rotated rectangle, circle, thick line and triangle in camera coordinates. A pixel and border use screen coordinates after EndMode2D. Success prints camera shapes complete without a trailing newline and returns 0.
Native installation · Drawing and input guide · API reference.
No source modules or data assets are required.
The page language is independent of source vocabulary. Download only supplied variants, with original filenames. Mixed-only programs are labelled in both locales; no source translation is generated.
Mixed source
Execution: Native only · ASPL 0.7.0
- Native ASPL 0.7.0 on x86_64 Linux with glibc 2.34 or later.
- Running needs a reachable Wayland/EGL or X11/GLX display and OpenGL 3.3 core; no system Raylib or C compiler is required. Checking and building need no display.
Input: No input lines are required.
No English source variant is supplied. Showing Mixed source as written; the source was not translated.
import core::raylib;
استورد أساسي::رايليب.
fn start_main() -> i64 {
if not raylib::InitWindow(640, 360, "ASPL Camera2D shapes")::ok { return 1; }
let camera = رايليب::كاميرا2 {
إزاحة: raylib::Vector2 { x: 320.0, y: 180.0 },
هدف: raylib::Vector2 { x: 0.0, y: 0.0 }, دوران: 15.0, تكبير: 1.5
};
if not raylib::SetTargetFPS(60)::ok { return 2; }
var frame: i32 = 0;
while frame < 20 and not raylib::WindowShouldClose()::value {
if not raylib::BeginDrawing()::ok { return 3; }
if not رايليب::امسح_الخلفية(raylib::RAYWHITE)::ok { return 4; }
if not raylib::BeginMode2D(camera)::ok { return 5; }
if not raylib::DrawRectanglePro(raylib::Rectangle { x: -100.0, y: -50.0, width: 80.0, height: 60.0 },
raylib::Vector2 { x: 40.0, y: 30.0 }, 20.0, raylib::BLUE)::ok { return 6; }
if not raylib::DrawCircleV(raylib::Vector2 { x: 50.0, y: 0.0 }, 35.0, raylib::RED)::ok { return 7; }
if not raylib::DrawLineEx(raylib::Vector2 { x: -150.0, y: 70.0 }, raylib::Vector2 { x: 150.0, y: 70.0 }, 4.0, raylib::DARKGRAY)::ok { return 8; }
if not raylib::DrawTriangle(raylib::Vector2 { x: 100.0, y: -60.0 }, raylib::Vector2 { x: 100.0, y: 0.0 },
raylib::Vector2 { x: 150.0, y: 0.0 }, raylib::GREEN)::ok { return 9; }
if not raylib::EndMode2D()::ok { return 10; }
if not raylib::DrawPixel(10, 10, raylib::BLACK)::ok { return 11; }
if not raylib::DrawRectangleLines(5, 5, 630, 350, raylib::GRAY)::ok { return 12; }
if not raylib::EndDrawing()::ok { return 13; }
frame = frame + 1;
}
if not raylib::CloseWindow()::ok { return 14; }
print("camera shapes complete");
return 0;
}
Follow the Linux instructions to run this example. Download the source to keep a copy.
Download raylib-shapes.mixed.asplExpected outcomes
{
"native": {
"check": 0,
"status": 0,
"output": "camera shapes complete",
"behavior": {
"en": "Up to 20 frames show a rotated rectangle, circle, thick line and triangle in camera coordinates. A pixel and border use screen coordinates after EndMode2D. Success prints camera shapes complete without a trailing newline and returns 0.",
"ar": "يعرض البرنامج حتى 20 إطارا فيها مستطيل مدور ودائرة وخط سميك ومثلث بإحداثيات الكاميرا. تستخدم نقطة وإطار حدود إحداثيات الشاشة بعد EndMode2D. يطبع النجاح camera shapes complete دون سطر جديد ويعيد 0."
}
}
}Commands and outcomes
Run from the directory containing the downloaded docs/ tree. Keep the generated .THIRD-PARTY-NOTICES companion when distributing the ELF program. Checking and building do not open a window. Running needs the stated graphics facilities.
mixed:
aspl check docs/examples/raylib-shapes.mixed.aspl
aspl run docs/examples/raylib-shapes.mixed.aspl
aspl build -o raylib-shapes-mixed-program docs/examples/raylib-shapes.mixed.aspl
./raylib-shapes-mixed-program