@@ -18,7 +18,7 @@ use std::c_str::CString;
18
18
use std:: num:: FromPrimitive ;
19
19
use sdl2:: surface:: Surface ;
20
20
use sdl2:: get_error;
21
- use sdl2:: pixels:: Color ;
21
+ use sdl2:: pixels:: ToColor ;
22
22
use sdl2:: rwops:: RWops ;
23
23
use sdl2:: version:: Version ;
24
24
@@ -336,11 +336,11 @@ impl Font {
336
336
}
337
337
}
338
338
339
- pub fn render_bytes_solid ( & self , text : & [ u8 ] , fg : Color ) -> Result < ~Surface , ~str > {
339
+ pub fn render_bytes_solid < C : ToColor > ( & self , text : & [ u8 ] , fg : C ) -> Result < ~Surface , ~str > {
340
340
//! Draw LATIN1 text in solid mode.
341
341
unsafe {
342
342
let raw = text. with_c_str ( |ctext| {
343
- ffi:: TTF_RenderText_Solid ( self . raw , ctext, fg)
343
+ ffi:: TTF_RenderText_Solid ( self . raw , ctext, fg. to_color ( ) )
344
344
} ) ;
345
345
if raw. is_null ( ) {
346
346
Err ( get_error ( ) )
@@ -350,11 +350,11 @@ impl Font {
350
350
}
351
351
}
352
352
353
- pub fn render_str_solid ( & self , text : & str , fg : Color ) -> Result < ~Surface , ~str > {
353
+ pub fn render_str_solid < C : ToColor > ( & self , text : & str , fg : C ) -> Result < ~Surface , ~str > {
354
354
//! Draw UTF8 text in solid mode.
355
355
unsafe {
356
356
let raw = text. with_c_str ( |ctext| {
357
- ffi:: TTF_RenderUTF8_Solid ( self . raw , ctext, fg)
357
+ ffi:: TTF_RenderUTF8_Solid ( self . raw , ctext, fg. to_color ( ) )
358
358
} ) ;
359
359
if raw. is_null ( ) {
360
360
Err ( get_error ( ) )
@@ -364,10 +364,10 @@ impl Font {
364
364
}
365
365
}
366
366
367
- pub fn render_char_solid ( & self , ch : char , fg : Color ) -> Result < ~Surface , ~str > {
367
+ pub fn render_char_solid < C : ToColor > ( & self , ch : char , fg : C ) -> Result < ~Surface , ~str > {
368
368
//! Draw a UNICODE glyph in solid mode.
369
369
unsafe {
370
- let raw = ffi:: TTF_RenderGlyph_Solid ( self . raw , ch as u16 , fg) ;
370
+ let raw = ffi:: TTF_RenderGlyph_Solid ( self . raw , ch as u16 , fg. to_color ( ) ) ;
371
371
if raw. is_null ( ) {
372
372
Err ( get_error ( ) )
373
373
} else {
@@ -376,11 +376,11 @@ impl Font {
376
376
}
377
377
}
378
378
379
- pub fn render_bytes_shaded ( & self , text : & [ u8 ] , fg : Color , bg : Color ) -> Result < ~Surface , ~str > {
379
+ pub fn render_bytes_shaded < C : ToColor > ( & self , text : & [ u8 ] , fg : C , bg : C ) -> Result < ~Surface , ~str > {
380
380
//! Draw LATIN1 text in shaded mode.
381
381
unsafe {
382
382
let raw = text. with_c_str ( |ctext| {
383
- ffi:: TTF_RenderText_Shaded ( self . raw , ctext, fg, bg)
383
+ ffi:: TTF_RenderText_Shaded ( self . raw , ctext, fg. to_color ( ) , bg. to_color ( ) )
384
384
} ) ;
385
385
if raw. is_null ( ) {
386
386
Err ( get_error ( ) )
@@ -390,11 +390,11 @@ impl Font {
390
390
}
391
391
}
392
392
393
- pub fn render_str_shaded ( & self , text : & str , fg : Color , bg : Color ) -> Result < ~Surface , ~str > {
393
+ pub fn render_str_shaded < C : ToColor > ( & self , text : & str , fg : C , bg : C ) -> Result < ~Surface , ~str > {
394
394
//! Draw UTF8 text in shaded mode.
395
395
unsafe {
396
396
let raw = text. with_c_str ( |ctext| {
397
- ffi:: TTF_RenderUTF8_Shaded ( self . raw , ctext, fg, bg)
397
+ ffi:: TTF_RenderUTF8_Shaded ( self . raw , ctext, fg. to_color ( ) , bg. to_color ( ) )
398
398
} ) ;
399
399
if raw. is_null ( ) {
400
400
Err ( get_error ( ) )
@@ -404,10 +404,10 @@ impl Font {
404
404
}
405
405
}
406
406
407
- pub fn render_char_shaded ( & self , ch : char , fg : Color , bg : Color ) -> Result < ~Surface , ~str > {
407
+ pub fn render_char_shaded < C : ToColor > ( & self , ch : char , fg : C , bg : C ) -> Result < ~Surface , ~str > {
408
408
//! Draw a UNICODE glyph in shaded mode.
409
409
unsafe {
410
- let raw = ffi:: TTF_RenderGlyph_Shaded ( self . raw , ch as u16 , fg, bg) ;
410
+ let raw = ffi:: TTF_RenderGlyph_Shaded ( self . raw , ch as u16 , fg. to_color ( ) , bg. to_color ( ) ) ;
411
411
if raw. is_null ( ) {
412
412
Err ( get_error ( ) )
413
413
} else {
@@ -416,11 +416,11 @@ impl Font {
416
416
}
417
417
}
418
418
419
- pub fn render_bytes_blended ( & self , text : & [ u8 ] , fg : Color ) -> Result < ~Surface , ~str > {
419
+ pub fn render_bytes_blended < C : ToColor > ( & self , text : & [ u8 ] , fg : C ) -> Result < ~Surface , ~str > {
420
420
//! Draw LATIN1 text in blended mode.
421
421
unsafe {
422
422
let raw = text. with_c_str ( |ctext| {
423
- ffi:: TTF_RenderText_Blended ( self . raw , ctext, fg)
423
+ ffi:: TTF_RenderText_Blended ( self . raw , ctext, fg. to_color ( ) )
424
424
} ) ;
425
425
if raw. is_null ( ) {
426
426
Err ( get_error ( ) )
@@ -430,11 +430,11 @@ impl Font {
430
430
}
431
431
}
432
432
433
- pub fn render_str_blended ( & self , text : & str , fg : Color ) -> Result < ~Surface , ~str > {
433
+ pub fn render_str_blended < C : ToColor > ( & self , text : & str , fg : C ) -> Result < ~Surface , ~str > {
434
434
//! Draw UTF8 text in blended mode.
435
435
unsafe {
436
436
let raw = text. with_c_str ( |ctext| {
437
- ffi:: TTF_RenderUTF8_Blended ( self . raw , ctext, fg)
437
+ ffi:: TTF_RenderUTF8_Blended ( self . raw , ctext, fg. to_color ( ) )
438
438
} ) ;
439
439
if raw. is_null ( ) {
440
440
Err ( get_error ( ) )
@@ -444,10 +444,10 @@ impl Font {
444
444
}
445
445
}
446
446
447
- pub fn render_char_blended ( & self , ch : char , fg : Color ) -> Result < ~Surface , ~str > {
447
+ pub fn render_char_blended < C : ToColor > ( & self , ch : char , fg : C ) -> Result < ~Surface , ~str > {
448
448
//! Draw a UNICODE glyph in blended mode.
449
449
unsafe {
450
- let raw = ffi:: TTF_RenderGlyph_Blended ( self . raw , ch as u16 , fg) ;
450
+ let raw = ffi:: TTF_RenderGlyph_Blended ( self . raw , ch as u16 , fg. to_color ( ) ) ;
451
451
if raw. is_null ( ) {
452
452
Err ( get_error ( ) )
453
453
} else {
0 commit comments