Skip to content

Commit c554550

Browse files
Replace Color in example code with RColor
1 parent ed1b670 commit c554550

9 files changed

+39
-39
lines changed

examples/cursor.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use sdl2::event::Event;
44
use sdl2::image::{InitFlag, LoadSurface};
55
use sdl2::keyboard::Keycode;
66
use sdl2::mouse::Cursor;
7-
use sdl2::pixels::Color;
7+
use sdl2::pixels::RColor;
88
use sdl2::rect::Rect;
99
use sdl2::surface::Surface;
1010
use std::env;
@@ -35,7 +35,7 @@ pub fn run(png: &Path) -> Result<(), String> {
3535
canvas.clear();
3636
canvas.present();
3737

38-
canvas.set_draw_color(Color::RGBA(255, 255, 255, 255));
38+
canvas.set_draw_color(RColor::RGBA(255, 255, 255, 255));
3939

4040
let mut events = sdl_context.event_pump()?;
4141

examples/demo.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ extern crate sdl2;
22

33
use sdl2::event::Event;
44
use sdl2::keyboard::Keycode;
5-
use sdl2::pixels::Color;
5+
use sdl2::pixels::RColor;
66
use std::time::Duration;
77

88
pub fn main() -> Result<(), String> {
@@ -18,7 +18,7 @@ pub fn main() -> Result<(), String> {
1818

1919
let mut canvas = window.into_canvas().build().map_err(|e| e.to_string())?;
2020

21-
canvas.set_draw_color(Color::RGB(255, 0, 0));
21+
canvas.set_draw_color(RColor::RGB(255, 0, 0));
2222
canvas.clear();
2323
canvas.present();
2424
let mut event_pump = sdl_context.event_pump()?;

examples/events.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ extern crate sdl2;
22

33
use sdl2::event::Event;
44
use sdl2::keyboard::Keycode;
5-
use sdl2::pixels::Color;
5+
use sdl2::pixels::RColor;
66
use std::time::Duration;
77

88
pub fn main() -> Result<(), String> {
@@ -18,7 +18,7 @@ pub fn main() -> Result<(), String> {
1818

1919
let mut canvas = window.into_canvas().build().map_err(|e| e.to_string())?;
2020

21-
canvas.set_draw_color(Color::RGB(255, 0, 0));
21+
canvas.set_draw_color(RColor::RGB(255, 0, 0));
2222
canvas.clear();
2323
canvas.present();
2424
let mut event_pump = sdl_context.event_pump()?;

examples/game-of-life-unsafe-textures.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use sdl2::keyboard::Keycode;
99
#[cfg(feature = "unsafe_textures")]
1010
use sdl2::mouse::MouseButton;
1111
#[cfg(feature = "unsafe_textures")]
12-
use sdl2::pixels::Color;
12+
use sdl2::pixels::RColor;
1313
#[cfg(feature = "unsafe_textures")]
1414
use sdl2::rect::{Point, Rect};
1515
#[cfg(feature = "unsafe_textures")]
@@ -140,20 +140,20 @@ fn dummy_texture<'a>(canvas: &mut Canvas<Window>) -> Result<(Texture, Texture),
140140
];
141141
canvas
142142
.with_multiple_texture_canvas(textures.iter(), |texture_canvas, user_context| {
143-
texture_canvas.set_draw_color(Color::RGB(0, 0, 0));
143+
texture_canvas.set_draw_color(RColor::RGB(0, 0, 0));
144144
texture_canvas.clear();
145145
match *user_context {
146146
TextureColor::Yellow => {
147147
for i in 0..SQUARE_SIZE {
148148
for j in 0..SQUARE_SIZE {
149149
if (i + j) % 4 == 0 {
150-
texture_canvas.set_draw_color(Color::RGB(255, 255, 0));
150+
texture_canvas.set_draw_color(RColor::RGB(255, 255, 0));
151151
texture_canvas
152152
.draw_point(Point::new(i as i32, j as i32))
153153
.expect("could not draw point");
154154
}
155155
if (i + j * 2) % 9 == 0 {
156-
texture_canvas.set_draw_color(Color::RGB(200, 200, 0));
156+
texture_canvas.set_draw_color(RColor::RGB(200, 200, 0));
157157
texture_canvas
158158
.draw_point(Point::new(i as i32, j as i32))
159159
.expect("could not draw point");
@@ -169,13 +169,13 @@ fn dummy_texture<'a>(canvas: &mut Canvas<Window>) -> Result<(Texture, Texture),
169169
if (i + j) % 7 == 0 {
170170
// this doesn't mean anything, there was some trial and error to find
171171
// something that wasn't too ugly
172-
texture_canvas.set_draw_color(Color::RGB(192, 192, 192));
172+
texture_canvas.set_draw_color(RColor::RGB(192, 192, 192));
173173
texture_canvas
174174
.draw_point(Point::new(i as i32, j as i32))
175175
.expect("could not draw point");
176176
}
177177
if (i + j * 2) % 5 == 0 {
178-
texture_canvas.set_draw_color(Color::RGB(64, 64, 64));
178+
texture_canvas.set_draw_color(RColor::RGB(64, 64, 64));
179179
texture_canvas
180180
.draw_point(Point::new(i as i32, j as i32))
181181
.expect("could not draw point");
@@ -191,13 +191,13 @@ fn dummy_texture<'a>(canvas: &mut Canvas<Window>) -> Result<(Texture, Texture),
191191
if (i + j) % 7 == 0 {
192192
// this doesn't mean anything, there was some trial and serror to find
193193
// something that wasn't too ugly
194-
texture_canvas.set_draw_color(Color::RGB(192, 192, 192));
194+
texture_canvas.set_draw_color(RColor::RGB(192, 192, 192));
195195
texture_canvas
196196
.draw_point(Point::new(i as i32, j as i32))
197197
.expect("could not draw point");
198198
}
199199
if (i + j * 2) % 5 == 0 {
200-
texture_canvas.set_draw_color(Color::RGB(64, 64, 64));
200+
texture_canvas.set_draw_color(RColor::RGB(64, 64, 64));
201201
texture_canvas
202202
.draw_point(Point::new(i as i32, j as i32))
203203
.expect("could not draw point");
@@ -239,7 +239,7 @@ pub fn main() -> Result<(), String> {
239239
.map_err(|e| e.to_string())?;
240240

241241
println!("Using SDL_Renderer \"{}\"", canvas.info().name);
242-
canvas.set_draw_color(Color::RGB(0, 0, 0));
242+
canvas.set_draw_color(RColor::RGB(0, 0, 0));
243243
// clears the canvas with the color we set in `set_draw_color`.
244244
canvas.clear();
245245
// However the canvas has not been updated to the window yet, everything has been processed to
@@ -294,7 +294,7 @@ pub fn main() -> Result<(), String> {
294294
frame = 0;
295295
}
296296

297-
canvas.set_draw_color(Color::RGB(0, 0, 0));
297+
canvas.set_draw_color(RColor::RGB(0, 0, 0));
298298
canvas.clear();
299299
for (i, unit) in (&game).into_iter().enumerate() {
300300
let i = i as u32;

examples/game-of-life.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::game_of_life::{PLAYGROUND_HEIGHT, PLAYGROUND_WIDTH, SQUARE_SIZE};
44
use sdl2::event::Event;
55
use sdl2::keyboard::Keycode;
66
use sdl2::mouse::MouseButton;
7-
use sdl2::pixels::Color;
7+
use sdl2::pixels::RColor;
88
use sdl2::rect::{Point, Rect};
99
use sdl2::render::{Canvas, Texture, TextureCreator};
1010
use sdl2::video::{Window, WindowContext};
@@ -133,20 +133,20 @@ fn dummy_texture<'a>(
133133
];
134134
canvas
135135
.with_multiple_texture_canvas(textures.iter(), |texture_canvas, user_context| {
136-
texture_canvas.set_draw_color(Color::RGB(0, 0, 0));
136+
texture_canvas.set_draw_color(RColor::RGB(0, 0, 0));
137137
texture_canvas.clear();
138138
match *user_context {
139139
TextureColor::Yellow => {
140140
for i in 0..SQUARE_SIZE {
141141
for j in 0..SQUARE_SIZE {
142142
if (i + j) % 4 == 0 {
143-
texture_canvas.set_draw_color(Color::RGB(255, 255, 0));
143+
texture_canvas.set_draw_color(RColor::RGB(255, 255, 0));
144144
texture_canvas
145145
.draw_point(Point::new(i as i32, j as i32))
146146
.expect("could not draw point");
147147
}
148148
if (i + j * 2) % 9 == 0 {
149-
texture_canvas.set_draw_color(Color::RGB(200, 200, 0));
149+
texture_canvas.set_draw_color(RColor::RGB(200, 200, 0));
150150
texture_canvas
151151
.draw_point(Point::new(i as i32, j as i32))
152152
.expect("could not draw point");
@@ -162,13 +162,13 @@ fn dummy_texture<'a>(
162162
if (i + j) % 7 == 0 {
163163
// this doesn't mean anything, there was some trial and error to find
164164
// something that wasn't too ugly
165-
texture_canvas.set_draw_color(Color::RGB(192, 192, 192));
165+
texture_canvas.set_draw_color(RColor::RGB(192, 192, 192));
166166
texture_canvas
167167
.draw_point(Point::new(i as i32, j as i32))
168168
.expect("could not draw point");
169169
}
170170
if (i + j * 2) % 5 == 0 {
171-
texture_canvas.set_draw_color(Color::RGB(64, 64, 64));
171+
texture_canvas.set_draw_color(RColor::RGB(64, 64, 64));
172172
texture_canvas
173173
.draw_point(Point::new(i as i32, j as i32))
174174
.expect("could not draw point");
@@ -184,13 +184,13 @@ fn dummy_texture<'a>(
184184
if (i + j) % 7 == 0 {
185185
// this doesn't mean anything, there was some trial and serror to find
186186
// something that wasn't too ugly
187-
texture_canvas.set_draw_color(Color::RGB(192, 192, 192));
187+
texture_canvas.set_draw_color(RColor::RGB(192, 192, 192));
188188
texture_canvas
189189
.draw_point(Point::new(i as i32, j as i32))
190190
.expect("could not draw point");
191191
}
192192
if (i + j * 2) % 5 == 0 {
193-
texture_canvas.set_draw_color(Color::RGB(64, 64, 64));
193+
texture_canvas.set_draw_color(RColor::RGB(64, 64, 64));
194194
texture_canvas
195195
.draw_point(Point::new(i as i32, j as i32))
196196
.expect("could not draw point");
@@ -231,7 +231,7 @@ pub fn main() -> Result<(), String> {
231231
.map_err(|e| e.to_string())?;
232232

233233
println!("Using SDL_Renderer \"{}\"", canvas.info().name);
234-
canvas.set_draw_color(Color::RGB(0, 0, 0));
234+
canvas.set_draw_color(RColor::RGB(0, 0, 0));
235235
// clears the canvas with the color we set in `set_draw_color`.
236236
canvas.clear();
237237
// However the canvas has not been updated to the window yet, everything has been processed to
@@ -290,7 +290,7 @@ pub fn main() -> Result<(), String> {
290290
frame = 0;
291291
}
292292

293-
canvas.set_draw_color(Color::RGB(0, 0, 0));
293+
canvas.set_draw_color(RColor::RGB(0, 0, 0));
294294
canvas.clear();
295295
for (i, unit) in (&game).into_iter().enumerate() {
296296
let i = i as u32;

examples/message-box.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate sdl2;
33
use sdl2::event::Event;
44
use sdl2::keyboard::Keycode;
55
use sdl2::messagebox::*;
6-
use sdl2::pixels::Color;
6+
use sdl2::pixels::RColor;
77

88
pub fn main() -> Result<(), String> {
99
let sdl_context = sdl2::init()?;
@@ -18,7 +18,7 @@ pub fn main() -> Result<(), String> {
1818

1919
let mut canvas = window.into_canvas().build().map_err(|e| e.to_string())?;
2020

21-
canvas.set_draw_color(Color::RGB(255, 0, 0));
21+
canvas.set_draw_color(RColor::RGB(255, 0, 0));
2222
canvas.clear();
2323
canvas.present();
2424
let mut event_pump = sdl_context.event_pump()?;

examples/no-renderer.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ extern crate sdl2;
22

33
use sdl2::event::Event;
44
use sdl2::keyboard::Keycode;
5-
use sdl2::pixels::Color;
5+
use sdl2::pixels::RColor;
66
use sdl2::rect::Rect;
77
use sdl2::video::Window;
88
use std::time::Duration;
@@ -29,11 +29,11 @@ fn set_window_gradient(
2929
let c: u8 = 255 - (i as u8);
3030
let i = i as i32;
3131
let color = match gradient {
32-
Gradient::Red => Color::RGB(c, 0, 0),
33-
Gradient::Cyan => Color::RGB(0, c, c),
34-
Gradient::Green => Color::RGB(0, c, 0),
35-
Gradient::Blue => Color::RGB(0, 0, c),
36-
Gradient::White => Color::RGB(c, c, c),
32+
Gradient::Red => RColor::RGB(c, 0, 0),
33+
Gradient::Cyan => RColor::RGB(0, c, c),
34+
Gradient::Green => RColor::RGB(0, c, 0),
35+
Gradient::Blue => RColor::RGB(0, 0, c),
36+
Gradient::White => RColor::RGB(c, c, c),
3737
};
3838
surface.fill_rect(Rect::new(i * 4, 0, 4, WINDOW_HEIGHT), color)?;
3939
}

examples/renderer-target.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ extern crate sdl2;
22

33
use sdl2::event::Event;
44
use sdl2::keyboard::Keycode;
5-
use sdl2::pixels::{Color, PixelFormatEnum};
5+
use sdl2::pixels::{PixelFormatEnum, RColor};
66
use sdl2::rect::{Point, Rect};
77

88
fn main() -> Result<(), String> {
@@ -40,13 +40,13 @@ fn main() -> Result<(), String> {
4040
canvas
4141
.with_texture_canvas(&mut texture, |texture_canvas| {
4242
texture_canvas.clear();
43-
texture_canvas.set_draw_color(Color::RGBA(255, 0, 0, 255));
43+
texture_canvas.set_draw_color(RColor::RGBA(255, 0, 0, 255));
4444
texture_canvas
4545
.fill_rect(Rect::new(0, 0, 400, 300))
4646
.expect("could not fill rect");
4747
})
4848
.map_err(|e| e.to_string())?;
49-
canvas.set_draw_color(Color::RGBA(0, 0, 0, 255));
49+
canvas.set_draw_color(RColor::RGBA(0, 0, 0, 255));
5050
let dst = Some(Rect::new(0, 0, 400, 300));
5151
canvas.clear();
5252
canvas.copy_ex(

examples/window-properties.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ extern crate sdl2;
22

33
use sdl2::event::Event;
44
use sdl2::keyboard::Keycode;
5-
use sdl2::pixels::Color;
5+
use sdl2::pixels::RColor;
66

77
pub fn main() -> Result<(), String> {
88
let sdl_context = sdl2::init()?;
@@ -51,7 +51,7 @@ pub fn main() -> Result<(), String> {
5151
tick += 1;
5252
}
5353

54-
canvas.set_draw_color(Color::RGB(0, 0, 0));
54+
canvas.set_draw_color(RColor::RGB(0, 0, 0));
5555
canvas.clear();
5656
canvas.present();
5757
}

0 commit comments

Comments
 (0)