pub struct DrawHandle<'a> {
pub draw: RaylibDrawHandle<'a>,
}Expand description
Handle de dibujo (Raylib = Pincel)
Se obtiene de RyditGfx::begin_draw() y se usa para dibujar.
Al salir de scope, automáticamente finaliza el dibujo.
Fields§
§draw: RaylibDrawHandle<'a>Implementations§
Source§impl<'a> DrawHandle<'a>
impl<'a> DrawHandle<'a>
Sourcepub fn clear(&mut self, color: ColorRydit)
pub fn clear(&mut self, color: ColorRydit)
Limpiar con color
Examples found in repository?
examples/demo.rs (line 29)
6fn main() {
7 println!("=== RYDIT-GFX v0.1.0 ===");
8 println!("Rust = Arquitecto, Raylib = Pincel\n");
9
10 // Crear ventana (Rust controla)
11 let mut gfx = RyditGfx::new("RyDit v0.0.7 - rydit-gfx", 800, 600);
12 gfx.set_target_fps(60);
13
14 println!("[RUST] Ventana creada, iniciando game loop...\n");
15
16 // Game loop controlado por Rust
17 let mut frame = 0;
18 while !gfx.should_close() {
19 frame += 1;
20
21 // Rust decide input PRIMERO (antes de dibujar)
22 let escape_pressed = gfx.is_key_pressed(Key::Escape);
23
24 // Iniciar dibujo (toma &mut self, no podemos usar gfx después)
25 {
26 let mut d = gfx.begin_draw();
27
28 // Limpiar pantalla
29 d.clear(ColorRydit::Negro);
30
31 // Dibujar círculo rojo en el centro (animado)
32 let radius = 50 + (frame % 20);
33 d.draw_circle(400, 300, radius, ColorRydit::Rojo);
34
35 // Dibujar rectángulo verde
36 d.draw_rectangle(100, 100, 100, 100, ColorRydit::Verde);
37
38 // Dibujar línea azul
39 d.draw_line(0, 0, 800, 600, ColorRydit::Azul);
40
41 // Dibujar texto
42 d.draw_text(
43 "RyDit v0.0.7 - rydit-gfx",
44 250,
45 50,
46 20,
47 ColorRydit::Amarillo,
48 );
49 d.draw_text(
50 "Rust = Arquitecto, Raylib = Pincel",
51 220,
52 80,
53 16,
54 ColorRydit::Blanco,
55 );
56 d.draw_text("Presiona ESC para salir", 280, 550, 16, ColorRydit::Blanco);
57
58 // d se va de scope aquí, finaliza dibujo
59 }
60
61 // Rust decide después de dibujar
62 if escape_pressed {
63 println!("\n[RUST] Decidiendo cerrar en frame {}...", frame);
64 break;
65 }
66 }
67
68 println!("\n[RUST] Juego terminado. ¡Éxito!");
69}Sourcepub fn draw_circle(&mut self, x: i32, y: i32, radius: i32, color: ColorRydit)
pub fn draw_circle(&mut self, x: i32, y: i32, radius: i32, color: ColorRydit)
Dibujar círculo
Examples found in repository?
examples/demo.rs (line 33)
6fn main() {
7 println!("=== RYDIT-GFX v0.1.0 ===");
8 println!("Rust = Arquitecto, Raylib = Pincel\n");
9
10 // Crear ventana (Rust controla)
11 let mut gfx = RyditGfx::new("RyDit v0.0.7 - rydit-gfx", 800, 600);
12 gfx.set_target_fps(60);
13
14 println!("[RUST] Ventana creada, iniciando game loop...\n");
15
16 // Game loop controlado por Rust
17 let mut frame = 0;
18 while !gfx.should_close() {
19 frame += 1;
20
21 // Rust decide input PRIMERO (antes de dibujar)
22 let escape_pressed = gfx.is_key_pressed(Key::Escape);
23
24 // Iniciar dibujo (toma &mut self, no podemos usar gfx después)
25 {
26 let mut d = gfx.begin_draw();
27
28 // Limpiar pantalla
29 d.clear(ColorRydit::Negro);
30
31 // Dibujar círculo rojo en el centro (animado)
32 let radius = 50 + (frame % 20);
33 d.draw_circle(400, 300, radius, ColorRydit::Rojo);
34
35 // Dibujar rectángulo verde
36 d.draw_rectangle(100, 100, 100, 100, ColorRydit::Verde);
37
38 // Dibujar línea azul
39 d.draw_line(0, 0, 800, 600, ColorRydit::Azul);
40
41 // Dibujar texto
42 d.draw_text(
43 "RyDit v0.0.7 - rydit-gfx",
44 250,
45 50,
46 20,
47 ColorRydit::Amarillo,
48 );
49 d.draw_text(
50 "Rust = Arquitecto, Raylib = Pincel",
51 220,
52 80,
53 16,
54 ColorRydit::Blanco,
55 );
56 d.draw_text("Presiona ESC para salir", 280, 550, 16, ColorRydit::Blanco);
57
58 // d se va de scope aquí, finaliza dibujo
59 }
60
61 // Rust decide después de dibujar
62 if escape_pressed {
63 println!("\n[RUST] Decidiendo cerrar en frame {}...", frame);
64 break;
65 }
66 }
67
68 println!("\n[RUST] Juego terminado. ¡Éxito!");
69}Sourcepub fn draw_rectangle(
&mut self,
x: i32,
y: i32,
w: i32,
h: i32,
color: ColorRydit,
)
pub fn draw_rectangle( &mut self, x: i32, y: i32, w: i32, h: i32, color: ColorRydit, )
Dibujar rectángulo
Examples found in repository?
examples/demo.rs (line 36)
6fn main() {
7 println!("=== RYDIT-GFX v0.1.0 ===");
8 println!("Rust = Arquitecto, Raylib = Pincel\n");
9
10 // Crear ventana (Rust controla)
11 let mut gfx = RyditGfx::new("RyDit v0.0.7 - rydit-gfx", 800, 600);
12 gfx.set_target_fps(60);
13
14 println!("[RUST] Ventana creada, iniciando game loop...\n");
15
16 // Game loop controlado por Rust
17 let mut frame = 0;
18 while !gfx.should_close() {
19 frame += 1;
20
21 // Rust decide input PRIMERO (antes de dibujar)
22 let escape_pressed = gfx.is_key_pressed(Key::Escape);
23
24 // Iniciar dibujo (toma &mut self, no podemos usar gfx después)
25 {
26 let mut d = gfx.begin_draw();
27
28 // Limpiar pantalla
29 d.clear(ColorRydit::Negro);
30
31 // Dibujar círculo rojo en el centro (animado)
32 let radius = 50 + (frame % 20);
33 d.draw_circle(400, 300, radius, ColorRydit::Rojo);
34
35 // Dibujar rectángulo verde
36 d.draw_rectangle(100, 100, 100, 100, ColorRydit::Verde);
37
38 // Dibujar línea azul
39 d.draw_line(0, 0, 800, 600, ColorRydit::Azul);
40
41 // Dibujar texto
42 d.draw_text(
43 "RyDit v0.0.7 - rydit-gfx",
44 250,
45 50,
46 20,
47 ColorRydit::Amarillo,
48 );
49 d.draw_text(
50 "Rust = Arquitecto, Raylib = Pincel",
51 220,
52 80,
53 16,
54 ColorRydit::Blanco,
55 );
56 d.draw_text("Presiona ESC para salir", 280, 550, 16, ColorRydit::Blanco);
57
58 // d se va de scope aquí, finaliza dibujo
59 }
60
61 // Rust decide después de dibujar
62 if escape_pressed {
63 println!("\n[RUST] Decidiendo cerrar en frame {}...", frame);
64 break;
65 }
66 }
67
68 println!("\n[RUST] Juego terminado. ¡Éxito!");
69}Sourcepub fn draw_line(
&mut self,
x1: i32,
y1: i32,
x2: i32,
y2: i32,
color: ColorRydit,
)
pub fn draw_line( &mut self, x1: i32, y1: i32, x2: i32, y2: i32, color: ColorRydit, )
Dibujar línea
Examples found in repository?
examples/demo.rs (line 39)
6fn main() {
7 println!("=== RYDIT-GFX v0.1.0 ===");
8 println!("Rust = Arquitecto, Raylib = Pincel\n");
9
10 // Crear ventana (Rust controla)
11 let mut gfx = RyditGfx::new("RyDit v0.0.7 - rydit-gfx", 800, 600);
12 gfx.set_target_fps(60);
13
14 println!("[RUST] Ventana creada, iniciando game loop...\n");
15
16 // Game loop controlado por Rust
17 let mut frame = 0;
18 while !gfx.should_close() {
19 frame += 1;
20
21 // Rust decide input PRIMERO (antes de dibujar)
22 let escape_pressed = gfx.is_key_pressed(Key::Escape);
23
24 // Iniciar dibujo (toma &mut self, no podemos usar gfx después)
25 {
26 let mut d = gfx.begin_draw();
27
28 // Limpiar pantalla
29 d.clear(ColorRydit::Negro);
30
31 // Dibujar círculo rojo en el centro (animado)
32 let radius = 50 + (frame % 20);
33 d.draw_circle(400, 300, radius, ColorRydit::Rojo);
34
35 // Dibujar rectángulo verde
36 d.draw_rectangle(100, 100, 100, 100, ColorRydit::Verde);
37
38 // Dibujar línea azul
39 d.draw_line(0, 0, 800, 600, ColorRydit::Azul);
40
41 // Dibujar texto
42 d.draw_text(
43 "RyDit v0.0.7 - rydit-gfx",
44 250,
45 50,
46 20,
47 ColorRydit::Amarillo,
48 );
49 d.draw_text(
50 "Rust = Arquitecto, Raylib = Pincel",
51 220,
52 80,
53 16,
54 ColorRydit::Blanco,
55 );
56 d.draw_text("Presiona ESC para salir", 280, 550, 16, ColorRydit::Blanco);
57
58 // d se va de scope aquí, finaliza dibujo
59 }
60
61 // Rust decide después de dibujar
62 if escape_pressed {
63 println!("\n[RUST] Decidiendo cerrar en frame {}...", frame);
64 break;
65 }
66 }
67
68 println!("\n[RUST] Juego terminado. ¡Éxito!");
69}Sourcepub fn draw_text(
&mut self,
text: &str,
x: i32,
y: i32,
size: i32,
color: ColorRydit,
)
pub fn draw_text( &mut self, text: &str, x: i32, y: i32, size: i32, color: ColorRydit, )
Dibujar texto
Examples found in repository?
examples/demo.rs (lines 42-48)
6fn main() {
7 println!("=== RYDIT-GFX v0.1.0 ===");
8 println!("Rust = Arquitecto, Raylib = Pincel\n");
9
10 // Crear ventana (Rust controla)
11 let mut gfx = RyditGfx::new("RyDit v0.0.7 - rydit-gfx", 800, 600);
12 gfx.set_target_fps(60);
13
14 println!("[RUST] Ventana creada, iniciando game loop...\n");
15
16 // Game loop controlado por Rust
17 let mut frame = 0;
18 while !gfx.should_close() {
19 frame += 1;
20
21 // Rust decide input PRIMERO (antes de dibujar)
22 let escape_pressed = gfx.is_key_pressed(Key::Escape);
23
24 // Iniciar dibujo (toma &mut self, no podemos usar gfx después)
25 {
26 let mut d = gfx.begin_draw();
27
28 // Limpiar pantalla
29 d.clear(ColorRydit::Negro);
30
31 // Dibujar círculo rojo en el centro (animado)
32 let radius = 50 + (frame % 20);
33 d.draw_circle(400, 300, radius, ColorRydit::Rojo);
34
35 // Dibujar rectángulo verde
36 d.draw_rectangle(100, 100, 100, 100, ColorRydit::Verde);
37
38 // Dibujar línea azul
39 d.draw_line(0, 0, 800, 600, ColorRydit::Azul);
40
41 // Dibujar texto
42 d.draw_text(
43 "RyDit v0.0.7 - rydit-gfx",
44 250,
45 50,
46 20,
47 ColorRydit::Amarillo,
48 );
49 d.draw_text(
50 "Rust = Arquitecto, Raylib = Pincel",
51 220,
52 80,
53 16,
54 ColorRydit::Blanco,
55 );
56 d.draw_text("Presiona ESC para salir", 280, 550, 16, ColorRydit::Blanco);
57
58 // d se va de scope aquí, finaliza dibujo
59 }
60
61 // Rust decide después de dibujar
62 if escape_pressed {
63 println!("\n[RUST] Decidiendo cerrar en frame {}...", frame);
64 break;
65 }
66 }
67
68 println!("\n[RUST] Juego terminado. ¡Éxito!");
69}Sourcepub fn draw_triangle(
&mut self,
v1: (i32, i32),
v2: (i32, i32),
v3: (i32, i32),
color: ColorRydit,
)
pub fn draw_triangle( &mut self, v1: (i32, i32), v2: (i32, i32), v3: (i32, i32), color: ColorRydit, )
Dibujar triángulo
Sourcepub fn draw_triangle_lines(
&mut self,
v1: (i32, i32),
v2: (i32, i32),
v3: (i32, i32),
color: ColorRydit,
)
pub fn draw_triangle_lines( &mut self, v1: (i32, i32), v2: (i32, i32), v3: (i32, i32), color: ColorRydit, )
Dibujar triángulo con líneas (outline)
Sourcepub fn draw_rectangle_lines(
&mut self,
x: i32,
y: i32,
w: i32,
h: i32,
color: ColorRydit,
)
pub fn draw_rectangle_lines( &mut self, x: i32, y: i32, w: i32, h: i32, color: ColorRydit, )
Dibujar rectángulo con líneas (outline)
Sourcepub fn draw_ring(
&mut self,
center: (i32, i32),
_inner_radius: i32,
outer_radius: i32,
color: ColorRydit,
)
pub fn draw_ring( &mut self, center: (i32, i32), _inner_radius: i32, outer_radius: i32, color: ColorRydit, )
Dibujar anillo (ring)
Sourcepub fn draw_ellipse(
&mut self,
center: (i32, i32),
radius_h: i32,
radius_v: i32,
color: ColorRydit,
)
pub fn draw_ellipse( &mut self, center: (i32, i32), radius_h: i32, radius_v: i32, color: ColorRydit, )
Dibujar elipse
Sourcepub fn draw_line_thick(
&mut self,
start_pos: (i32, i32),
end_pos: (i32, i32),
thick: f32,
color: ColorRydit,
)
pub fn draw_line_thick( &mut self, start_pos: (i32, i32), end_pos: (i32, i32), thick: f32, color: ColorRydit, )
Dibujar línea gruesa
Sourcepub fn draw_rectangle_pro(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32,
angle: f32,
color: ColorRydit,
)
pub fn draw_rectangle_pro( &mut self, x: i32, y: i32, width: i32, height: i32, angle: f32, color: ColorRydit, )
Dibujar rectángulo rotado
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for DrawHandle<'a>
impl<'a> RefUnwindSafe for DrawHandle<'a>
impl<'a> Send for DrawHandle<'a>
impl<'a> Sync for DrawHandle<'a>
impl<'a> Unpin for DrawHandle<'a>
impl<'a> UnsafeUnpin for DrawHandle<'a>
impl<'a> !UnwindSafe for DrawHandle<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more