formatting
note that i'm intentionally not using rustfmt. i've tried to like that tool, but in the end i just really don't like it. too many edge cases and subjectivity and not enough customization. which is probably the intent. which makes me hate it that much more. fuck you, rustfmt.
This commit is contained in:
parent
43333687a8
commit
eb6a363afd
|
@ -11,7 +11,7 @@ use libretrogd::utils::rnd_value;
|
||||||
struct AudioChannelStatus {
|
struct AudioChannelStatus {
|
||||||
size: usize,
|
size: usize,
|
||||||
position: usize,
|
position: usize,
|
||||||
playing: bool
|
playing: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_and_convert_wav(path: &Path, target_spec: &AudioSpec) -> Result<AudioBuffer> {
|
fn load_and_convert_wav(path: &Path, target_spec: &AudioSpec) -> Result<AudioBuffer> {
|
||||||
|
@ -95,7 +95,6 @@ fn main() -> Result<()> {
|
||||||
if system.input_devices.keyboard.is_key_pressed(Scancode::Num3) {
|
if system.input_devices.keyboard.is_key_pressed(Scancode::Num3) {
|
||||||
if using_queue_commands {
|
if using_queue_commands {
|
||||||
system.audio_queue.play_buffer(&sounds[2], false);
|
system.audio_queue.play_buffer(&sounds[2], false);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
audio_device.play_buffer(&sounds[2], false)?;
|
audio_device.play_buffer(&sounds[2], false)?;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +103,6 @@ fn main() -> Result<()> {
|
||||||
if system.input_devices.keyboard.is_key_pressed(Scancode::Num4) {
|
if system.input_devices.keyboard.is_key_pressed(Scancode::Num4) {
|
||||||
if using_queue_commands {
|
if using_queue_commands {
|
||||||
system.audio_queue.play_buffer(&sounds[3], false);
|
system.audio_queue.play_buffer(&sounds[3], false);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
audio_device.play_buffer(&sounds[3], false)?;
|
audio_device.play_buffer(&sounds[3], false)?;
|
||||||
}
|
}
|
||||||
|
@ -174,7 +172,7 @@ fn main() -> Result<()> {
|
||||||
} else {
|
} else {
|
||||||
"Direct Commands"
|
"Direct Commands"
|
||||||
},
|
},
|
||||||
160, 16, FontRenderOpts::Color(9), &system.font
|
160, 16, FontRenderOpts::Color(9), &system.font,
|
||||||
);
|
);
|
||||||
|
|
||||||
system.video.print_string("Audio Channels", 16, 32, FontRenderOpts::Color(14), &system.font);
|
system.video.print_string("Audio Channels", 16, 32, FontRenderOpts::Color(14), &system.font);
|
||||||
|
@ -191,7 +189,7 @@ fn main() -> Result<()> {
|
||||||
),
|
),
|
||||||
16, y,
|
16, y,
|
||||||
FontRenderOpts::Color(15),
|
FontRenderOpts::Color(15),
|
||||||
&system.font
|
&system.font,
|
||||||
);
|
);
|
||||||
y += 16;
|
y += 16;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ fn new_bounce_particles(entities: &mut Entities, x: f32, y: f32) {
|
||||||
BOUNCE_PARTICLE_COLOR,
|
BOUNCE_PARTICLE_COLOR,
|
||||||
BOUNCE_PARTICLE_LIFETIME,
|
BOUNCE_PARTICLE_LIFETIME,
|
||||||
angle,
|
angle,
|
||||||
BOUNCE_PARTICLE_SPEED
|
BOUNCE_PARTICLE_SPEED,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ fn render_system_sprites(context: &mut Context) {
|
||||||
BlitMethod::Transparent(0),
|
BlitMethod::Transparent(0),
|
||||||
&context.sprites[sprite_index.0],
|
&context.sprites[sprite_index.0],
|
||||||
position.0.x as i32,
|
position.0.x as i32,
|
||||||
position.0.y as i32
|
position.0.y as i32,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ fn event_handler(event: &Event, context: &mut Context) -> bool {
|
||||||
match event {
|
match event {
|
||||||
Event::Kill(entity) => {
|
Event::Kill(entity) => {
|
||||||
context.entities.remove_entity(*entity);
|
context.entities.remove_entity(*entity);
|
||||||
},
|
}
|
||||||
Event::CollideAgainstEdge(entity) => {
|
Event::CollideAgainstEdge(entity) => {
|
||||||
let positions = context.entities.components::<Position>();
|
let positions = context.entities.components::<Position>();
|
||||||
let position = positions.get(entity).unwrap();
|
let position = positions.get(entity).unwrap();
|
||||||
|
@ -223,7 +223,7 @@ fn event_handler(event: &Event, context: &mut Context) -> bool {
|
||||||
let y = position.0.y + (BALL_SIZE / 2) as f32;
|
let y = position.0.y + (BALL_SIZE / 2) as f32;
|
||||||
drop(positions);
|
drop(positions);
|
||||||
new_bounce_particles(&mut context.entities, x, y);
|
new_bounce_particles(&mut context.entities, x, y);
|
||||||
},
|
}
|
||||||
Event::LeaveTrail(position) => {
|
Event::LeaveTrail(position) => {
|
||||||
new_trail_particle_entity(&mut context.entities, position.x, position.y, TRAIL_PARTICLE_LIFETIME);
|
new_trail_particle_entity(&mut context.entities, position.x, position.y, TRAIL_PARTICLE_LIFETIME);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl Game {
|
||||||
&balls_bmp,
|
&balls_bmp,
|
||||||
&Rect::new(i as i32 * BALL_SIZE as i32, 0, BALL_SIZE as u32, BALL_SIZE as u32),
|
&Rect::new(i as i32 * BALL_SIZE as i32, 0, BALL_SIZE as u32, BALL_SIZE as u32),
|
||||||
0,
|
0,
|
||||||
0
|
0,
|
||||||
);
|
);
|
||||||
sprites.push(sprite);
|
sprites.push(sprite);
|
||||||
}
|
}
|
||||||
|
@ -61,10 +61,10 @@ impl Game {
|
||||||
font,
|
font,
|
||||||
sprites,
|
sprites,
|
||||||
entities,
|
entities,
|
||||||
event_publisher
|
event_publisher,
|
||||||
},
|
},
|
||||||
component_systems,
|
component_systems,
|
||||||
event_listeners
|
event_listeners,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ fn event_handler(event: &Event, context: &mut Core) -> bool {
|
||||||
if context.entities.has_entity(*entity) {
|
if context.entities.has_entity(*entity) {
|
||||||
remove_entity(&mut context.entities, *entity);
|
remove_entity(&mut context.entities, *entity);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
Event::RemoveAttachment(entity) => {
|
Event::RemoveAttachment(entity) => {
|
||||||
if context.entities.has_entity(*entity) {
|
if context.entities.has_entity(*entity) {
|
||||||
remove_entity_attachment(&mut context.entities, *entity);
|
remove_entity_attachment(&mut context.entities, *entity);
|
||||||
|
@ -36,15 +36,15 @@ fn event_handler(event: &Event, context: &mut Core) -> bool {
|
||||||
if context.entities.has_entity(*entity) {
|
if context.entities.has_entity(*entity) {
|
||||||
turn_and_move_entity(context, *entity, *direction);
|
turn_and_move_entity(context, *entity, *direction);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
Event::MoveForward(entity) => {
|
Event::MoveForward(entity) => {
|
||||||
if context.entities.has_entity(*entity) {
|
if context.entities.has_entity(*entity) {
|
||||||
move_entity_forward(context, *entity);
|
move_entity_forward(context, *entity);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
Event::Spawn(entity) => {
|
Event::Spawn(entity) => {
|
||||||
// todo
|
// todo
|
||||||
},
|
}
|
||||||
Event::AnimationFinished(entity) => {
|
Event::AnimationFinished(entity) => {
|
||||||
if context.entities.has_entity(*entity) {
|
if context.entities.has_entity(*entity) {
|
||||||
// if the entity's 'attack' animation just finished, move them back to 'idle'
|
// if the entity's 'attack' animation just finished, move them back to 'idle'
|
||||||
|
@ -59,25 +59,25 @@ fn event_handler(event: &Event, context: &mut Core) -> bool {
|
||||||
}
|
}
|
||||||
Event::SpawnSlimeRandomly => {
|
Event::SpawnSlimeRandomly => {
|
||||||
spawn_slime_randomly(context);
|
spawn_slime_randomly(context);
|
||||||
},
|
}
|
||||||
Event::SetActivity(entity, activity) => {
|
Event::SetActivity(entity, activity) => {
|
||||||
if context.entities.has_entity(*entity) {
|
if context.entities.has_entity(*entity) {
|
||||||
set_entity_activity(&mut context.entities, *entity, *activity);
|
set_entity_activity(&mut context.entities, *entity, *activity);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
Event::Attack(entity) => {
|
Event::Attack(entity) => {
|
||||||
if context.entities.has_entity(*entity) {
|
if context.entities.has_entity(*entity) {
|
||||||
attack(context, *entity);
|
attack(context, *entity);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
Event::Hit(target, source, damage, damage_position) => {
|
Event::Hit(target, source, damage, damage_position) => {
|
||||||
if context.entities.has_entity(*target) {
|
if context.entities.has_entity(*target) {
|
||||||
hit_entity(context, *target, *source, *damage, *damage_position);
|
hit_entity(context, *target, *source, *damage, *damage_position);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
Event::Kill(entity) => {
|
Event::Kill(entity) => {
|
||||||
kill_entity(context, *entity);
|
kill_entity(context, *entity);
|
||||||
},
|
}
|
||||||
Event::Pickup(picked_up_by, picked_up) => {
|
Event::Pickup(picked_up_by, picked_up) => {
|
||||||
if context.entities.has_entity(*picked_up_by) && context.entities.has_entity(*picked_up) {
|
if context.entities.has_entity(*picked_up_by) && context.entities.has_entity(*picked_up) {
|
||||||
pickup(context, *picked_up_by, *picked_up);
|
pickup(context, *picked_up_by, *picked_up);
|
||||||
|
|
|
@ -150,7 +150,7 @@ pub fn apply_damage_at(context: &mut Core, area: Circle, damage: i32, source: En
|
||||||
let circle = Circle::new(
|
let circle = Circle::new(
|
||||||
position.0.x as i32 + bound.width as i32 / 2,
|
position.0.x as i32 + bound.width as i32 / 2,
|
||||||
position.0.y as i32 + bound.height as i32 / 2,
|
position.0.y as i32 + bound.height as i32 / 2,
|
||||||
bound.radius
|
bound.radius,
|
||||||
);
|
);
|
||||||
if area.overlaps(&circle) {
|
if area.overlaps(&circle) {
|
||||||
context.event_publisher.queue(Event::Hit(*entity, source, damage, source_position.0));
|
context.event_publisher.queue(Event::Hit(*entity, source, damage, source_position.0));
|
||||||
|
@ -630,7 +630,7 @@ fn update_system_pickups(context: &mut Core) {
|
||||||
let pickuper_circle = Circle::new(
|
let pickuper_circle = Circle::new(
|
||||||
pickuper_position.0.x as i32 + pickuper_bounds.width as i32 / 2,
|
pickuper_position.0.x as i32 + pickuper_bounds.width as i32 / 2,
|
||||||
pickuper_position.0.y as i32 + pickuper_bounds.height as i32 / 2,
|
pickuper_position.0.y as i32 + pickuper_bounds.height as i32 / 2,
|
||||||
pickuper_bounds.radius
|
pickuper_bounds.radius,
|
||||||
);
|
);
|
||||||
|
|
||||||
for (pickupable_entity, pickupable) in pickupables.iter() {
|
for (pickupable_entity, pickupable) in pickupables.iter() {
|
||||||
|
@ -640,7 +640,7 @@ fn update_system_pickups(context: &mut Core) {
|
||||||
let pickupable_circle = Circle::new(
|
let pickupable_circle = Circle::new(
|
||||||
pickupable_position.0.x as i32 + pickupable_bounds.width as i32 / 2,
|
pickupable_position.0.x as i32 + pickupable_bounds.width as i32 / 2,
|
||||||
pickupable_position.0.y as i32 + pickupable_bounds.height as i32 / 2,
|
pickupable_position.0.y as i32 + pickupable_bounds.height as i32 / 2,
|
||||||
pickupable_bounds.radius
|
pickupable_bounds.radius,
|
||||||
);
|
);
|
||||||
|
|
||||||
if pickupable_circle.overlaps(&pickuper_circle) {
|
if pickupable_circle.overlaps(&pickuper_circle) {
|
||||||
|
@ -673,11 +673,11 @@ fn render_system_sprites(context: &mut Core) {
|
||||||
FlickerMethod::OnOff => {
|
FlickerMethod::OnOff => {
|
||||||
// skip to the next entity, this one isn't visible
|
// skip to the next entity, this one isn't visible
|
||||||
continue;
|
continue;
|
||||||
},
|
}
|
||||||
FlickerMethod::Color(draw_color) => {
|
FlickerMethod::Color(draw_color) => {
|
||||||
blit_method = BlitMethod::TransparentSingle {
|
blit_method = BlitMethod::TransparentSingle {
|
||||||
transparent_color: 0,
|
transparent_color: 0,
|
||||||
draw_color
|
draw_color,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ impl AppState<Game> for GamePlayState {
|
||||||
State::Pending => {
|
State::Pending => {
|
||||||
init_everything(context, Path::new("./assets/arena.map.json"), 0.5, 2.0, 100);
|
init_everything(context, Path::new("./assets/arena.map.json"), 0.5, 2.0, 100);
|
||||||
spawn_player_randomly(&mut context.core);
|
spawn_player_randomly(&mut context.core);
|
||||||
},
|
}
|
||||||
State::TransitionIn => {
|
State::TransitionIn => {
|
||||||
self.fade = 0.0;
|
self.fade = 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ pub fn update_fade_transition(state: State, fade: &mut f32, delta: f32, context:
|
||||||
context.core.system.palette.lerp(0..=255, &context.core.fade_out_palette, &context.core.palette, *fade);
|
context.core.system.palette.lerp(0..=255, &context.core.fade_out_palette, &context.core.palette, *fade);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
State::TransitionOut(_) => {
|
State::TransitionOut(_) => {
|
||||||
*fade -= delta;
|
*fade -= delta;
|
||||||
if *fade <= 0.0 {
|
if *fade <= 0.0 {
|
||||||
|
@ -75,7 +75,7 @@ pub fn update_fade_transition(state: State, fade: &mut f32, delta: f32, context:
|
||||||
context.core.system.palette.lerp(0..=255, &context.core.fade_out_palette, &context.core.palette, *fade);
|
context.core.system.palette.lerp(0..=255, &context.core.fade_out_palette, &context.core.palette, *fade);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => {
|
_ => {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ impl TileMap {
|
||||||
if self.collision()[index] == TILE_FLAG_COLLISION {
|
if self.collision()[index] == TILE_FLAG_COLLISION {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => return true
|
None => return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub fn event_listener(event: &Event, context: &mut Core) -> bool {
|
||||||
Event::Remove(entity) => {
|
Event::Remove(entity) => {
|
||||||
context.entities.remove_entity(*entity);
|
context.entities.remove_entity(*entity);
|
||||||
true
|
true
|
||||||
},
|
}
|
||||||
Event::SpawnPixel => {
|
Event::SpawnPixel => {
|
||||||
let speed = rnd_value(1, 10) as f32 * 10.0;
|
let speed = rnd_value(1, 10) as f32 * 10.0;
|
||||||
let angle = (rnd_value(0, 359) as f32).to_radians();
|
let angle = (rnd_value(0, 359) as f32).to_radians();
|
||||||
|
@ -33,7 +33,7 @@ pub fn event_listener(event: &Event, context: &mut Core) -> bool {
|
||||||
context.entities.add_component(id, Velocity(Vector2::from_angle(angle) * speed));
|
context.entities.add_component(id, Velocity(Vector2::from_angle(angle) * speed));
|
||||||
context.entities.add_component(id, Color(color));
|
context.entities.add_component(id, Color(color));
|
||||||
true
|
true
|
||||||
},
|
}
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ impl AppState<App> for DemoState {
|
||||||
fn update(&mut self, state: State, context: &mut App) -> Option<StateChange<App>> {
|
fn update(&mut self, state: State, context: &mut App) -> Option<StateChange<App>> {
|
||||||
if state == State::Active {
|
if state == State::Active {
|
||||||
if context.core.system.input_devices.keyboard.is_key_pressed(Scancode::Escape) {
|
if context.core.system.input_devices.keyboard.is_key_pressed(Scancode::Escape) {
|
||||||
return Some(StateChange::Pop(1))
|
return Some(StateChange::Pop(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ impl AppState<App> for DemoState {
|
||||||
match new_state {
|
match new_state {
|
||||||
State::Pending => {
|
State::Pending => {
|
||||||
self.init(context);
|
self.init(context);
|
||||||
},
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ impl CoreStateWithEvents<Event> for Core {
|
||||||
|
|
||||||
pub struct Support {
|
pub struct Support {
|
||||||
pub component_systems: ComponentSystems<Core, Core>,
|
pub component_systems: ComponentSystems<Core, Core>,
|
||||||
pub event_listeners: EventListeners<Event, Core>
|
pub event_listeners: EventListeners<Event, Core>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SupportSystems for Support {}
|
impl SupportSystems for Support {}
|
||||||
|
@ -217,7 +217,7 @@ impl App {
|
||||||
support: Support {
|
support: Support {
|
||||||
component_systems,
|
component_systems,
|
||||||
event_listeners,
|
event_listeners,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, Criterion, criterion_group, criterion_main};
|
||||||
|
|
||||||
use libretrogd::graphics::*;
|
|
||||||
use libretrogd::{SCREEN_HEIGHT, SCREEN_WIDTH};
|
use libretrogd::{SCREEN_HEIGHT, SCREEN_WIDTH};
|
||||||
|
use libretrogd::graphics::*;
|
||||||
|
|
||||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
let mut source = Bitmap::new(SCREEN_WIDTH, SCREEN_HEIGHT).unwrap();
|
let mut source = Bitmap::new(SCREEN_WIDTH, SCREEN_HEIGHT).unwrap();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, Criterion, criterion_group, criterion_main};
|
||||||
|
|
||||||
use libretrogd::graphics::*;
|
use libretrogd::graphics::*;
|
||||||
use libretrogd::math::*;
|
use libretrogd::math::*;
|
||||||
|
@ -69,7 +69,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
framebuffer.blit(
|
framebuffer.blit(
|
||||||
black_box(BlitMethod::SolidFlipped {
|
black_box(BlitMethod::SolidFlipped {
|
||||||
horizontal_flip: false,
|
horizontal_flip: false,
|
||||||
vertical_flip: false
|
vertical_flip: false,
|
||||||
}),
|
}),
|
||||||
black_box(&solid_bmp),
|
black_box(&solid_bmp),
|
||||||
black_box(100),
|
black_box(100),
|
||||||
|
@ -83,7 +83,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
framebuffer.blit(
|
framebuffer.blit(
|
||||||
black_box(BlitMethod::SolidFlipped {
|
black_box(BlitMethod::SolidFlipped {
|
||||||
horizontal_flip: true,
|
horizontal_flip: true,
|
||||||
vertical_flip: false
|
vertical_flip: false,
|
||||||
}),
|
}),
|
||||||
black_box(&solid_bmp),
|
black_box(&solid_bmp),
|
||||||
black_box(100),
|
black_box(100),
|
||||||
|
@ -97,7 +97,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
framebuffer.blit(
|
framebuffer.blit(
|
||||||
black_box(BlitMethod::SolidFlipped {
|
black_box(BlitMethod::SolidFlipped {
|
||||||
horizontal_flip: false,
|
horizontal_flip: false,
|
||||||
vertical_flip: true
|
vertical_flip: true,
|
||||||
}),
|
}),
|
||||||
black_box(&solid_bmp),
|
black_box(&solid_bmp),
|
||||||
black_box(100),
|
black_box(100),
|
||||||
|
@ -111,7 +111,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
framebuffer.blit(
|
framebuffer.blit(
|
||||||
black_box(BlitMethod::SolidFlipped {
|
black_box(BlitMethod::SolidFlipped {
|
||||||
horizontal_flip: true,
|
horizontal_flip: true,
|
||||||
vertical_flip: true
|
vertical_flip: true,
|
||||||
}),
|
}),
|
||||||
black_box(&solid_bmp),
|
black_box(&solid_bmp),
|
||||||
black_box(100),
|
black_box(100),
|
||||||
|
@ -128,7 +128,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
black_box(BlitMethod::TransparentFlipped {
|
black_box(BlitMethod::TransparentFlipped {
|
||||||
transparent_color: 0,
|
transparent_color: 0,
|
||||||
horizontal_flip: false,
|
horizontal_flip: false,
|
||||||
vertical_flip: false
|
vertical_flip: false,
|
||||||
}),
|
}),
|
||||||
black_box(&trans_bmp),
|
black_box(&trans_bmp),
|
||||||
black_box(100),
|
black_box(100),
|
||||||
|
@ -143,7 +143,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
black_box(BlitMethod::TransparentFlipped {
|
black_box(BlitMethod::TransparentFlipped {
|
||||||
transparent_color: 0,
|
transparent_color: 0,
|
||||||
horizontal_flip: true,
|
horizontal_flip: true,
|
||||||
vertical_flip: false
|
vertical_flip: false,
|
||||||
}),
|
}),
|
||||||
black_box(&trans_bmp),
|
black_box(&trans_bmp),
|
||||||
black_box(100),
|
black_box(100),
|
||||||
|
@ -158,7 +158,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
black_box(BlitMethod::TransparentFlipped {
|
black_box(BlitMethod::TransparentFlipped {
|
||||||
transparent_color: 0,
|
transparent_color: 0,
|
||||||
horizontal_flip: false,
|
horizontal_flip: false,
|
||||||
vertical_flip: true
|
vertical_flip: true,
|
||||||
}),
|
}),
|
||||||
black_box(&trans_bmp),
|
black_box(&trans_bmp),
|
||||||
black_box(100),
|
black_box(100),
|
||||||
|
@ -173,7 +173,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
black_box(BlitMethod::TransparentFlipped {
|
black_box(BlitMethod::TransparentFlipped {
|
||||||
transparent_color: 0,
|
transparent_color: 0,
|
||||||
horizontal_flip: true,
|
horizontal_flip: true,
|
||||||
vertical_flip: true
|
vertical_flip: true,
|
||||||
}),
|
}),
|
||||||
black_box(&trans_bmp),
|
black_box(&trans_bmp),
|
||||||
black_box(100),
|
black_box(100),
|
||||||
|
@ -492,7 +492,6 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
criterion_group!(benches, criterion_benchmark);
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
|
|
@ -332,37 +332,37 @@ impl AudioDevice {
|
||||||
|
|
||||||
/// Returns an iterator of any [`AudioChannel`]s that are currently playing.
|
/// Returns an iterator of any [`AudioChannel`]s that are currently playing.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn playing_channels_iter(&mut self) -> impl Iterator<Item = &AudioChannel> {
|
pub fn playing_channels_iter(&mut self) -> impl Iterator<Item=&AudioChannel> {
|
||||||
self.channels.iter().filter(|channel| channel.playing)
|
self.channels.iter().filter(|channel| channel.playing)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator of mutable [`AudioChannel`]s that are currently playing.
|
/// Returns an iterator of mutable [`AudioChannel`]s that are currently playing.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn playing_channels_iter_mut(&mut self) -> impl Iterator<Item = &mut AudioChannel> {
|
pub fn playing_channels_iter_mut(&mut self) -> impl Iterator<Item=&mut AudioChannel> {
|
||||||
self.channels.iter_mut().filter(|channel| channel.playing)
|
self.channels.iter_mut().filter(|channel| channel.playing)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator of [`AudioChannel`]s that are not currently playing.
|
/// Returns an iterator of [`AudioChannel`]s that are not currently playing.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn stopped_channels_iter(&mut self) -> impl Iterator<Item = &AudioChannel> {
|
pub fn stopped_channels_iter(&mut self) -> impl Iterator<Item=&AudioChannel> {
|
||||||
self.channels.iter().filter(|channel| !channel.playing)
|
self.channels.iter().filter(|channel| !channel.playing)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator of mutable [`AudioChannel`]s that are not currently playing.
|
/// Returns an iterator of mutable [`AudioChannel`]s that are not currently playing.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn stopped_channels_iter_mut(&mut self) -> impl Iterator<Item = &mut AudioChannel> {
|
pub fn stopped_channels_iter_mut(&mut self) -> impl Iterator<Item=&mut AudioChannel> {
|
||||||
self.channels.iter_mut().filter(|channel| !channel.playing)
|
self.channels.iter_mut().filter(|channel| !channel.playing)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator of all [`AudioChannel`]s.
|
/// Returns an iterator of all [`AudioChannel`]s.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_iter(&mut self) -> impl Iterator<Item = &AudioChannel> {
|
pub fn channels_iter(&mut self) -> impl Iterator<Item=&AudioChannel> {
|
||||||
self.channels.iter()
|
self.channels.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator of all [`AudioChannel`]s as mutable references.
|
/// Returns an iterator of all [`AudioChannel`]s as mutable references.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_iter_mut(&mut self) -> impl Iterator<Item = &mut AudioChannel> {
|
pub fn channels_iter_mut(&mut self) -> impl Iterator<Item=&mut AudioChannel> {
|
||||||
self.channels.iter_mut()
|
self.channels.iter_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,38 +46,38 @@ impl std::fmt::Debug for AudioCommand {
|
||||||
.field("buffer", buffer)
|
.field("buffer", buffer)
|
||||||
.field("loops", loops)
|
.field("loops", loops)
|
||||||
.finish()
|
.finish()
|
||||||
},
|
}
|
||||||
PlayRcBuffer { buffer, loops } => {
|
PlayRcBuffer { buffer, loops } => {
|
||||||
f.debug_struct("PlayRcBuffer")
|
f.debug_struct("PlayRcBuffer")
|
||||||
.field("buffer", buffer)
|
.field("buffer", buffer)
|
||||||
.field("loops", loops)
|
.field("loops", loops)
|
||||||
.finish()
|
.finish()
|
||||||
},
|
}
|
||||||
PlayBufferOnChannel { channel, buffer, loops } => {
|
PlayBufferOnChannel { channel, buffer, loops } => {
|
||||||
f.debug_struct("PlayBufferOnChannel")
|
f.debug_struct("PlayBufferOnChannel")
|
||||||
.field("channel", channel)
|
.field("channel", channel)
|
||||||
.field("buffer", buffer)
|
.field("buffer", buffer)
|
||||||
.field("loops", loops)
|
.field("loops", loops)
|
||||||
.finish()
|
.finish()
|
||||||
},
|
}
|
||||||
PlayRcBufferOnChannel { channel, buffer, loops } => {
|
PlayRcBufferOnChannel { channel, buffer, loops } => {
|
||||||
f.debug_struct("PlayRcBufferOnChannel")
|
f.debug_struct("PlayRcBufferOnChannel")
|
||||||
.field("channel", channel)
|
.field("channel", channel)
|
||||||
.field("buffer", buffer)
|
.field("buffer", buffer)
|
||||||
.field("loops", loops)
|
.field("loops", loops)
|
||||||
.finish()
|
.finish()
|
||||||
},
|
}
|
||||||
PlayGenerator { loops, .. } => {
|
PlayGenerator { loops, .. } => {
|
||||||
f.debug_struct("PlayGenerator")
|
f.debug_struct("PlayGenerator")
|
||||||
.field("loops", loops)
|
.field("loops", loops)
|
||||||
.finish_non_exhaustive()
|
.finish_non_exhaustive()
|
||||||
},
|
}
|
||||||
PlayGeneratorOnChannel { channel, loops, .. } => {
|
PlayGeneratorOnChannel { channel, loops, .. } => {
|
||||||
f.debug_struct("PlayGeneratorOnChannel")
|
f.debug_struct("PlayGeneratorOnChannel")
|
||||||
.field("channel", channel)
|
.field("channel", channel)
|
||||||
.field("loops", loops)
|
.field("loops", loops)
|
||||||
.finish_non_exhaustive()
|
.finish_non_exhaustive()
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,31 +247,31 @@ impl AudioQueue {
|
||||||
match command {
|
match command {
|
||||||
StopChannel(channel_index) => {
|
StopChannel(channel_index) => {
|
||||||
device.stop_channel(channel_index)?;
|
device.stop_channel(channel_index)?;
|
||||||
},
|
}
|
||||||
StopAllChannels => {
|
StopAllChannels => {
|
||||||
device.stop_all();
|
device.stop_all();
|
||||||
},
|
}
|
||||||
PlayBuffer { buffer, loops } => {
|
PlayBuffer { buffer, loops } => {
|
||||||
device.play_buffer(&buffer, loops)?;
|
device.play_buffer(&buffer, loops)?;
|
||||||
}
|
}
|
||||||
PlayRcBuffer { buffer, loops } => {
|
PlayRcBuffer { buffer, loops } => {
|
||||||
device.play_buffer(&buffer, loops)?;
|
device.play_buffer(&buffer, loops)?;
|
||||||
},
|
}
|
||||||
PlayBufferOnChannel { channel, buffer, loops } => {
|
PlayBufferOnChannel { channel, buffer, loops } => {
|
||||||
device.play_buffer_on_channel(channel, &buffer, loops)?;
|
device.play_buffer_on_channel(channel, &buffer, loops)?;
|
||||||
}
|
}
|
||||||
PlayRcBufferOnChannel { channel, buffer, loops } => {
|
PlayRcBufferOnChannel { channel, buffer, loops } => {
|
||||||
device.play_buffer_on_channel(channel, &buffer, loops)?;
|
device.play_buffer_on_channel(channel, &buffer, loops)?;
|
||||||
},
|
}
|
||||||
PlayGenerator { generator, loops } => {
|
PlayGenerator { generator, loops } => {
|
||||||
device.play_generator(generator, loops)?;
|
device.play_generator(generator, loops)?;
|
||||||
},
|
}
|
||||||
PlayGeneratorOnChannel { channel, generator, loops } => {
|
PlayGeneratorOnChannel { channel, generator, loops } => {
|
||||||
device.play_generator_on_channel(channel, generator, loops)?;
|
device.play_generator_on_channel(channel, generator, loops)?;
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Ok(())
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ pub fn main_loop<ContextType, State>(
|
||||||
mut app: ContextType,
|
mut app: ContextType,
|
||||||
initial_state: State,
|
initial_state: State,
|
||||||
) -> Result<(), MainLoopError>
|
) -> Result<(), MainLoopError>
|
||||||
where
|
where
|
||||||
ContextType: AppContext,
|
ContextType: AppContext,
|
||||||
State: AppState<ContextType> + 'static,
|
State: AppState<ContextType> + 'static,
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,6 +11,7 @@ pub type EntityId = usize;
|
||||||
|
|
||||||
// alias `Component` to always be `'static` ...
|
// alias `Component` to always be `'static` ...
|
||||||
pub trait Component: 'static {}
|
pub trait Component: 'static {}
|
||||||
|
|
||||||
impl<T: 'static> Component for T {}
|
impl<T: 'static> Component for T {}
|
||||||
|
|
||||||
pub type ComponentStore<T> = RefCell<HashMap<EntityId, T>>;
|
pub type ComponentStore<T> = RefCell<HashMap<EntityId, T>>;
|
||||||
|
@ -495,12 +496,16 @@ mod tests {
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
||||||
struct Name(&'static str);
|
struct Name(&'static str);
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
||||||
struct Position(i32, i32);
|
struct Position(i32, i32);
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
||||||
struct Velocity(i32, i32);
|
struct Velocity(i32, i32);
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
||||||
struct Health(u32);
|
struct Health(u32);
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
||||||
struct Counter(u32);
|
struct Counter(u32);
|
||||||
|
|
||||||
|
@ -761,7 +766,7 @@ mod tests {
|
||||||
pub fn new(entities: Entities) -> Self {
|
pub fn new(entities: Entities) -> Self {
|
||||||
ComponentSystemContext {
|
ComponentSystemContext {
|
||||||
delta: 0.0,
|
delta: 0.0,
|
||||||
entities
|
entities,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ impl<EventType, ContextType> EventListeners<EventType, ContextType> {
|
||||||
// HACK?: comparing function pointers -- see above "HACK?" comment. same concern here.
|
// HACK?: comparing function pointers -- see above "HACK?" comment. same concern here.
|
||||||
self.listeners.retain(|&l| l as usize != listener as usize);
|
self.listeners.retain(|&l| l as usize != listener as usize);
|
||||||
// return true if the listener was removed
|
// return true if the listener was removed
|
||||||
return before_size != self.listeners.len()
|
return before_size != self.listeners.len();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Moves the queue from the given [`EventPublisher`] to this manager in preparation for
|
/// Moves the queue from the given [`EventPublisher`] to this manager in preparation for
|
||||||
|
@ -141,7 +141,6 @@ impl<EventType, ContextType> EventListeners<EventType, ContextType> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -194,7 +193,7 @@ mod tests {
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,6 +336,5 @@ mod tests {
|
||||||
vec![Message("hello"), Dummy, Foobar(3)],
|
vec![Message("hello"), Dummy, Foobar(3)],
|
||||||
context.events
|
context.events
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,7 +349,7 @@ unsafe fn per_pixel_rotozoom_blit(
|
||||||
top_left_x.min(bottom_left_x).min(top_right_x).min(bottom_right_x) as i32 - 1,
|
top_left_x.min(bottom_left_x).min(top_right_x).min(bottom_right_x) as i32 - 1,
|
||||||
top_left_y.min(bottom_left_y).min(top_right_y).min(bottom_right_y) as i32 - 1,
|
top_left_y.min(bottom_left_y).min(top_right_y).min(bottom_right_y) as i32 - 1,
|
||||||
top_left_x.max(bottom_left_x).max(top_right_x).max(bottom_right_x) as i32 + 1,
|
top_left_x.max(bottom_left_x).max(top_right_x).max(bottom_right_x) as i32 + 1,
|
||||||
top_left_y.max(bottom_left_y).max(top_right_y).max(bottom_right_y) as i32 + 1
|
top_left_y.max(bottom_left_y).max(top_right_y).max(bottom_right_y) as i32 + 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
// now we're ready to draw. we'll be iterating through each pixel on the area we calculated
|
// now we're ready to draw. we'll be iterating through each pixel on the area we calculated
|
||||||
|
@ -422,7 +422,7 @@ impl Bitmap {
|
||||||
} else {
|
} else {
|
||||||
*dest_pixels = *src_pixels;
|
*dest_pixels = *src_pixels;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ impl Bitmap {
|
||||||
self, src, src_region, dest_x, dest_y, horizontal_flip, vertical_flip,
|
self, src, src_region, dest_x, dest_y, horizontal_flip, vertical_flip,
|
||||||
|src_pixels, dest_pixels| {
|
|src_pixels, dest_pixels| {
|
||||||
*dest_pixels = *src_pixels;
|
*dest_pixels = *src_pixels;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ impl Bitmap {
|
||||||
} else {
|
} else {
|
||||||
*dest_pixels = *src_pixels;
|
*dest_pixels = *src_pixels;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ impl Bitmap {
|
||||||
self, src, src_region, dest_x, dest_y,
|
self, src, src_region, dest_x, dest_y,
|
||||||
|src_pixels, dest_pixels| {
|
|src_pixels, dest_pixels| {
|
||||||
*dest_pixels = (*src_pixels).wrapping_add(offset);
|
*dest_pixels = (*src_pixels).wrapping_add(offset);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,7 +495,7 @@ impl Bitmap {
|
||||||
self, src, src_region, dest_x, dest_y, horizontal_flip, vertical_flip,
|
self, src, src_region, dest_x, dest_y, horizontal_flip, vertical_flip,
|
||||||
|src_pixels, dest_pixels| {
|
|src_pixels, dest_pixels| {
|
||||||
*dest_pixels = (*src_pixels).wrapping_add(offset);
|
*dest_pixels = (*src_pixels).wrapping_add(offset);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ impl Bitmap {
|
||||||
if *src_pixels != transparent_color {
|
if *src_pixels != transparent_color {
|
||||||
*dest_pixels = *src_pixels;
|
*dest_pixels = *src_pixels;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ impl Bitmap {
|
||||||
*dest_pixels = *src_pixels;
|
*dest_pixels = *src_pixels;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,7 +556,7 @@ impl Bitmap {
|
||||||
if *src_pixels != transparent_color {
|
if *src_pixels != transparent_color {
|
||||||
*dest_pixels = *src_pixels;
|
*dest_pixels = *src_pixels;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ impl Bitmap {
|
||||||
*dest_pixels = *src_pixels;
|
*dest_pixels = *src_pixels;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,7 +600,7 @@ impl Bitmap {
|
||||||
if *src_pixels != transparent_color {
|
if *src_pixels != transparent_color {
|
||||||
*dest_pixels = (*src_pixels).wrapping_add(offset);
|
*dest_pixels = (*src_pixels).wrapping_add(offset);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,7 +621,7 @@ impl Bitmap {
|
||||||
if *src_pixels != transparent_color {
|
if *src_pixels != transparent_color {
|
||||||
*dest_pixels = (*src_pixels).wrapping_add(offset);
|
*dest_pixels = (*src_pixels).wrapping_add(offset);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ impl Bitmap {
|
||||||
if *src_pixels != transparent_color {
|
if *src_pixels != transparent_color {
|
||||||
*dest_pixels = draw_color;
|
*dest_pixels = draw_color;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,7 +661,7 @@ impl Bitmap {
|
||||||
if *src_pixels != transparent_color {
|
if *src_pixels != transparent_color {
|
||||||
*dest_pixels = draw_color;
|
*dest_pixels = draw_color;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,7 +680,7 @@ impl Bitmap {
|
||||||
|src_pixel, dest_bitmap, draw_x, draw_y| {
|
|src_pixel, dest_bitmap, draw_x, draw_y| {
|
||||||
dest_bitmap.set_pixel(draw_x, draw_y, src_pixel);
|
dest_bitmap.set_pixel(draw_x, draw_y, src_pixel);
|
||||||
//dest_bitmap.set_pixel(draw_x + 1, draw_y, src_pixel);
|
//dest_bitmap.set_pixel(draw_x + 1, draw_y, src_pixel);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,7 +706,7 @@ impl Bitmap {
|
||||||
};
|
};
|
||||||
dest_bitmap.set_pixel(draw_x, draw_y, draw_pixel);
|
dest_bitmap.set_pixel(draw_x, draw_y, draw_pixel);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,7 +727,7 @@ impl Bitmap {
|
||||||
if transparent_color != src_pixel {
|
if transparent_color != src_pixel {
|
||||||
dest_bitmap.set_pixel(draw_x, draw_y, src_pixel);
|
dest_bitmap.set_pixel(draw_x, draw_y, src_pixel);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -756,7 +756,7 @@ impl Bitmap {
|
||||||
dest_bitmap.set_pixel(draw_x, draw_y, draw_pixel);
|
dest_bitmap.set_pixel(draw_x, draw_y, draw_pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,7 +776,7 @@ impl Bitmap {
|
||||||
|src_pixel, dest_bitmap, draw_x, draw_y| {
|
|src_pixel, dest_bitmap, draw_x, draw_y| {
|
||||||
let src_pixel = src_pixel.wrapping_add(offset);
|
let src_pixel = src_pixel.wrapping_add(offset);
|
||||||
dest_bitmap.set_pixel(draw_x, draw_y, src_pixel);
|
dest_bitmap.set_pixel(draw_x, draw_y, src_pixel);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -799,7 +799,7 @@ impl Bitmap {
|
||||||
let src_pixel = src_pixel.wrapping_add(offset);
|
let src_pixel = src_pixel.wrapping_add(offset);
|
||||||
dest_bitmap.set_pixel(draw_x, draw_y, src_pixel);
|
dest_bitmap.set_pixel(draw_x, draw_y, src_pixel);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -888,52 +888,52 @@ impl Bitmap {
|
||||||
SolidOffset(offset) => self.solid_palette_offset_blit(src, src_region, dest_x, dest_y, offset),
|
SolidOffset(offset) => self.solid_palette_offset_blit(src, src_region, dest_x, dest_y, offset),
|
||||||
SolidFlippedOffset { horizontal_flip, vertical_flip, offset } => {
|
SolidFlippedOffset { horizontal_flip, vertical_flip, offset } => {
|
||||||
self.solid_flipped_palette_offset_blit(src, src_region, dest_x, dest_y, horizontal_flip, vertical_flip, offset)
|
self.solid_flipped_palette_offset_blit(src, src_region, dest_x, dest_y, horizontal_flip, vertical_flip, offset)
|
||||||
},
|
}
|
||||||
Transparent(transparent_color) => {
|
Transparent(transparent_color) => {
|
||||||
self.transparent_blit(src, src_region, dest_x, dest_y, transparent_color)
|
self.transparent_blit(src, src_region, dest_x, dest_y, transparent_color)
|
||||||
},
|
}
|
||||||
TransparentFlipped { transparent_color, horizontal_flip, vertical_flip } => {
|
TransparentFlipped { transparent_color, horizontal_flip, vertical_flip } => {
|
||||||
self.transparent_flipped_blit(src, src_region, dest_x, dest_y, transparent_color, horizontal_flip, vertical_flip)
|
self.transparent_flipped_blit(src, src_region, dest_x, dest_y, transparent_color, horizontal_flip, vertical_flip)
|
||||||
},
|
}
|
||||||
TransparentOffset { transparent_color, offset } => {
|
TransparentOffset { transparent_color, offset } => {
|
||||||
self.transparent_palette_offset_blit(src, src_region, dest_x, dest_y, transparent_color, offset)
|
self.transparent_palette_offset_blit(src, src_region, dest_x, dest_y, transparent_color, offset)
|
||||||
},
|
}
|
||||||
TransparentFlippedOffset { transparent_color, horizontal_flip, vertical_flip, offset } => {
|
TransparentFlippedOffset { transparent_color, horizontal_flip, vertical_flip, offset } => {
|
||||||
self.transparent_flipped_palette_offset_blit(src, src_region, dest_x, dest_y, transparent_color, horizontal_flip, vertical_flip, offset)
|
self.transparent_flipped_palette_offset_blit(src, src_region, dest_x, dest_y, transparent_color, horizontal_flip, vertical_flip, offset)
|
||||||
},
|
}
|
||||||
TransparentSingle { transparent_color, draw_color } => {
|
TransparentSingle { transparent_color, draw_color } => {
|
||||||
self.transparent_single_color_blit(src, src_region, dest_x, dest_y, transparent_color, draw_color)
|
self.transparent_single_color_blit(src, src_region, dest_x, dest_y, transparent_color, draw_color)
|
||||||
},
|
}
|
||||||
TransparentFlippedSingle { transparent_color, horizontal_flip, vertical_flip, draw_color } => {
|
TransparentFlippedSingle { transparent_color, horizontal_flip, vertical_flip, draw_color } => {
|
||||||
self.transparent_flipped_single_color_blit(src, src_region, dest_x, dest_y, transparent_color, horizontal_flip, vertical_flip, draw_color)
|
self.transparent_flipped_single_color_blit(src, src_region, dest_x, dest_y, transparent_color, horizontal_flip, vertical_flip, draw_color)
|
||||||
},
|
}
|
||||||
RotoZoom { angle, scale_x, scale_y } => {
|
RotoZoom { angle, scale_x, scale_y } => {
|
||||||
self.rotozoom_blit(src, src_region, dest_x, dest_y, angle, scale_x, scale_y)
|
self.rotozoom_blit(src, src_region, dest_x, dest_y, angle, scale_x, scale_y)
|
||||||
},
|
}
|
||||||
RotoZoomOffset { angle, scale_x, scale_y, offset } => {
|
RotoZoomOffset { angle, scale_x, scale_y, offset } => {
|
||||||
self.rotozoom_palette_offset_blit(src, src_region, dest_x, dest_y, angle, scale_x, scale_y, offset)
|
self.rotozoom_palette_offset_blit(src, src_region, dest_x, dest_y, angle, scale_x, scale_y, offset)
|
||||||
},
|
}
|
||||||
RotoZoomTransparent { angle, scale_x, scale_y, transparent_color } => {
|
RotoZoomTransparent { angle, scale_x, scale_y, transparent_color } => {
|
||||||
self.rotozoom_transparent_blit(src, src_region, dest_x, dest_y, angle, scale_x, scale_y, transparent_color)
|
self.rotozoom_transparent_blit(src, src_region, dest_x, dest_y, angle, scale_x, scale_y, transparent_color)
|
||||||
},
|
}
|
||||||
RotoZoomTransparentOffset { angle, scale_x, scale_y, transparent_color, offset } => {
|
RotoZoomTransparentOffset { angle, scale_x, scale_y, transparent_color, offset } => {
|
||||||
self.rotozoom_transparent_palette_offset_blit(src, src_region, dest_x, dest_y, angle, scale_x, scale_y, transparent_color, offset)
|
self.rotozoom_transparent_palette_offset_blit(src, src_region, dest_x, dest_y, angle, scale_x, scale_y, transparent_color, offset)
|
||||||
},
|
}
|
||||||
SolidBlended { blend_map } => {
|
SolidBlended { blend_map } => {
|
||||||
self.solid_blended_blit(src, src_region, dest_x, dest_y, blend_map)
|
self.solid_blended_blit(src, src_region, dest_x, dest_y, blend_map)
|
||||||
},
|
}
|
||||||
SolidFlippedBlended { horizontal_flip, vertical_flip, blend_map } => {
|
SolidFlippedBlended { horizontal_flip, vertical_flip, blend_map } => {
|
||||||
self.solid_flipped_blended_blit(src, src_region, dest_x, dest_y, horizontal_flip, vertical_flip, blend_map)
|
self.solid_flipped_blended_blit(src, src_region, dest_x, dest_y, horizontal_flip, vertical_flip, blend_map)
|
||||||
},
|
}
|
||||||
TransparentBlended { transparent_color, blend_map } => {
|
TransparentBlended { transparent_color, blend_map } => {
|
||||||
self.transparent_blended_blit(src, src_region, dest_x, dest_y, transparent_color, blend_map)
|
self.transparent_blended_blit(src, src_region, dest_x, dest_y, transparent_color, blend_map)
|
||||||
},
|
}
|
||||||
TransparentFlippedBlended { transparent_color, horizontal_flip, vertical_flip, blend_map } => {
|
TransparentFlippedBlended { transparent_color, horizontal_flip, vertical_flip, blend_map } => {
|
||||||
self.transparent_flipped_blended_blit(src, src_region, dest_x, dest_y, transparent_color, horizontal_flip, vertical_flip, blend_map)
|
self.transparent_flipped_blended_blit(src, src_region, dest_x, dest_y, transparent_color, horizontal_flip, vertical_flip, blend_map)
|
||||||
},
|
}
|
||||||
RotoZoomBlended { angle, scale_x, scale_y, blend_map } => {
|
RotoZoomBlended { angle, scale_x, scale_y, blend_map } => {
|
||||||
self.rotozoom_blended_blit(src, src_region, dest_x, dest_y, angle, scale_x, scale_y, blend_map)
|
self.rotozoom_blended_blit(src, src_region, dest_x, dest_y, angle, scale_x, scale_y, blend_map)
|
||||||
},
|
}
|
||||||
RotoZoomTransparentBlended { angle, scale_x, scale_y, transparent_color, blend_map } => {
|
RotoZoomTransparentBlended { angle, scale_x, scale_y, transparent_color, blend_map } => {
|
||||||
self.rotozoom_transparent_blended_blit(src, src_region, dest_x, dest_y, angle, scale_x, scale_y, transparent_color, blend_map)
|
self.rotozoom_transparent_blended_blit(src, src_region, dest_x, dest_y, angle, scale_x, scale_y, transparent_color, blend_map)
|
||||||
}
|
}
|
||||||
|
|
|
@ -333,7 +333,7 @@ impl LocalImageDescriptor {
|
||||||
y: reader.read_u16::<LittleEndian>()?,
|
y: reader.read_u16::<LittleEndian>()?,
|
||||||
width: reader.read_u16::<LittleEndian>()?,
|
width: reader.read_u16::<LittleEndian>()?,
|
||||||
height: reader.read_u16::<LittleEndian>()?,
|
height: reader.read_u16::<LittleEndian>()?,
|
||||||
flags: reader.read_u8()?
|
flags: reader.read_u8()?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,29 +444,29 @@ impl Bitmap {
|
||||||
if frame_palette.is_some() {
|
if frame_palette.is_some() {
|
||||||
palette = frame_palette;
|
palette = frame_palette;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
EXTENSION_INTRODUCER => {
|
EXTENSION_INTRODUCER => {
|
||||||
let label = GifExtensionLabel::from(reader.read_u8()?)?;
|
let label = GifExtensionLabel::from(reader.read_u8()?)?;
|
||||||
match label {
|
match label {
|
||||||
GifExtensionLabel::GraphicControl => {
|
GifExtensionLabel::GraphicControl => {
|
||||||
current_graphic_control = Some(GraphicControlExtension::read(reader)?);
|
current_graphic_control = Some(GraphicControlExtension::read(reader)?);
|
||||||
},
|
}
|
||||||
GifExtensionLabel::PlainText => {
|
GifExtensionLabel::PlainText => {
|
||||||
let _plain_text = PlainTextExtension::read(reader)?;
|
let _plain_text = PlainTextExtension::read(reader)?;
|
||||||
// todo: do something with this maybe
|
// todo: do something with this maybe
|
||||||
},
|
}
|
||||||
GifExtensionLabel::Application => {
|
GifExtensionLabel::Application => {
|
||||||
let _application = ApplicationExtension::read(reader)?;
|
let _application = ApplicationExtension::read(reader)?;
|
||||||
// todo: do something with this maybe
|
// todo: do something with this maybe
|
||||||
},
|
}
|
||||||
GifExtensionLabel::Comment => {
|
GifExtensionLabel::Comment => {
|
||||||
let _comment = CommentExtension::read(reader)?;
|
let _comment = CommentExtension::read(reader)?;
|
||||||
// todo: do something with this maybe
|
// todo: do something with this maybe
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(GifError::BadFile(format!("Unexpected byte found {} not a file trailer, image separator or extension introducer", current_byte)))
|
return Err(GifError::BadFile(format!("Unexpected byte found {} not a file trailer, image separator or extension introducer", current_byte)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -493,7 +493,6 @@ impl Bitmap {
|
||||||
palette: &Palette,
|
palette: &Palette,
|
||||||
settings: GifSettings,
|
settings: GifSettings,
|
||||||
) -> Result<(), GifError> {
|
) -> Result<(), GifError> {
|
||||||
|
|
||||||
let mut header = GifHeader {
|
let mut header = GifHeader {
|
||||||
signature: *b"GIF",
|
signature: *b"GIF",
|
||||||
version: *b"89a",
|
version: *b"89a",
|
||||||
|
@ -516,7 +515,7 @@ impl Bitmap {
|
||||||
match settings {
|
match settings {
|
||||||
GifSettings::Default => {
|
GifSettings::Default => {
|
||||||
transparent_color = 0;
|
transparent_color = 0;
|
||||||
},
|
}
|
||||||
GifSettings::TransparentColor(color) => {
|
GifSettings::TransparentColor(color) => {
|
||||||
transparent_color = color;
|
transparent_color = color;
|
||||||
}
|
}
|
||||||
|
@ -543,7 +542,7 @@ impl Bitmap {
|
||||||
&self,
|
&self,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
palette: &Palette,
|
palette: &Palette,
|
||||||
settings: GifSettings
|
settings: GifSettings,
|
||||||
) -> Result<(), GifError> {
|
) -> Result<(), GifError> {
|
||||||
let f = File::create(path)?;
|
let f = File::create(path)?;
|
||||||
let mut writer = BufWriter::new(f);
|
let mut writer = BufWriter::new(f);
|
||||||
|
|
|
@ -392,7 +392,7 @@ impl Bitmap {
|
||||||
Err(IffError::IOError(io_error))
|
Err(IffError::IOError(io_error))
|
||||||
if io_error.kind() == io::ErrorKind::UnexpectedEof =>
|
if io_error.kind() == io::ErrorKind::UnexpectedEof =>
|
||||||
{
|
{
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
Err(err) => return Err(err),
|
Err(err) => return Err(err),
|
||||||
};
|
};
|
||||||
|
|
|
@ -364,7 +364,7 @@ pub mod tests {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 32
|
height: 32,
|
||||||
},
|
},
|
||||||
bmp.full_bounds()
|
bmp.full_bounds()
|
||||||
);
|
);
|
||||||
|
@ -373,7 +373,7 @@ pub mod tests {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 32
|
height: 32,
|
||||||
},
|
},
|
||||||
*bmp.clip_region()
|
*bmp.clip_region()
|
||||||
);
|
);
|
||||||
|
@ -428,7 +428,7 @@ pub mod tests {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 8
|
height: 8,
|
||||||
},
|
},
|
||||||
bmp.full_bounds()
|
bmp.full_bounds()
|
||||||
);
|
);
|
||||||
|
|
|
@ -92,7 +92,7 @@ impl BlendMap {
|
||||||
blend_map.set_mapping(
|
blend_map.set_mapping(
|
||||||
source_color,
|
source_color,
|
||||||
idx as u8,
|
idx as u8,
|
||||||
(gradient_size - 1) - (lit / (256 / gradient_size as u32) as u8) + source_color
|
(gradient_size - 1) - (lit / (256 / gradient_size as u32) as u8) + source_color,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
}
|
}
|
||||||
blend_map
|
blend_map
|
||||||
|
@ -106,7 +106,7 @@ impl BlendMap {
|
||||||
gradient_start: u8,
|
gradient_start: u8,
|
||||||
gradient_end: u8,
|
gradient_end: u8,
|
||||||
palette: &Palette,
|
palette: &Palette,
|
||||||
f: impl Fn(f32, f32) -> f32
|
f: impl Fn(f32, f32) -> f32,
|
||||||
) -> BlendMap {
|
) -> BlendMap {
|
||||||
let (gradient_start, gradient_end) = if gradient_start > gradient_end {
|
let (gradient_start, gradient_end) = if gradient_start > gradient_end {
|
||||||
(gradient_end, gradient_start)
|
(gradient_end, gradient_start)
|
||||||
|
@ -126,7 +126,7 @@ impl BlendMap {
|
||||||
blend_map.set_mapping(
|
blend_map.set_mapping(
|
||||||
source_color,
|
source_color,
|
||||||
dest_color,
|
dest_color,
|
||||||
(gradient_size - 1).wrapping_sub(weight / (256 / gradient_size as u32) as u8) + gradient_start
|
(gradient_size - 1).wrapping_sub(weight / (256 / gradient_size as u32) as u8) + gradient_start,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ impl BlendMap {
|
||||||
Ok(BlendMap {
|
Ok(BlendMap {
|
||||||
start_color,
|
start_color,
|
||||||
end_color,
|
end_color,
|
||||||
mapping: maps.into_boxed_slice()
|
mapping: maps.into_boxed_slice(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ impl Font for BitmaskFont {
|
||||||
}
|
}
|
||||||
width = std::cmp::max(width, x);
|
width = std::cmp::max(width, x);
|
||||||
x = 0;
|
x = 0;
|
||||||
},
|
}
|
||||||
'\r' => (),
|
'\r' => (),
|
||||||
ch => {
|
ch => {
|
||||||
if x == 0 {
|
if x == 0 {
|
||||||
|
|
|
@ -7,13 +7,14 @@ use std::path::Path;
|
||||||
use byteorder::{ReadBytesExt, WriteBytesExt};
|
use byteorder::{ReadBytesExt, WriteBytesExt};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::NUM_COLORS;
|
|
||||||
use crate::graphics::*;
|
use crate::graphics::*;
|
||||||
|
use crate::NUM_COLORS;
|
||||||
use crate::utils::abs_diff;
|
use crate::utils::abs_diff;
|
||||||
|
|
||||||
// silly "hack" (???) which allows us to alias the generic constraint `RangeBounds<u8> + Iterator<Item = u8>` to `ColorRange`
|
// silly "hack" (???) which allows us to alias the generic constraint `RangeBounds<u8> + Iterator<Item = u8>` to `ColorRange`
|
||||||
pub trait ColorRange: RangeBounds<u8> + Iterator<Item = u8> {}
|
pub trait ColorRange: RangeBounds<u8> + Iterator<Item=u8> {}
|
||||||
impl<T> ColorRange for T where T: RangeBounds<u8> + Iterator<Item = u8> {}
|
|
||||||
|
impl<T> ColorRange for T where T: RangeBounds<u8> + Iterator<Item=u8> {}
|
||||||
|
|
||||||
pub static VGA_PALETTE_BYTES: &[u8] = include_bytes!("../../assets/vga.pal");
|
pub static VGA_PALETTE_BYTES: &[u8] = include_bytes!("../../assets/vga.pal");
|
||||||
|
|
||||||
|
@ -161,7 +162,7 @@ fn read_palette_6bit<T: ReadBytesExt>(
|
||||||
num_colors: usize,
|
num_colors: usize,
|
||||||
) -> Result<[u32; NUM_COLORS], PaletteError> {
|
) -> Result<[u32; NUM_COLORS], PaletteError> {
|
||||||
if num_colors > NUM_COLORS {
|
if num_colors > NUM_COLORS {
|
||||||
return Err(PaletteError::OutOfRange(num_colors))
|
return Err(PaletteError::OutOfRange(num_colors));
|
||||||
}
|
}
|
||||||
let mut colors = [0u32; NUM_COLORS];
|
let mut colors = [0u32; NUM_COLORS];
|
||||||
for i in 0..num_colors {
|
for i in 0..num_colors {
|
||||||
|
@ -180,7 +181,7 @@ fn write_palette_6bit<T: WriteBytesExt>(
|
||||||
num_colors: usize,
|
num_colors: usize,
|
||||||
) -> Result<(), PaletteError> {
|
) -> Result<(), PaletteError> {
|
||||||
if num_colors > NUM_COLORS {
|
if num_colors > NUM_COLORS {
|
||||||
return Err(PaletteError::OutOfRange(num_colors))
|
return Err(PaletteError::OutOfRange(num_colors));
|
||||||
}
|
}
|
||||||
for i in 0..num_colors {
|
for i in 0..num_colors {
|
||||||
let (r, g, b) = from_rgb32(colors[i as usize]);
|
let (r, g, b) = from_rgb32(colors[i as usize]);
|
||||||
|
@ -197,7 +198,7 @@ fn read_palette_8bit<T: ReadBytesExt>(
|
||||||
num_colors: usize,
|
num_colors: usize,
|
||||||
) -> Result<[u32; NUM_COLORS], PaletteError> {
|
) -> Result<[u32; NUM_COLORS], PaletteError> {
|
||||||
if num_colors > NUM_COLORS {
|
if num_colors > NUM_COLORS {
|
||||||
return Err(PaletteError::OutOfRange(num_colors))
|
return Err(PaletteError::OutOfRange(num_colors));
|
||||||
}
|
}
|
||||||
let mut colors = [0u32; NUM_COLORS];
|
let mut colors = [0u32; NUM_COLORS];
|
||||||
for i in 0..num_colors {
|
for i in 0..num_colors {
|
||||||
|
@ -216,7 +217,7 @@ fn write_palette_8bit<T: WriteBytesExt>(
|
||||||
num_colors: usize,
|
num_colors: usize,
|
||||||
) -> Result<(), PaletteError> {
|
) -> Result<(), PaletteError> {
|
||||||
if num_colors > NUM_COLORS {
|
if num_colors > NUM_COLORS {
|
||||||
return Err(PaletteError::OutOfRange(num_colors))
|
return Err(PaletteError::OutOfRange(num_colors));
|
||||||
}
|
}
|
||||||
for i in 0..num_colors {
|
for i in 0..num_colors {
|
||||||
let (r, g, b) = from_rgb32(colors[i as usize]);
|
let (r, g, b) = from_rgb32(colors[i as usize]);
|
||||||
|
@ -336,7 +337,7 @@ impl Palette {
|
||||||
num_colors: usize,
|
num_colors: usize,
|
||||||
) -> Result<Palette, PaletteError> {
|
) -> Result<Palette, PaletteError> {
|
||||||
if num_colors > NUM_COLORS {
|
if num_colors > NUM_COLORS {
|
||||||
return Err(PaletteError::OutOfRange(num_colors))
|
return Err(PaletteError::OutOfRange(num_colors));
|
||||||
}
|
}
|
||||||
let colors = match format {
|
let colors = match format {
|
||||||
PaletteFormat::Vga => read_palette_6bit(reader, num_colors)?,
|
PaletteFormat::Vga => read_palette_6bit(reader, num_colors)?,
|
||||||
|
@ -391,7 +392,7 @@ impl Palette {
|
||||||
num_colors: usize,
|
num_colors: usize,
|
||||||
) -> Result<(), PaletteError> {
|
) -> Result<(), PaletteError> {
|
||||||
if num_colors > NUM_COLORS {
|
if num_colors > NUM_COLORS {
|
||||||
return Err(PaletteError::OutOfRange(num_colors))
|
return Err(PaletteError::OutOfRange(num_colors));
|
||||||
}
|
}
|
||||||
let f = File::create(path)?;
|
let f = File::create(path)?;
|
||||||
let mut writer = BufWriter::new(f);
|
let mut writer = BufWriter::new(f);
|
||||||
|
@ -415,7 +416,7 @@ impl Palette {
|
||||||
num_colors: usize,
|
num_colors: usize,
|
||||||
) -> Result<(), PaletteError> {
|
) -> Result<(), PaletteError> {
|
||||||
if num_colors > NUM_COLORS {
|
if num_colors > NUM_COLORS {
|
||||||
return Err(PaletteError::OutOfRange(num_colors))
|
return Err(PaletteError::OutOfRange(num_colors));
|
||||||
}
|
}
|
||||||
match format {
|
match format {
|
||||||
PaletteFormat::Vga => write_palette_6bit(writer, &self.colors, num_colors),
|
PaletteFormat::Vga => write_palette_6bit(writer, &self.colors, num_colors),
|
||||||
|
|
|
@ -74,7 +74,7 @@ impl Matrix3x3 {
|
||||||
Matrix3x3::new(
|
Matrix3x3::new(
|
||||||
1.0, 0.0, 0.0,
|
1.0, 0.0, 0.0,
|
||||||
0.0, c, -s,
|
0.0, c, -s,
|
||||||
0.0, s, c
|
0.0, s, c,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ impl Matrix3x3 {
|
||||||
Matrix3x3::new(
|
Matrix3x3::new(
|
||||||
c, 0.0, s,
|
c, 0.0, s,
|
||||||
0.0, 1.0, 0.0,
|
0.0, 1.0, 0.0,
|
||||||
-s, 0.0, c
|
-s, 0.0, c,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ impl Matrix3x3 {
|
||||||
Matrix3x3::new(
|
Matrix3x3::new(
|
||||||
c, -s, 0.0,
|
c, -s, 0.0,
|
||||||
s, c, 0.0,
|
s, c, 0.0,
|
||||||
0.0, 0.0, 1.0
|
0.0, 0.0, 1.0,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ impl Matrix3x3 {
|
||||||
Matrix3x3::new(
|
Matrix3x3::new(
|
||||||
1.0, 0.0, 0.0,
|
1.0, 0.0, 0.0,
|
||||||
0.0, 1.0, 0.0,
|
0.0, 1.0, 0.0,
|
||||||
x, y, 1.0
|
x, y, 1.0,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ impl Matrix3x3 {
|
||||||
Matrix3x3::new(
|
Matrix3x3::new(
|
||||||
x, 0.0, 0.0,
|
x, 0.0, 0.0,
|
||||||
0.0, y, 0.0,
|
0.0, y, 0.0,
|
||||||
0.0, 0.0, 1.0
|
0.0, 0.0, 1.0,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ impl Mul for Matrix3x3 {
|
||||||
self.m[Matrix3x3::M21] * rhs.m[Matrix3x3::M13] + self.m[Matrix3x3::M22] * rhs.m[Matrix3x3::M23] + self.m[Matrix3x3::M23] * rhs.m[Matrix3x3::M33],
|
self.m[Matrix3x3::M21] * rhs.m[Matrix3x3::M13] + self.m[Matrix3x3::M22] * rhs.m[Matrix3x3::M23] + self.m[Matrix3x3::M23] * rhs.m[Matrix3x3::M33],
|
||||||
self.m[Matrix3x3::M31] * rhs.m[Matrix3x3::M11] + self.m[Matrix3x3::M32] * rhs.m[Matrix3x3::M21] + self.m[Matrix3x3::M33] * rhs.m[Matrix3x3::M31],
|
self.m[Matrix3x3::M31] * rhs.m[Matrix3x3::M11] + self.m[Matrix3x3::M32] * rhs.m[Matrix3x3::M21] + self.m[Matrix3x3::M33] * rhs.m[Matrix3x3::M31],
|
||||||
self.m[Matrix3x3::M31] * rhs.m[Matrix3x3::M12] + self.m[Matrix3x3::M32] * rhs.m[Matrix3x3::M22] + self.m[Matrix3x3::M33] * rhs.m[Matrix3x3::M32],
|
self.m[Matrix3x3::M31] * rhs.m[Matrix3x3::M12] + self.m[Matrix3x3::M32] * rhs.m[Matrix3x3::M22] + self.m[Matrix3x3::M33] * rhs.m[Matrix3x3::M32],
|
||||||
self.m[Matrix3x3::M31] * rhs.m[Matrix3x3::M13] + self.m[Matrix3x3::M32] * rhs.m[Matrix3x3::M23] + self.m[Matrix3x3::M33] * rhs.m[Matrix3x3::M33]
|
self.m[Matrix3x3::M31] * rhs.m[Matrix3x3::M13] + self.m[Matrix3x3::M32] * rhs.m[Matrix3x3::M23] + self.m[Matrix3x3::M33] * rhs.m[Matrix3x3::M33],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ impl MulAssign for Matrix3x3 {
|
||||||
self.m[Matrix3x3::M21] * rhs.m[Matrix3x3::M13] + self.m[Matrix3x3::M22] * rhs.m[Matrix3x3::M23] + self.m[Matrix3x3::M23] * rhs.m[Matrix3x3::M33],
|
self.m[Matrix3x3::M21] * rhs.m[Matrix3x3::M13] + self.m[Matrix3x3::M22] * rhs.m[Matrix3x3::M23] + self.m[Matrix3x3::M23] * rhs.m[Matrix3x3::M33],
|
||||||
self.m[Matrix3x3::M31] * rhs.m[Matrix3x3::M11] + self.m[Matrix3x3::M32] * rhs.m[Matrix3x3::M21] + self.m[Matrix3x3::M33] * rhs.m[Matrix3x3::M31],
|
self.m[Matrix3x3::M31] * rhs.m[Matrix3x3::M11] + self.m[Matrix3x3::M32] * rhs.m[Matrix3x3::M21] + self.m[Matrix3x3::M33] * rhs.m[Matrix3x3::M31],
|
||||||
self.m[Matrix3x3::M31] * rhs.m[Matrix3x3::M12] + self.m[Matrix3x3::M32] * rhs.m[Matrix3x3::M22] + self.m[Matrix3x3::M33] * rhs.m[Matrix3x3::M32],
|
self.m[Matrix3x3::M31] * rhs.m[Matrix3x3::M12] + self.m[Matrix3x3::M32] * rhs.m[Matrix3x3::M22] + self.m[Matrix3x3::M33] * rhs.m[Matrix3x3::M32],
|
||||||
self.m[Matrix3x3::M31] * rhs.m[Matrix3x3::M13] + self.m[Matrix3x3::M32] * rhs.m[Matrix3x3::M23] + self.m[Matrix3x3::M33] * rhs.m[Matrix3x3::M33]
|
self.m[Matrix3x3::M31] * rhs.m[Matrix3x3::M13] + self.m[Matrix3x3::M32] * rhs.m[Matrix3x3::M23] + self.m[Matrix3x3::M33] * rhs.m[Matrix3x3::M33],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ impl Mul<Vector2> for Matrix3x3 {
|
||||||
fn mul(self, rhs: Vector2) -> Self::Output {
|
fn mul(self, rhs: Vector2) -> Self::Output {
|
||||||
Vector2 {
|
Vector2 {
|
||||||
x: rhs.x * self.m[Matrix3x3::M11] + rhs.y * self.m[Matrix3x3::M12] + self.m[Matrix3x3::M13] + self.m[Matrix3x3::M31],
|
x: rhs.x * self.m[Matrix3x3::M11] + rhs.y * self.m[Matrix3x3::M12] + self.m[Matrix3x3::M13] + self.m[Matrix3x3::M31],
|
||||||
y: rhs.x * self.m[Matrix3x3::M21] + rhs.y * self.m[Matrix3x3::M22] + self.m[Matrix3x3::M23] + self.m[Matrix3x3::M32]
|
y: rhs.x * self.m[Matrix3x3::M21] + rhs.y * self.m[Matrix3x3::M22] + self.m[Matrix3x3::M23] + self.m[Matrix3x3::M32],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ pub mod tests {
|
||||||
let m = Matrix3x3::new(
|
let m = Matrix3x3::new(
|
||||||
1.0, 2.0, 3.0,
|
1.0, 2.0, 3.0,
|
||||||
4.0, 5.0, 6.0,
|
4.0, 5.0, 6.0,
|
||||||
7.0, 8.0, 9.0
|
7.0, 8.0, 9.0,
|
||||||
);
|
);
|
||||||
let t = m.transpose();
|
let t = m.transpose();
|
||||||
assert_eq!(1.0, t.m[Matrix3x3::M11]);
|
assert_eq!(1.0, t.m[Matrix3x3::M11]);
|
||||||
|
|
|
@ -10,9 +10,12 @@ pub mod matrix3x3;
|
||||||
pub mod rect;
|
pub mod rect;
|
||||||
pub mod vector2;
|
pub mod vector2;
|
||||||
|
|
||||||
pub const PI: f32 = std::f32::consts::PI; // 180 degrees
|
pub const PI: f32 = std::f32::consts::PI;
|
||||||
pub const HALF_PI: f32 = PI / 2.0; // 90 degrees
|
// 180 degrees
|
||||||
pub const QUARTER_PI: f32 = PI / 4.0; // 45 degrees
|
pub const HALF_PI: f32 = PI / 2.0;
|
||||||
|
// 90 degrees
|
||||||
|
pub const QUARTER_PI: f32 = PI / 4.0;
|
||||||
|
// 45 degrees
|
||||||
pub const TWO_PI: f32 = PI * 2.0; // 360 degrees
|
pub const TWO_PI: f32 = PI * 2.0; // 360 degrees
|
||||||
|
|
||||||
pub const RADIANS_0: f32 = 0.0;
|
pub const RADIANS_0: f32 = 0.0;
|
||||||
|
@ -53,8 +56,8 @@ pub fn nearly_equal(a: f32, b: f32, epsilon: f32) -> bool {
|
||||||
/// * `t`: the amount to interpolate between the two values, specified as a fraction
|
/// * `t`: the amount to interpolate between the two values, specified as a fraction
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn lerp<N>(a: N, b: N, t: f32) -> N
|
pub fn lerp<N>(a: N, b: N, t: f32) -> N
|
||||||
where
|
where
|
||||||
N: Copy + Add<Output = N> + Sub<Output = N> + Mul<f32, Output = N>,
|
N: Copy + Add<Output=N> + Sub<Output=N> + Mul<f32, Output=N>,
|
||||||
{
|
{
|
||||||
a + (b - a) * t
|
a + (b - a) * t
|
||||||
}
|
}
|
||||||
|
@ -69,8 +72,8 @@ where
|
||||||
/// * `lerp_result`: the interpolated value between the range given
|
/// * `lerp_result`: the interpolated value between the range given
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inverse_lerp<N>(a: N, b: N, lerp_result: N) -> f32
|
pub fn inverse_lerp<N>(a: N, b: N, lerp_result: N) -> f32
|
||||||
where
|
where
|
||||||
N: Copy + Sub<Output = N> + Div<N, Output = f32>,
|
N: Copy + Sub<Output=N> + Div<N, Output=f32>,
|
||||||
{
|
{
|
||||||
(lerp_result - a) / (b - a)
|
(lerp_result - a) / (b - a)
|
||||||
}
|
}
|
||||||
|
@ -84,8 +87,8 @@ where
|
||||||
/// * `t`: the amount to interpolate between the two values, specified as a fraction
|
/// * `t`: the amount to interpolate between the two values, specified as a fraction
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn smooth_lerp<N>(a: N, b: N, t: f32) -> N
|
pub fn smooth_lerp<N>(a: N, b: N, t: f32) -> N
|
||||||
where
|
where
|
||||||
N: Copy + Add<Output = N> + Sub<Output = N> + Mul<f32, Output = N>,
|
N: Copy + Add<Output=N> + Sub<Output=N> + Mul<f32, Output=N>,
|
||||||
{
|
{
|
||||||
let t = t.clamp(0.0, 1.0);
|
let t = t.clamp(0.0, 1.0);
|
||||||
lerp(a, b, (t * t) * (3.0 - (2.0 * t)))
|
lerp(a, b, (t * t) * (3.0 - (2.0 * t)))
|
||||||
|
@ -104,8 +107,8 @@ where
|
||||||
/// * `new_max`: new max value (high end of range)
|
/// * `new_max`: new max value (high end of range)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn scale_range<N>(value: N, old_min: N, old_max: N, new_min: N, new_max: N) -> N
|
pub fn scale_range<N>(value: N, old_min: N, old_max: N, new_min: N, new_max: N) -> N
|
||||||
where
|
where
|
||||||
N: Copy + Add<Output = N> + Sub<Output = N> + Mul<Output = N> + Div<Output = N>,
|
N: Copy + Add<Output=N> + Sub<Output=N> + Mul<Output=N> + Div<Output=N>,
|
||||||
{
|
{
|
||||||
(new_max - new_min) * (value - old_min) / (old_max - old_min) + new_min
|
(new_max - new_min) * (value - old_min) / (old_max - old_min) + new_min
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub enum TransitionTo {
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||||
pub enum TransitionDirection {
|
pub enum TransitionDirection {
|
||||||
In,
|
In,
|
||||||
Out
|
Out,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||||
|
@ -133,7 +133,7 @@ impl<ContextType> StateContainer<ContextType> {
|
||||||
State::Pending | State::Paused | State::Resume => {
|
State::Pending | State::Paused | State::Resume => {
|
||||||
self.change_state(State::TransitionIn, context);
|
self.change_state(State::TransitionIn, context);
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
}
|
||||||
_ => {
|
_ => {
|
||||||
Err(StateError::AppStateInvalidState(self.current_state))
|
Err(StateError::AppStateInvalidState(self.current_state))
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ impl<ContextType> States<ContextType> {
|
||||||
match command {
|
match command {
|
||||||
StateChange::Push(new_state) => {
|
StateChange::Push(new_state) => {
|
||||||
self.pending_state = Some(new_state);
|
self.pending_state = Some(new_state);
|
||||||
},
|
}
|
||||||
StateChange::Pop(count) => {
|
StateChange::Pop(count) => {
|
||||||
if let Some(state) = self.states.front_mut() {
|
if let Some(state) = self.states.front_mut() {
|
||||||
state.pending_transition_out(TransitionTo::Dead);
|
state.pending_transition_out(TransitionTo::Dead);
|
||||||
|
@ -351,7 +351,7 @@ impl<ContextType> States<ContextType> {
|
||||||
state.change_state(State::Resume, context);
|
state.change_state(State::Resume, context);
|
||||||
state.transition_in(context)?;
|
state.transition_in(context)?;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
State::Paused => {
|
State::Paused => {
|
||||||
state.pause(context)?;
|
state.pause(context)?;
|
||||||
|
|
||||||
|
@ -362,11 +362,11 @@ impl<ContextType> States<ContextType> {
|
||||||
new_state.change_state(State::Pending, context);
|
new_state.change_state(State::Pending, context);
|
||||||
self.states.push_front(new_state);
|
self.states.push_front(new_state);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
State::Active => state.activate(context)?,
|
State::Active => state.activate(context)?,
|
||||||
State::TransitionOut(to) => state.transition_out(to, context)?,
|
State::TransitionOut(to) => state.transition_out(to, context)?,
|
||||||
State::TransitionIn => state.transition_in(context)?,
|
State::TransitionIn => state.transition_in(context)?,
|
||||||
_ => {},
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,29 +383,29 @@ impl<ContextType> States<ContextType> {
|
||||||
Some(State::Paused) => {
|
Some(State::Paused) => {
|
||||||
// should never happen now. leaving here just in case ...
|
// should never happen now. leaving here just in case ...
|
||||||
return Err(StateError::AppStateInvalidState(State::Paused));
|
return Err(StateError::AppStateInvalidState(State::Paused));
|
||||||
},
|
}
|
||||||
Some(State::Dead) => {
|
Some(State::Dead) => {
|
||||||
// should never happen now. leaving here just in case ...
|
// should never happen now. leaving here just in case ...
|
||||||
return Err(StateError::AppStateInvalidState(State::Dead));
|
return Err(StateError::AppStateInvalidState(State::Dead));
|
||||||
},
|
}
|
||||||
Some(State::TransitionIn) => {
|
Some(State::TransitionIn) => {
|
||||||
let state = self.states.front_mut().unwrap();
|
let state = self.states.front_mut().unwrap();
|
||||||
if state.state().transition(State::TransitionIn, context) {
|
if state.state().transition(State::TransitionIn, context) {
|
||||||
// state has indicated it is done transitioning, so we can switch it to active
|
// state has indicated it is done transitioning, so we can switch it to active
|
||||||
state.pending_activate();
|
state.pending_activate();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
Some(State::TransitionOut(to)) => {
|
Some(State::TransitionOut(to)) => {
|
||||||
let state = self.states.front_mut().unwrap();
|
let state = self.states.front_mut().unwrap();
|
||||||
if state.state().transition(State::TransitionOut(to), context) {
|
if state.state().transition(State::TransitionOut(to), context) {
|
||||||
// state has indicated it is done transitioning, so we can switch it to whatever
|
// state has indicated it is done transitioning, so we can switch it to whatever
|
||||||
// it was transitioning to
|
// it was transitioning to
|
||||||
match to {
|
match to {
|
||||||
TransitionTo::Paused => { state.pending_pause(); },
|
TransitionTo::Paused => { state.pending_pause(); }
|
||||||
TransitionTo::Dead => { state.pending_kill(); }
|
TransitionTo::Dead => { state.pending_kill(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ impl<ContextType> States<ContextType> {
|
||||||
match current_state {
|
match current_state {
|
||||||
State::Active | State::TransitionIn | State::TransitionOut(_) => {
|
State::Active | State::TransitionIn | State::TransitionOut(_) => {
|
||||||
state.state().render(current_state, context);
|
state.state().render(current_state, context);
|
||||||
},
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,7 +533,7 @@ mod tests {
|
||||||
match new_state {
|
match new_state {
|
||||||
State::TransitionIn | State::TransitionOut(_) => {
|
State::TransitionIn | State::TransitionOut(_) => {
|
||||||
self.counter = self.transition_length;
|
self.counter = self.transition_length;
|
||||||
},
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,7 @@ mod tests {
|
||||||
StateChange(FOO, TransitionIn, Pending),
|
StateChange(FOO, TransitionIn, Pending),
|
||||||
Transition(FOO, TransitionIn),
|
Transition(FOO, TransitionIn),
|
||||||
Update(FOO, TransitionIn),
|
Update(FOO, TransitionIn),
|
||||||
Render(FOO, TransitionIn)
|
Render(FOO, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// state finished transitioning in, now moves to active
|
// state finished transitioning in, now moves to active
|
||||||
|
@ -577,7 +577,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(FOO, Active, TransitionIn),
|
StateChange(FOO, Active, TransitionIn),
|
||||||
Update(FOO, Active),
|
Update(FOO, Active),
|
||||||
Render(FOO, Active)
|
Render(FOO, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -592,7 +592,7 @@ mod tests {
|
||||||
StateChange(FOO, TransitionOut(TransitionTo::Dead), Active),
|
StateChange(FOO, TransitionOut(TransitionTo::Dead), Active),
|
||||||
Transition(FOO, TransitionOut(TransitionTo::Dead)),
|
Transition(FOO, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(FOO, TransitionOut(TransitionTo::Dead)),
|
Update(FOO, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(FOO, TransitionOut(TransitionTo::Dead))
|
Render(FOO, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// state finished transitioning out, now dies
|
// state finished transitioning out, now dies
|
||||||
|
@ -628,7 +628,7 @@ mod tests {
|
||||||
StateChange(FOO, TransitionIn, Pending),
|
StateChange(FOO, TransitionIn, Pending),
|
||||||
Transition(FOO, TransitionIn),
|
Transition(FOO, TransitionIn),
|
||||||
Update(FOO, TransitionIn),
|
Update(FOO, TransitionIn),
|
||||||
Render(FOO, TransitionIn)
|
Render(FOO, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// wait for transition to finish
|
// wait for transition to finish
|
||||||
|
@ -639,7 +639,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
Transition(FOO, TransitionIn),
|
Transition(FOO, TransitionIn),
|
||||||
Update(FOO, TransitionIn),
|
Update(FOO, TransitionIn),
|
||||||
Render(FOO, TransitionIn)
|
Render(FOO, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -650,7 +650,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(FOO, Active, TransitionIn),
|
StateChange(FOO, Active, TransitionIn),
|
||||||
Update(FOO, Active),
|
Update(FOO, Active),
|
||||||
Render(FOO, Active)
|
Render(FOO, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -665,7 +665,7 @@ mod tests {
|
||||||
StateChange(FOO, TransitionOut(TransitionTo::Dead), Active),
|
StateChange(FOO, TransitionOut(TransitionTo::Dead), Active),
|
||||||
Transition(FOO, TransitionOut(TransitionTo::Dead)),
|
Transition(FOO, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(FOO, TransitionOut(TransitionTo::Dead)),
|
Update(FOO, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(FOO, TransitionOut(TransitionTo::Dead))
|
Render(FOO, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// wait for transition to finish
|
// wait for transition to finish
|
||||||
|
@ -676,7 +676,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
Transition(FOO, TransitionOut(TransitionTo::Dead)),
|
Transition(FOO, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(FOO, TransitionOut(TransitionTo::Dead)),
|
Update(FOO, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(FOO, TransitionOut(TransitionTo::Dead))
|
Render(FOO, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -715,7 +715,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionIn, Pending),
|
StateChange(FIRST, TransitionIn, Pending),
|
||||||
Transition(FIRST, TransitionIn),
|
Transition(FIRST, TransitionIn),
|
||||||
Update(FIRST, TransitionIn),
|
Update(FIRST, TransitionIn),
|
||||||
Render(FIRST, TransitionIn)
|
Render(FIRST, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// first state finished transitioning in, now moves to active
|
// first state finished transitioning in, now moves to active
|
||||||
|
@ -725,7 +725,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(FIRST, Active, TransitionIn),
|
StateChange(FIRST, Active, TransitionIn),
|
||||||
Update(FIRST, Active),
|
Update(FIRST, Active),
|
||||||
Render(FIRST, Active)
|
Render(FIRST, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -741,7 +741,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionOut(TransitionTo::Paused), Active),
|
StateChange(FIRST, TransitionOut(TransitionTo::Paused), Active),
|
||||||
Transition(FIRST, TransitionOut(TransitionTo::Paused)),
|
Transition(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
Update(FIRST, TransitionOut(TransitionTo::Paused)),
|
Update(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
Render(FIRST, TransitionOut(TransitionTo::Paused))
|
Render(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// state finished transitioning out, now is paused
|
// state finished transitioning out, now is paused
|
||||||
|
@ -755,7 +755,7 @@ mod tests {
|
||||||
StateChange(SECOND, TransitionIn, Pending),
|
StateChange(SECOND, TransitionIn, Pending),
|
||||||
Transition(SECOND, TransitionIn),
|
Transition(SECOND, TransitionIn),
|
||||||
Update(SECOND, TransitionIn),
|
Update(SECOND, TransitionIn),
|
||||||
Render(SECOND, TransitionIn)
|
Render(SECOND, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// second state finished transitioning in, now moves to active
|
// second state finished transitioning in, now moves to active
|
||||||
|
@ -765,7 +765,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(SECOND, Active, TransitionIn),
|
StateChange(SECOND, Active, TransitionIn),
|
||||||
Update(SECOND, Active),
|
Update(SECOND, Active),
|
||||||
Render(SECOND, Active)
|
Render(SECOND, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -781,7 +781,7 @@ mod tests {
|
||||||
StateChange(SECOND, TransitionOut(TransitionTo::Dead), Active),
|
StateChange(SECOND, TransitionOut(TransitionTo::Dead), Active),
|
||||||
Transition(SECOND, TransitionOut(TransitionTo::Dead)),
|
Transition(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(SECOND, TransitionOut(TransitionTo::Dead)),
|
Update(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(SECOND, TransitionOut(TransitionTo::Dead))
|
Render(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// second state finished transitioning out, now dies. first state wakes up again and
|
// second state finished transitioning out, now dies. first state wakes up again and
|
||||||
|
@ -795,7 +795,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionIn, Resume),
|
StateChange(FIRST, TransitionIn, Resume),
|
||||||
Transition(FIRST, TransitionIn),
|
Transition(FIRST, TransitionIn),
|
||||||
Update(FIRST, TransitionIn),
|
Update(FIRST, TransitionIn),
|
||||||
Render(FIRST, TransitionIn)
|
Render(FIRST, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// first state finished transitioning in, now moves to active
|
// first state finished transitioning in, now moves to active
|
||||||
|
@ -805,7 +805,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(FIRST, Active, TransitionIn),
|
StateChange(FIRST, Active, TransitionIn),
|
||||||
Update(FIRST, Active),
|
Update(FIRST, Active),
|
||||||
Render(FIRST, Active)
|
Render(FIRST, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -821,7 +821,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionOut(TransitionTo::Dead), Active),
|
StateChange(FIRST, TransitionOut(TransitionTo::Dead), Active),
|
||||||
Transition(FIRST, TransitionOut(TransitionTo::Dead)),
|
Transition(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(FIRST, TransitionOut(TransitionTo::Dead)),
|
Update(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(FIRST, TransitionOut(TransitionTo::Dead))
|
Render(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// first state finished transitioning out, now dies
|
// first state finished transitioning out, now dies
|
||||||
|
@ -859,7 +859,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionIn, Pending),
|
StateChange(FIRST, TransitionIn, Pending),
|
||||||
Transition(FIRST, TransitionIn),
|
Transition(FIRST, TransitionIn),
|
||||||
Update(FIRST, TransitionIn),
|
Update(FIRST, TransitionIn),
|
||||||
Render(FIRST, TransitionIn)
|
Render(FIRST, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// wait for transition to finish
|
// wait for transition to finish
|
||||||
|
@ -870,7 +870,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
Transition(FIRST, TransitionIn),
|
Transition(FIRST, TransitionIn),
|
||||||
Update(FIRST, TransitionIn),
|
Update(FIRST, TransitionIn),
|
||||||
Render(FIRST, TransitionIn)
|
Render(FIRST, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -881,7 +881,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(FIRST, Active, TransitionIn),
|
StateChange(FIRST, Active, TransitionIn),
|
||||||
Update(FIRST, Active),
|
Update(FIRST, Active),
|
||||||
Render(FIRST, Active)
|
Render(FIRST, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -898,7 +898,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionOut(TransitionTo::Paused), Active),
|
StateChange(FIRST, TransitionOut(TransitionTo::Paused), Active),
|
||||||
Transition(FIRST, TransitionOut(TransitionTo::Paused)),
|
Transition(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
Update(FIRST, TransitionOut(TransitionTo::Paused)),
|
Update(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
Render(FIRST, TransitionOut(TransitionTo::Paused))
|
Render(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// wait for transition to finish
|
// wait for transition to finish
|
||||||
|
@ -909,7 +909,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
Transition(FIRST, TransitionOut(TransitionTo::Paused)),
|
Transition(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
Update(FIRST, TransitionOut(TransitionTo::Paused)),
|
Update(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
Render(FIRST, TransitionOut(TransitionTo::Paused))
|
Render(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -923,7 +923,7 @@ mod tests {
|
||||||
StateChange(SECOND, TransitionIn, Pending),
|
StateChange(SECOND, TransitionIn, Pending),
|
||||||
Transition(SECOND, TransitionIn),
|
Transition(SECOND, TransitionIn),
|
||||||
Update(SECOND, TransitionIn),
|
Update(SECOND, TransitionIn),
|
||||||
Render(SECOND, TransitionIn)
|
Render(SECOND, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// wait for transition to finish
|
// wait for transition to finish
|
||||||
|
@ -934,7 +934,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
Transition(SECOND, TransitionIn),
|
Transition(SECOND, TransitionIn),
|
||||||
Update(SECOND, TransitionIn),
|
Update(SECOND, TransitionIn),
|
||||||
Render(SECOND, TransitionIn)
|
Render(SECOND, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -945,7 +945,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(SECOND, Active, TransitionIn),
|
StateChange(SECOND, Active, TransitionIn),
|
||||||
Update(SECOND, Active),
|
Update(SECOND, Active),
|
||||||
Render(SECOND, Active)
|
Render(SECOND, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -961,7 +961,7 @@ mod tests {
|
||||||
StateChange(SECOND, TransitionOut(TransitionTo::Dead), Active),
|
StateChange(SECOND, TransitionOut(TransitionTo::Dead), Active),
|
||||||
Transition(SECOND, TransitionOut(TransitionTo::Dead)),
|
Transition(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(SECOND, TransitionOut(TransitionTo::Dead)),
|
Update(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(SECOND, TransitionOut(TransitionTo::Dead))
|
Render(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// wait for transition to finish
|
// wait for transition to finish
|
||||||
|
@ -972,7 +972,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
Transition(SECOND, TransitionOut(TransitionTo::Dead)),
|
Transition(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(SECOND, TransitionOut(TransitionTo::Dead)),
|
Update(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(SECOND, TransitionOut(TransitionTo::Dead))
|
Render(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -987,7 +987,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionIn, Resume),
|
StateChange(FIRST, TransitionIn, Resume),
|
||||||
Transition(FIRST, TransitionIn),
|
Transition(FIRST, TransitionIn),
|
||||||
Update(FIRST, TransitionIn),
|
Update(FIRST, TransitionIn),
|
||||||
Render(FIRST, TransitionIn)
|
Render(FIRST, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// wait for transition to finish
|
// wait for transition to finish
|
||||||
|
@ -998,7 +998,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
Transition(FIRST, TransitionIn),
|
Transition(FIRST, TransitionIn),
|
||||||
Update(FIRST, TransitionIn),
|
Update(FIRST, TransitionIn),
|
||||||
Render(FIRST, TransitionIn)
|
Render(FIRST, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +1009,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(FIRST, Active, TransitionIn),
|
StateChange(FIRST, Active, TransitionIn),
|
||||||
Update(FIRST, Active),
|
Update(FIRST, Active),
|
||||||
Render(FIRST, Active)
|
Render(FIRST, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1025,7 +1025,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionOut(TransitionTo::Dead), Active),
|
StateChange(FIRST, TransitionOut(TransitionTo::Dead), Active),
|
||||||
Transition(FIRST, TransitionOut(TransitionTo::Dead)),
|
Transition(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(FIRST, TransitionOut(TransitionTo::Dead)),
|
Update(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(FIRST, TransitionOut(TransitionTo::Dead))
|
Render(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// wait for transition to finish
|
// wait for transition to finish
|
||||||
|
@ -1036,7 +1036,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
Transition(FIRST, TransitionOut(TransitionTo::Dead)),
|
Transition(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(FIRST, TransitionOut(TransitionTo::Dead)),
|
Update(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(FIRST, TransitionOut(TransitionTo::Dead))
|
Render(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1075,7 +1075,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionIn, Pending),
|
StateChange(FIRST, TransitionIn, Pending),
|
||||||
Transition(FIRST, TransitionIn),
|
Transition(FIRST, TransitionIn),
|
||||||
Update(FIRST, TransitionIn),
|
Update(FIRST, TransitionIn),
|
||||||
Render(FIRST, TransitionIn)
|
Render(FIRST, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// first state finished transitioning in, now moves to active
|
// first state finished transitioning in, now moves to active
|
||||||
|
@ -1085,7 +1085,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(FIRST, Active, TransitionIn),
|
StateChange(FIRST, Active, TransitionIn),
|
||||||
Update(FIRST, Active),
|
Update(FIRST, Active),
|
||||||
Render(FIRST, Active)
|
Render(FIRST, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1101,7 +1101,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionOut(TransitionTo::Paused), Active),
|
StateChange(FIRST, TransitionOut(TransitionTo::Paused), Active),
|
||||||
Transition(FIRST, TransitionOut(TransitionTo::Paused)),
|
Transition(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
Update(FIRST, TransitionOut(TransitionTo::Paused)),
|
Update(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
Render(FIRST, TransitionOut(TransitionTo::Paused))
|
Render(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// state finished transitioning out, now is paused
|
// state finished transitioning out, now is paused
|
||||||
|
@ -1115,7 +1115,7 @@ mod tests {
|
||||||
StateChange(SECOND, TransitionIn, Pending),
|
StateChange(SECOND, TransitionIn, Pending),
|
||||||
Transition(SECOND, TransitionIn),
|
Transition(SECOND, TransitionIn),
|
||||||
Update(SECOND, TransitionIn),
|
Update(SECOND, TransitionIn),
|
||||||
Render(SECOND, TransitionIn)
|
Render(SECOND, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// second state finished transitioning in, now moves to active
|
// second state finished transitioning in, now moves to active
|
||||||
|
@ -1125,7 +1125,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(SECOND, Active, TransitionIn),
|
StateChange(SECOND, Active, TransitionIn),
|
||||||
Update(SECOND, Active),
|
Update(SECOND, Active),
|
||||||
Render(SECOND, Active)
|
Render(SECOND, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1141,7 +1141,7 @@ mod tests {
|
||||||
StateChange(SECOND, TransitionOut(TransitionTo::Dead), Active),
|
StateChange(SECOND, TransitionOut(TransitionTo::Dead), Active),
|
||||||
Transition(SECOND, TransitionOut(TransitionTo::Dead)),
|
Transition(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(SECOND, TransitionOut(TransitionTo::Dead)),
|
Update(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(SECOND, TransitionOut(TransitionTo::Dead))
|
Render(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// second state finished transitioning out, now dies.
|
// second state finished transitioning out, now dies.
|
||||||
|
@ -1151,7 +1151,7 @@ mod tests {
|
||||||
context.take_log(),
|
context.take_log(),
|
||||||
vec![
|
vec![
|
||||||
StateChange(SECOND, Dead, TransitionOut(TransitionTo::Dead)),
|
StateChange(SECOND, Dead, TransitionOut(TransitionTo::Dead)),
|
||||||
StateChange(FIRST, Dead, Paused)
|
StateChange(FIRST, Dead, Paused),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1187,7 +1187,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionIn, Pending),
|
StateChange(FIRST, TransitionIn, Pending),
|
||||||
Transition(FIRST, TransitionIn),
|
Transition(FIRST, TransitionIn),
|
||||||
Update(FIRST, TransitionIn),
|
Update(FIRST, TransitionIn),
|
||||||
Render(FIRST, TransitionIn)
|
Render(FIRST, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// first state finished transitioning in, now moves to active
|
// first state finished transitioning in, now moves to active
|
||||||
|
@ -1197,7 +1197,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(FIRST, Active, TransitionIn),
|
StateChange(FIRST, Active, TransitionIn),
|
||||||
Update(FIRST, Active),
|
Update(FIRST, Active),
|
||||||
Render(FIRST, Active)
|
Render(FIRST, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1213,7 +1213,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionOut(TransitionTo::Dead), Active),
|
StateChange(FIRST, TransitionOut(TransitionTo::Dead), Active),
|
||||||
Transition(FIRST, TransitionOut(TransitionTo::Dead)),
|
Transition(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(FIRST, TransitionOut(TransitionTo::Dead)),
|
Update(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(FIRST, TransitionOut(TransitionTo::Dead))
|
Render(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// first state finished transitioning out, now dies.
|
// first state finished transitioning out, now dies.
|
||||||
|
@ -1227,7 +1227,7 @@ mod tests {
|
||||||
StateChange(SECOND, TransitionIn, Pending),
|
StateChange(SECOND, TransitionIn, Pending),
|
||||||
Transition(SECOND, TransitionIn),
|
Transition(SECOND, TransitionIn),
|
||||||
Update(SECOND, TransitionIn),
|
Update(SECOND, TransitionIn),
|
||||||
Render(SECOND, TransitionIn)
|
Render(SECOND, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// second state finished transitioning in, now moves to active
|
// second state finished transitioning in, now moves to active
|
||||||
|
@ -1237,7 +1237,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(SECOND, Active, TransitionIn),
|
StateChange(SECOND, Active, TransitionIn),
|
||||||
Update(SECOND, Active),
|
Update(SECOND, Active),
|
||||||
Render(SECOND, Active)
|
Render(SECOND, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1252,7 +1252,7 @@ mod tests {
|
||||||
StateChange(SECOND, TransitionOut(TransitionTo::Dead), Active),
|
StateChange(SECOND, TransitionOut(TransitionTo::Dead), Active),
|
||||||
Transition(SECOND, TransitionOut(TransitionTo::Dead)),
|
Transition(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(SECOND, TransitionOut(TransitionTo::Dead)),
|
Update(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(SECOND, TransitionOut(TransitionTo::Dead))
|
Render(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// state finished transitioning out, now dies
|
// state finished transitioning out, now dies
|
||||||
|
@ -1279,7 +1279,7 @@ mod tests {
|
||||||
id,
|
id,
|
||||||
counter: 0,
|
counter: 0,
|
||||||
push_after,
|
push_after,
|
||||||
pop_after
|
pop_after,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1337,7 +1337,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionIn, Pending),
|
StateChange(FIRST, TransitionIn, Pending),
|
||||||
Transition(FIRST, TransitionIn),
|
Transition(FIRST, TransitionIn),
|
||||||
Update(FIRST, TransitionIn),
|
Update(FIRST, TransitionIn),
|
||||||
Render(FIRST, TransitionIn)
|
Render(FIRST, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// first state finished transitioning in, now moves to active
|
// first state finished transitioning in, now moves to active
|
||||||
|
@ -1347,7 +1347,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(FIRST, Active, TransitionIn),
|
StateChange(FIRST, Active, TransitionIn),
|
||||||
Update(FIRST, Active),
|
Update(FIRST, Active),
|
||||||
Render(FIRST, Active)
|
Render(FIRST, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// wait for first state's counter to count up to where it should push the second state
|
// wait for first state's counter to count up to where it should push the second state
|
||||||
|
@ -1357,7 +1357,7 @@ mod tests {
|
||||||
context.take_log(),
|
context.take_log(),
|
||||||
vec![
|
vec![
|
||||||
Update(FIRST, Active),
|
Update(FIRST, Active),
|
||||||
Render(FIRST, Active)
|
Render(FIRST, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1370,7 +1370,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionOut(TransitionTo::Paused), Active),
|
StateChange(FIRST, TransitionOut(TransitionTo::Paused), Active),
|
||||||
Transition(FIRST, TransitionOut(TransitionTo::Paused)),
|
Transition(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
Update(FIRST, TransitionOut(TransitionTo::Paused)),
|
Update(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
Render(FIRST, TransitionOut(TransitionTo::Paused))
|
Render(FIRST, TransitionOut(TransitionTo::Paused)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// first state finished transitioning out, now is paused. second state will transition in
|
// first state finished transitioning out, now is paused. second state will transition in
|
||||||
|
@ -1383,7 +1383,7 @@ mod tests {
|
||||||
StateChange(SECOND, TransitionIn, Pending),
|
StateChange(SECOND, TransitionIn, Pending),
|
||||||
Transition(SECOND, TransitionIn),
|
Transition(SECOND, TransitionIn),
|
||||||
Update(SECOND, TransitionIn),
|
Update(SECOND, TransitionIn),
|
||||||
Render(SECOND, TransitionIn)
|
Render(SECOND, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// second state finished transitioning in, now moves to active
|
// second state finished transitioning in, now moves to active
|
||||||
|
@ -1393,7 +1393,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(SECOND, Active, TransitionIn),
|
StateChange(SECOND, Active, TransitionIn),
|
||||||
Update(SECOND, Active),
|
Update(SECOND, Active),
|
||||||
Render(SECOND, Active)
|
Render(SECOND, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// wait for second state's counter to count up to where it should pop itself
|
// wait for second state's counter to count up to where it should pop itself
|
||||||
|
@ -1403,7 +1403,7 @@ mod tests {
|
||||||
context.take_log(),
|
context.take_log(),
|
||||||
vec![
|
vec![
|
||||||
Update(SECOND, Active),
|
Update(SECOND, Active),
|
||||||
Render(SECOND, Active)
|
Render(SECOND, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1416,7 +1416,7 @@ mod tests {
|
||||||
StateChange(SECOND, TransitionOut(TransitionTo::Dead), Active),
|
StateChange(SECOND, TransitionOut(TransitionTo::Dead), Active),
|
||||||
Transition(SECOND, TransitionOut(TransitionTo::Dead)),
|
Transition(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(SECOND, TransitionOut(TransitionTo::Dead)),
|
Update(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(SECOND, TransitionOut(TransitionTo::Dead))
|
Render(SECOND, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// second state finished transitioning out, now dies. first state wakes up again and
|
// second state finished transitioning out, now dies. first state wakes up again and
|
||||||
|
@ -1430,7 +1430,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionIn, Resume),
|
StateChange(FIRST, TransitionIn, Resume),
|
||||||
Transition(FIRST, TransitionIn),
|
Transition(FIRST, TransitionIn),
|
||||||
Update(FIRST, TransitionIn),
|
Update(FIRST, TransitionIn),
|
||||||
Render(FIRST, TransitionIn)
|
Render(FIRST, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// first state finished transitioning in, now moves to active
|
// first state finished transitioning in, now moves to active
|
||||||
|
@ -1440,7 +1440,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(FIRST, Active, TransitionIn),
|
StateChange(FIRST, Active, TransitionIn),
|
||||||
Update(FIRST, Active),
|
Update(FIRST, Active),
|
||||||
Render(FIRST, Active)
|
Render(FIRST, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// wait for first state's counter to count up to where it should pop itself
|
// wait for first state's counter to count up to where it should pop itself
|
||||||
|
@ -1450,7 +1450,7 @@ mod tests {
|
||||||
context.take_log(),
|
context.take_log(),
|
||||||
vec![
|
vec![
|
||||||
Update(FIRST, Active),
|
Update(FIRST, Active),
|
||||||
Render(FIRST, Active)
|
Render(FIRST, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1463,7 +1463,7 @@ mod tests {
|
||||||
StateChange(FIRST, TransitionOut(TransitionTo::Dead), Active),
|
StateChange(FIRST, TransitionOut(TransitionTo::Dead), Active),
|
||||||
Transition(FIRST, TransitionOut(TransitionTo::Dead)),
|
Transition(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(FIRST, TransitionOut(TransitionTo::Dead)),
|
Update(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(FIRST, TransitionOut(TransitionTo::Dead))
|
Render(FIRST, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// first state finished transitioning out, now dies
|
// first state finished transitioning out, now dies
|
||||||
|
@ -1499,7 +1499,7 @@ mod tests {
|
||||||
StateChange(FOO, TransitionIn, Pending),
|
StateChange(FOO, TransitionIn, Pending),
|
||||||
Transition(FOO, TransitionIn),
|
Transition(FOO, TransitionIn),
|
||||||
Update(FOO, TransitionIn),
|
Update(FOO, TransitionIn),
|
||||||
Render(FOO, TransitionIn)
|
Render(FOO, TransitionIn),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1513,7 +1513,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
StateChange(FOO, Active, TransitionIn),
|
StateChange(FOO, Active, TransitionIn),
|
||||||
Update(FOO, Active),
|
Update(FOO, Active),
|
||||||
Render(FOO, Active)
|
Render(FOO, Active),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1528,7 +1528,7 @@ mod tests {
|
||||||
StateChange(FOO, TransitionOut(TransitionTo::Dead), Active),
|
StateChange(FOO, TransitionOut(TransitionTo::Dead), Active),
|
||||||
Transition(FOO, TransitionOut(TransitionTo::Dead)),
|
Transition(FOO, TransitionOut(TransitionTo::Dead)),
|
||||||
Update(FOO, TransitionOut(TransitionTo::Dead)),
|
Update(FOO, TransitionOut(TransitionTo::Dead)),
|
||||||
Render(FOO, TransitionOut(TransitionTo::Dead))
|
Render(FOO, TransitionOut(TransitionTo::Dead)),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -146,15 +146,15 @@ impl From<sdl2::event::Event> for SystemEvent {
|
||||||
keycode: keycode.map(|keycode| keycode.into()),
|
keycode: keycode.map(|keycode| keycode.into()),
|
||||||
scancode: scancode.map(|scancode| scancode.into()),
|
scancode: scancode.map(|scancode| scancode.into()),
|
||||||
keymod: KeyModifiers::from_bits_truncate(keymod.bits()),
|
keymod: KeyModifiers::from_bits_truncate(keymod.bits()),
|
||||||
repeat
|
repeat,
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
sdl2::event::Event::KeyUp { keycode, scancode, keymod, repeat, .. } => {
|
sdl2::event::Event::KeyUp { keycode, scancode, keymod, repeat, .. } => {
|
||||||
SystemEvent::Keyboard(KeyboardEvent::KeyUp {
|
SystemEvent::Keyboard(KeyboardEvent::KeyUp {
|
||||||
keycode: keycode.map(|keycode| keycode.into()),
|
keycode: keycode.map(|keycode| keycode.into()),
|
||||||
scancode: scancode.map(|scancode| scancode.into()),
|
scancode: scancode.map(|scancode| scancode.into()),
|
||||||
keymod: KeyModifiers::from_bits_truncate(keymod.bits()),
|
keymod: KeyModifiers::from_bits_truncate(keymod.bits()),
|
||||||
repeat
|
repeat,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
sdl2::event::Event::MouseMotion { mousestate, x, y, xrel, yrel, .. } => {
|
sdl2::event::Event::MouseMotion { mousestate, x, y, xrel, yrel, .. } => {
|
||||||
|
@ -165,7 +165,7 @@ impl From<sdl2::event::Event> for SystemEvent {
|
||||||
y_delta: yrel,
|
y_delta: yrel,
|
||||||
buttons: MouseButtons::from_bits_truncate(mousestate.to_sdl_state()),
|
buttons: MouseButtons::from_bits_truncate(mousestate.to_sdl_state()),
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
sdl2::event::Event::MouseButtonDown { mouse_btn, clicks, x, y, .. } => {
|
sdl2::event::Event::MouseButtonDown { mouse_btn, clicks, x, y, .. } => {
|
||||||
SystemEvent::Mouse(MouseEvent::MouseButtonDown {
|
SystemEvent::Mouse(MouseEvent::MouseButtonDown {
|
||||||
x,
|
x,
|
||||||
|
@ -173,7 +173,7 @@ impl From<sdl2::event::Event> for SystemEvent {
|
||||||
clicks,
|
clicks,
|
||||||
button: mouse_btn.into(),
|
button: mouse_btn.into(),
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
sdl2::event::Event::MouseButtonUp { mouse_btn, clicks, x, y, .. } => {
|
sdl2::event::Event::MouseButtonUp { mouse_btn, clicks, x, y, .. } => {
|
||||||
SystemEvent::Mouse(MouseButtonUp {
|
SystemEvent::Mouse(MouseButtonUp {
|
||||||
x,
|
x,
|
||||||
|
@ -181,7 +181,7 @@ impl From<sdl2::event::Event> for SystemEvent {
|
||||||
clicks,
|
clicks,
|
||||||
button: mouse_btn.into(),
|
button: mouse_btn.into(),
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
|
|
||||||
_ => SystemEvent::Unimplemented,
|
_ => SystemEvent::Unimplemented,
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,22 +17,22 @@ const DEFAULT_MOUSE_CURSOR_HEIGHT: usize = 16;
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
const DEFAULT_MOUSE_CURSOR: [u8; DEFAULT_MOUSE_CURSOR_WIDTH * DEFAULT_MOUSE_CURSOR_HEIGHT] = [
|
const DEFAULT_MOUSE_CURSOR: [u8; DEFAULT_MOUSE_CURSOR_WIDTH * DEFAULT_MOUSE_CURSOR_HEIGHT] = [
|
||||||
0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0x00, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00,0x0f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0x00, 0x0f, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00,0x0f,0x0f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0x00, 0x0f, 0x0f, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00,0x0f,0x0f,0x0f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00,0x0f,0x0f,0x0f,0x0f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
|
0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00,0x0f,0x0f,0x0f,0x0f,0x0f,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
|
0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00,0x0f,0x0f,0x00,0x0f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0x00, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00,0x0f,0x00,0x00,0x00,0x0f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0x00, 0x0f, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00,0x00,0xff,0xff,0x00,0x0f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0x00, 0x00, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0xff,0xff,0xff,0xff,0xff,0x00,0x0f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0xff,0xff,0xff,0xff,0xff,0x00,0x0f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Holds the current state of the mouse.
|
/// Holds the current state of the mouse.
|
||||||
|
|
|
@ -41,12 +41,12 @@ fn is_x11_compositor_skipping_problematic() -> bool {
|
||||||
to check for this.
|
to check for this.
|
||||||
*/
|
*/
|
||||||
match std::env::consts::OS {
|
match std::env::consts::OS {
|
||||||
"linux"|"freebsd"|"netbsd"|"openbsd" => {
|
"linux" | "freebsd" | "netbsd" | "openbsd" => {
|
||||||
match std::env::var("XDG_SESSION_DESKTOP") {
|
match std::env::var("XDG_SESSION_DESKTOP") {
|
||||||
Ok(value) => value.eq_ignore_ascii_case("KDE"),
|
Ok(value) => value.eq_ignore_ascii_case("KDE"),
|
||||||
Err(_) => false
|
Err(_) => false
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ impl SystemBuilder {
|
||||||
"1"
|
"1"
|
||||||
} else {
|
} else {
|
||||||
"0"
|
"0"
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// build all the individual SDL subsystems
|
// build all the individual SDL subsystems
|
||||||
|
|
|
@ -202,7 +202,7 @@ impl LzwBytesWriter {
|
||||||
pub fn write_code<T: WriteBytesExt>(
|
pub fn write_code<T: WriteBytesExt>(
|
||||||
&mut self,
|
&mut self,
|
||||||
writer: &mut T,
|
writer: &mut T,
|
||||||
code: LzwCode
|
code: LzwCode,
|
||||||
) -> Result<(), LzwError> {
|
) -> Result<(), LzwError> {
|
||||||
self.packer.push_code(code)?;
|
self.packer.push_code(code)?;
|
||||||
|
|
||||||
|
@ -345,20 +345,20 @@ impl LzwBytesReader {
|
||||||
Ok(Some(reader.read_u8()?))
|
Ok(Some(reader.read_u8()?))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_code<T: ReadBytesExt> (
|
pub fn read_code<T: ReadBytesExt>(
|
||||||
&mut self,
|
&mut self,
|
||||||
reader: &mut T,
|
reader: &mut T,
|
||||||
) -> Result<Option<LzwCode>, LzwError> {
|
) -> Result<Option<LzwCode>, LzwError> {
|
||||||
loop {
|
loop {
|
||||||
if let Some(code) = self.unpacker.take_code() {
|
if let Some(code) = self.unpacker.take_code() {
|
||||||
return Ok(Some(code))
|
return Ok(Some(code));
|
||||||
} else {
|
} else {
|
||||||
match self.read_byte(reader) {
|
match self.read_byte(reader) {
|
||||||
Ok(Some(byte)) => self.unpacker.push_byte(byte)?,
|
Ok(Some(byte)) => self.unpacker.push_byte(byte)?,
|
||||||
Ok(None) => return Ok(None),
|
Ok(None) => return Ok(None),
|
||||||
Err(LzwError::IOError(error)) if error.kind() == std::io::ErrorKind::UnexpectedEof => {
|
Err(LzwError::IOError(error)) if error.kind() == std::io::ErrorKind::UnexpectedEof => {
|
||||||
return Ok(None)
|
return Ok(None);
|
||||||
},
|
}
|
||||||
Err(error) => return Err(error),
|
Err(error) => return Err(error),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -371,9 +371,9 @@ impl LzwBytesReader {
|
||||||
pub fn lzw_encode<S, D>(
|
pub fn lzw_encode<S, D>(
|
||||||
src: &mut S,
|
src: &mut S,
|
||||||
dest: &mut D,
|
dest: &mut D,
|
||||||
min_code_size: usize
|
min_code_size: usize,
|
||||||
) -> Result<(), LzwError>
|
) -> Result<(), LzwError>
|
||||||
where
|
where
|
||||||
S: ReadBytesExt,
|
S: ReadBytesExt,
|
||||||
D: WriteBytesExt
|
D: WriteBytesExt
|
||||||
{
|
{
|
||||||
|
@ -413,7 +413,7 @@ where
|
||||||
writer.write_code(dest, end_of_info_code)?;
|
writer.write_code(dest, end_of_info_code)?;
|
||||||
writer.flush(dest)?;
|
writer.flush(dest)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
},
|
}
|
||||||
Err(error) => return Err(LzwError::IOError(error))
|
Err(error) => return Err(LzwError::IOError(error))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ pub fn lzw_decode<S, D>(
|
||||||
src: &mut S,
|
src: &mut S,
|
||||||
dest: &mut D,
|
dest: &mut D,
|
||||||
) -> Result<(), LzwError>
|
) -> Result<(), LzwError>
|
||||||
where
|
where
|
||||||
S: ReadBytesExt,
|
S: ReadBytesExt,
|
||||||
D: WriteBytesExt
|
D: WriteBytesExt
|
||||||
{
|
{
|
||||||
|
@ -581,7 +581,7 @@ where
|
||||||
current_bit_size = min_code_size + 1;
|
current_bit_size = min_code_size + 1;
|
||||||
reader.reset_bit_size();
|
reader.reset_bit_size();
|
||||||
break 'inner;
|
break 'inner;
|
||||||
},
|
}
|
||||||
Some(code) => code,
|
Some(code) => code,
|
||||||
None => return Err(LzwError::EncodingError(String::from("Unexpected end of code stream"))),
|
None => return Err(LzwError::EncodingError(String::from("Unexpected end of code stream"))),
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@ enum PackMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pack_bits<S, D>(src: &mut S, dest: &mut D, src_length: usize) -> Result<(), PackBitsError>
|
pub fn pack_bits<S, D>(src: &mut S, dest: &mut D, src_length: usize) -> Result<(), PackBitsError>
|
||||||
where
|
where
|
||||||
S: ReadBytesExt,
|
S: ReadBytesExt,
|
||||||
D: WriteBytesExt,
|
D: WriteBytesExt,
|
||||||
{
|
{
|
||||||
|
@ -117,7 +117,7 @@ pub fn unpack_bits<S, D>(
|
||||||
dest: &mut D,
|
dest: &mut D,
|
||||||
unpacked_length: usize,
|
unpacked_length: usize,
|
||||||
) -> Result<(), PackBitsError>
|
) -> Result<(), PackBitsError>
|
||||||
where
|
where
|
||||||
S: ReadBytesExt,
|
S: ReadBytesExt,
|
||||||
D: WriteBytesExt,
|
D: WriteBytesExt,
|
||||||
{
|
{
|
||||||
|
|
|
@ -114,10 +114,10 @@ fn pixel_drawing() {
|
||||||
//////
|
//////
|
||||||
|
|
||||||
for i in 0..10 {
|
for i in 0..10 {
|
||||||
screen.set_pixel(5-i, 100, 15);
|
screen.set_pixel(5 - i, 100, 15);
|
||||||
screen.set_pixel(i+314, 100, 15);
|
screen.set_pixel(i + 314, 100, 15);
|
||||||
screen.set_pixel(160, 5-i, 15);
|
screen.set_pixel(160, 5 - i, 15);
|
||||||
screen.set_pixel(160, i+234, 15);
|
screen.set_pixel(160, i + 234, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = Path::new("tests/ref/pixel_drawing.pcx");
|
let path = Path::new("tests/ref/pixel_drawing.pcx");
|
||||||
|
@ -130,19 +130,19 @@ fn blended_pixel_drawing() {
|
||||||
let (mut screen, palette, blend_map) = setup_for_blending();
|
let (mut screen, palette, blend_map) = setup_for_blending();
|
||||||
|
|
||||||
for i in 0..10 {
|
for i in 0..10 {
|
||||||
screen.set_blended_pixel(0+i, 0+i, 1, &blend_map);
|
screen.set_blended_pixel(0 + i, 0 + i, 1, &blend_map);
|
||||||
screen.set_blended_pixel(319-i, 0+i, 2, &blend_map);
|
screen.set_blended_pixel(319 - i, 0 + i, 2, &blend_map);
|
||||||
screen.set_blended_pixel(0+i, 239-i, 3, &blend_map);
|
screen.set_blended_pixel(0 + i, 239 - i, 3, &blend_map);
|
||||||
screen.set_blended_pixel(319-i, 239-i, 4, &blend_map);
|
screen.set_blended_pixel(319 - i, 239 - i, 4, &blend_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
|
||||||
for i in 0..10 {
|
for i in 0..10 {
|
||||||
screen.set_blended_pixel(5-i, 100, 15, &blend_map);
|
screen.set_blended_pixel(5 - i, 100, 15, &blend_map);
|
||||||
screen.set_blended_pixel(i+314, 100, 15, &blend_map);
|
screen.set_blended_pixel(i + 314, 100, 15, &blend_map);
|
||||||
screen.set_blended_pixel(160, 5-i, 15, &blend_map);
|
screen.set_blended_pixel(160, 5 - i, 15, &blend_map);
|
||||||
screen.set_blended_pixel(160, i+234, 15, &blend_map);
|
screen.set_blended_pixel(160, i + 234, 15, &blend_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = Path::new("tests/ref/blended_pixel_drawing.pcx");
|
let path = Path::new("tests/ref/blended_pixel_drawing.pcx");
|
||||||
|
@ -521,11 +521,11 @@ fn generate_bitmap(width: i32, height: i32) -> Bitmap {
|
||||||
let mut bitmap = Bitmap::new(width as u32, height as u32).unwrap();
|
let mut bitmap = Bitmap::new(width as u32, height as u32).unwrap();
|
||||||
|
|
||||||
bitmap.filled_rect(0, 0, x_third, y_third, 1);
|
bitmap.filled_rect(0, 0, x_third, y_third, 1);
|
||||||
bitmap.filled_rect(x_third*2+1, y_third*2+1, width-1, height-1, 2);
|
bitmap.filled_rect(x_third * 2 + 1, y_third * 2 + 1, width - 1, height - 1, 2);
|
||||||
bitmap.filled_rect(0, y_third*2+1, x_third, height-1, 3);
|
bitmap.filled_rect(0, y_third * 2 + 1, x_third, height - 1, 3);
|
||||||
bitmap.filled_rect(x_third*2+1, 0, width-1, y_third, 4);
|
bitmap.filled_rect(x_third * 2 + 1, 0, width - 1, y_third, 4);
|
||||||
bitmap.filled_rect(x_third, y_third, x_third*2+1, y_third*2+1, 5);
|
bitmap.filled_rect(x_third, y_third, x_third * 2 + 1, y_third * 2 + 1, 5);
|
||||||
bitmap.rect(0, 0, width-1, height-1, 6);
|
bitmap.rect(0, 0, width - 1, height - 1, 6);
|
||||||
|
|
||||||
bitmap
|
bitmap
|
||||||
}
|
}
|
||||||
|
@ -542,18 +542,18 @@ fn solid_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::Solid, &bmp16, x+16, y+48);
|
screen.blit(BlitMethod::Solid, &bmp16, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::Solid, &bmp12, x+80, y+48);
|
screen.blit(BlitMethod::Solid, &bmp12, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::Solid, &bmp21, x+144, y+48);
|
screen.blit(BlitMethod::Solid, &bmp21, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::Solid, &bmp3, x+208, y+48);
|
screen.blit(BlitMethod::Solid, &bmp3, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::Solid, &bmp16, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::Solid, &bmp16, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::Solid, &bmp12, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::Solid, &bmp12, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::Solid, &bmp21, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::Solid, &bmp21, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::Solid, &bmp3, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::Solid, &bmp3, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -607,18 +607,18 @@ fn blended_solid_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp16, x+16, y+48);
|
screen.blit(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp16, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp12, x+80, y+48);
|
screen.blit(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp12, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp21, x+144, y+48);
|
screen.blit(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp21, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp3, x+208, y+48);
|
screen.blit(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp3, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp16, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp16, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp12, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp12, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp21, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp21, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp3, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::SolidBlended { blend_map: blend_map.clone() }, &bmp3, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -669,18 +669,18 @@ fn solid_flipped_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::SolidFlipped { horizontal_flip: false, vertical_flip: false }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::SolidFlipped { horizontal_flip: false, vertical_flip: false }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::SolidFlipped { horizontal_flip: true, vertical_flip: false }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::SolidFlipped { horizontal_flip: true, vertical_flip: false }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::SolidFlipped { horizontal_flip: false, vertical_flip: true }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::SolidFlipped { horizontal_flip: false, vertical_flip: true }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::SolidFlipped { horizontal_flip: true, vertical_flip: true }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::SolidFlipped { horizontal_flip: true, vertical_flip: true }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::SolidFlipped { horizontal_flip: false, vertical_flip: false }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::SolidFlipped { horizontal_flip: false, vertical_flip: false }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidFlipped { horizontal_flip: true, vertical_flip: false }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::SolidFlipped { horizontal_flip: true, vertical_flip: false }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidFlipped { horizontal_flip: false, vertical_flip: true }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::SolidFlipped { horizontal_flip: false, vertical_flip: true }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidFlipped { horizontal_flip: true, vertical_flip: true }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::SolidFlipped { horizontal_flip: true, vertical_flip: true }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -731,18 +731,18 @@ fn blended_solid_flipped_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::SolidFlippedBlended { horizontal_flip: false, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::SolidFlippedBlended { horizontal_flip: false, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::SolidFlippedBlended { horizontal_flip: true, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::SolidFlippedBlended { horizontal_flip: true, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::SolidFlippedBlended { horizontal_flip: false, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::SolidFlippedBlended { horizontal_flip: false, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidFlippedBlended { horizontal_flip: true, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::SolidFlippedBlended { horizontal_flip: true, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -793,18 +793,18 @@ fn solid_offset_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::SolidOffset(0), &bmp, x+16, y+48);
|
screen.blit(BlitMethod::SolidOffset(0), &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::SolidOffset(4), &bmp, x+80, y+48);
|
screen.blit(BlitMethod::SolidOffset(4), &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::SolidOffset(7), &bmp, x+144, y+48);
|
screen.blit(BlitMethod::SolidOffset(7), &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::SolidOffset(13), &bmp, x+208, y+48);
|
screen.blit(BlitMethod::SolidOffset(13), &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::SolidOffset(0), &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::SolidOffset(0), &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidOffset(4), &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::SolidOffset(4), &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidOffset(7), &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::SolidOffset(7), &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidOffset(13), &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::SolidOffset(13), &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -855,18 +855,18 @@ fn solid_flipped_offset_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::SolidFlippedOffset { offset: 0, horizontal_flip: false, vertical_flip: false }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::SolidFlippedOffset { offset: 0, horizontal_flip: false, vertical_flip: false }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::SolidFlippedOffset { offset: 4, horizontal_flip: true, vertical_flip: false }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::SolidFlippedOffset { offset: 4, horizontal_flip: true, vertical_flip: false }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::SolidFlippedOffset { offset: 7, horizontal_flip: false, vertical_flip: true }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::SolidFlippedOffset { offset: 7, horizontal_flip: false, vertical_flip: true }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::SolidFlippedOffset { offset: 13, horizontal_flip: true, vertical_flip: true }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::SolidFlippedOffset { offset: 13, horizontal_flip: true, vertical_flip: true }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::SolidFlippedOffset { offset: 0, horizontal_flip: false, vertical_flip: false }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::SolidFlippedOffset { offset: 0, horizontal_flip: false, vertical_flip: false }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidFlippedOffset { offset: 4, horizontal_flip: true, vertical_flip: false }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::SolidFlippedOffset { offset: 4, horizontal_flip: true, vertical_flip: false }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidFlippedOffset { offset: 7, horizontal_flip: false, vertical_flip: true }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::SolidFlippedOffset { offset: 7, horizontal_flip: false, vertical_flip: true }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::SolidFlippedOffset { offset: 13, horizontal_flip: true, vertical_flip: true }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::SolidFlippedOffset { offset: 13, horizontal_flip: true, vertical_flip: true }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -920,18 +920,18 @@ fn transparent_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::Transparent(0), &bmp16, x+16, y+48);
|
screen.blit(BlitMethod::Transparent(0), &bmp16, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::Transparent(0), &bmp12, x+80, y+48);
|
screen.blit(BlitMethod::Transparent(0), &bmp12, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::Transparent(0), &bmp21, x+144, y+48);
|
screen.blit(BlitMethod::Transparent(0), &bmp21, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::Transparent(0), &bmp3, x+208, y+48);
|
screen.blit(BlitMethod::Transparent(0), &bmp3, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::Transparent(0), &bmp16, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::Transparent(0), &bmp16, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::Transparent(0), &bmp12, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::Transparent(0), &bmp12, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::Transparent(0), &bmp21, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::Transparent(0), &bmp21, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::Transparent(0), &bmp3, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::Transparent(0), &bmp3, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -985,18 +985,18 @@ fn blended_transparent_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp16, x+16, y+48);
|
screen.blit(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp16, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp12, x+80, y+48);
|
screen.blit(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp12, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp21, x+144, y+48);
|
screen.blit(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp21, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp3, x+208, y+48);
|
screen.blit(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp3, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp16, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp16, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp12, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp12, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp21, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp21, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp3, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentBlended { transparent_color: 0, blend_map: blend_map.clone() }, &bmp3, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -1047,18 +1047,18 @@ fn transparent_flipped_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: false, vertical_flip: false }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: false, vertical_flip: false }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: true, vertical_flip: false }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: true, vertical_flip: false }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: false, vertical_flip: true }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: false, vertical_flip: true }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: true, vertical_flip: true }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: true, vertical_flip: true }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: false, vertical_flip: false }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: false, vertical_flip: false }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: true, vertical_flip: false }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: true, vertical_flip: false }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: false, vertical_flip: true }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: false, vertical_flip: true }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: true, vertical_flip: true }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlipped { transparent_color: 0, horizontal_flip: true, vertical_flip: true }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -1109,18 +1109,18 @@ fn blended_transparent_flipped_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: false, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: false, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: true, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: true, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: false, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: false, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: true, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: true, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: false, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: false, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: true, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: true, vertical_flip: false, blend_map: blend_map.clone() }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: false, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: false, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: true, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlippedBlended { transparent_color: 0, horizontal_flip: true, vertical_flip: true, blend_map: blend_map.clone() }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -1171,18 +1171,18 @@ fn transparent_offset_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::TransparentOffset { transparent_color: 0, offset: 0 }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::TransparentOffset { transparent_color: 0, offset: 0 }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentOffset { transparent_color: 0, offset: 4 }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::TransparentOffset { transparent_color: 0, offset: 4 }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentOffset { transparent_color: 0, offset: 7 }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::TransparentOffset { transparent_color: 0, offset: 7 }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentOffset { transparent_color: 0, offset: 13 }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::TransparentOffset { transparent_color: 0, offset: 13 }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::TransparentOffset { transparent_color: 0, offset: 0 }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentOffset { transparent_color: 0, offset: 0 }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentOffset { transparent_color: 0, offset: 4 }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentOffset { transparent_color: 0, offset: 4 }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentOffset { transparent_color: 0, offset: 7 }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentOffset { transparent_color: 0, offset: 7 }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentOffset { transparent_color: 0, offset: 13 }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentOffset { transparent_color: 0, offset: 13 }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -1233,18 +1233,18 @@ fn transparent_flipped_offset_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 0, horizontal_flip: false, vertical_flip: false }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 0, horizontal_flip: false, vertical_flip: false }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 4, horizontal_flip: true, vertical_flip: false }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 4, horizontal_flip: true, vertical_flip: false }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 7, horizontal_flip: false, vertical_flip: true }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 7, horizontal_flip: false, vertical_flip: true }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 13, horizontal_flip: true, vertical_flip: true }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 13, horizontal_flip: true, vertical_flip: true }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 0, horizontal_flip: false, vertical_flip: false }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 0, horizontal_flip: false, vertical_flip: false }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 4, horizontal_flip: true, vertical_flip: false }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 4, horizontal_flip: true, vertical_flip: false }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 7, horizontal_flip: false, vertical_flip: true }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 7, horizontal_flip: false, vertical_flip: true }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 13, horizontal_flip: true, vertical_flip: true }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlippedOffset { transparent_color: 0, offset: 13, horizontal_flip: true, vertical_flip: true }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -1295,18 +1295,18 @@ fn transparent_single_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 1 }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 1 }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 4 }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 4 }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 7 }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 7 }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 13 }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 13 }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 1 }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 1 }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 4 }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 4 }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 7 }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 7 }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 13 }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentSingle { transparent_color: 0, draw_color: 13 }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -1357,18 +1357,18 @@ fn transparent_flipped_single_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 1, horizontal_flip: false, vertical_flip: false }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 1, horizontal_flip: false, vertical_flip: false }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 4, horizontal_flip: true, vertical_flip: false }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 4, horizontal_flip: true, vertical_flip: false }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 7, horizontal_flip: false, vertical_flip: true }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 7, horizontal_flip: false, vertical_flip: true }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 13, horizontal_flip: true, vertical_flip: true }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 13, horizontal_flip: true, vertical_flip: true }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 1, horizontal_flip: false, vertical_flip: false }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 1, horizontal_flip: false, vertical_flip: false }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 4, horizontal_flip: true, vertical_flip: false }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 4, horizontal_flip: true, vertical_flip: false }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 7, horizontal_flip: false, vertical_flip: true }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 7, horizontal_flip: false, vertical_flip: true }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 13, horizontal_flip: true, vertical_flip: true }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::TransparentFlippedSingle { transparent_color: 0, draw_color: 13, horizontal_flip: true, vertical_flip: true }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -1419,18 +1419,18 @@ fn rotozoom_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::RotoZoom { angle: 1.3, scale_x: 1.0, scale_y: 1.0 }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::RotoZoom { angle: 1.3, scale_x: 1.0, scale_y: 1.0 }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoom { angle: 0.3, scale_x: 1.5, scale_y: 1.0 }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::RotoZoom { angle: 0.3, scale_x: 1.5, scale_y: 1.0 }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoom { angle: 0.6, scale_x: 1.0, scale_y: 1.5 }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::RotoZoom { angle: 0.6, scale_x: 1.0, scale_y: 1.5 }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoom { angle: 2.0, scale_x: 0.7, scale_y: 0.7 }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::RotoZoom { angle: 2.0, scale_x: 0.7, scale_y: 0.7 }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoom { angle: 1.3, scale_x: 1.0, scale_y: 1.0 }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoom { angle: 1.3, scale_x: 1.0, scale_y: 1.0 }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoom { angle: 0.3, scale_x: 1.5, scale_y: 1.0 }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoom { angle: 0.3, scale_x: 1.5, scale_y: 1.0 }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoom { angle: 0.6, scale_x: 1.0, scale_y: 1.5 }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoom { angle: 0.6, scale_x: 1.0, scale_y: 1.5 }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoom { angle: 2.0, scale_x: 0.7, scale_y: 0.7 }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoom { angle: 2.0, scale_x: 0.7, scale_y: 0.7 }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -1481,18 +1481,18 @@ fn blended_rotozoom_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomBlended { angle: 0.3, scale_x: 1.5, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::RotoZoomBlended { angle: 0.3, scale_x: 1.5, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomBlended { angle: 0.6, scale_x: 1.0, scale_y: 1.5, blend_map: blend_map.clone() }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::RotoZoomBlended { angle: 0.6, scale_x: 1.0, scale_y: 1.5, blend_map: blend_map.clone() }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomBlended { angle: 2.0, scale_x: 0.7, scale_y: 0.7, blend_map: blend_map.clone() }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::RotoZoomBlended { angle: 2.0, scale_x: 0.7, scale_y: 0.7, blend_map: blend_map.clone() }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomBlended { angle: 0.3, scale_x: 1.5, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomBlended { angle: 0.3, scale_x: 1.5, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomBlended { angle: 0.6, scale_x: 1.0, scale_y: 1.5, blend_map: blend_map.clone() }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomBlended { angle: 0.6, scale_x: 1.0, scale_y: 1.5, blend_map: blend_map.clone() }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomBlended { angle: 2.0, scale_x: 0.7, scale_y: 0.7, blend_map: blend_map.clone() }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomBlended { angle: 2.0, scale_x: 0.7, scale_y: 0.7, blend_map: blend_map.clone() }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -1543,18 +1543,18 @@ fn rotozoom_offset_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::RotoZoomOffset { angle: 1.3, scale_x: 1.0, scale_y: 1.0, offset: 0 }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::RotoZoomOffset { angle: 1.3, scale_x: 1.0, scale_y: 1.0, offset: 0 }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomOffset { angle: 0.3, scale_x: 1.5, scale_y: 1.0, offset: 4 }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::RotoZoomOffset { angle: 0.3, scale_x: 1.5, scale_y: 1.0, offset: 4 }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomOffset { angle: 0.6, scale_x: 1.0, scale_y: 1.5, offset: 7 }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::RotoZoomOffset { angle: 0.6, scale_x: 1.0, scale_y: 1.5, offset: 7 }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomOffset { angle: 2.0, scale_x: 0.7, scale_y: 0.7, offset: 13 }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::RotoZoomOffset { angle: 2.0, scale_x: 0.7, scale_y: 0.7, offset: 13 }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomOffset { angle: 1.3, scale_x: 1.0, scale_y: 1.0, offset: 0 }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomOffset { angle: 1.3, scale_x: 1.0, scale_y: 1.0, offset: 0 }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomOffset { angle: 0.3, scale_x: 1.5, scale_y: 1.0, offset: 4 }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomOffset { angle: 0.3, scale_x: 1.5, scale_y: 1.0, offset: 4 }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomOffset { angle: 0.6, scale_x: 1.0, scale_y: 1.5, offset: 7 }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomOffset { angle: 0.6, scale_x: 1.0, scale_y: 1.5, offset: 7 }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomOffset { angle: 2.0, scale_x: 0.7, scale_y: 0.7, offset: 13 }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomOffset { angle: 2.0, scale_x: 0.7, scale_y: 0.7, offset: 13 }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -1605,18 +1605,18 @@ fn rotozoom_transparent_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 1.3, scale_x: 1.0, scale_y: 1.0 }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 1.3, scale_x: 1.0, scale_y: 1.0 }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 0.3, scale_x: 1.5, scale_y: 1.0 }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 0.3, scale_x: 1.5, scale_y: 1.0 }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 0.6, scale_x: 1.0, scale_y: 1.5 }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 0.6, scale_x: 1.0, scale_y: 1.5 }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 2.0, scale_x: 0.7, scale_y: 0.7 }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 2.0, scale_x: 0.7, scale_y: 0.7 }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 1.3, scale_x: 1.0, scale_y: 1.0 }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 1.3, scale_x: 1.0, scale_y: 1.0 }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 0.3, scale_x: 1.5, scale_y: 1.0 }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 0.3, scale_x: 1.5, scale_y: 1.0 }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 0.6, scale_x: 1.0, scale_y: 1.5 }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 0.6, scale_x: 1.0, scale_y: 1.5 }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 2.0, scale_x: 0.7, scale_y: 0.7 }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomTransparent { transparent_color: 0, angle: 2.0, scale_x: 0.7, scale_y: 0.7 }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -1667,18 +1667,18 @@ fn blended_rotozoom_transparent_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 0.3, scale_x: 1.5, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 0.3, scale_x: 1.5, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 0.6, scale_x: 1.0, scale_y: 1.5, blend_map: blend_map.clone() }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 0.6, scale_x: 1.0, scale_y: 1.5, blend_map: blend_map.clone() }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 2.0, scale_x: 0.7, scale_y: 0.7, blend_map: blend_map.clone() }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 2.0, scale_x: 0.7, scale_y: 0.7, blend_map: blend_map.clone() }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 0.3, scale_x: 1.5, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 0.3, scale_x: 1.5, scale_y: 1.0, blend_map: blend_map.clone() }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 0.6, scale_x: 1.0, scale_y: 1.5, blend_map: blend_map.clone() }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 0.6, scale_x: 1.0, scale_y: 1.5, blend_map: blend_map.clone() }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 2.0, scale_x: 0.7, scale_y: 0.7, blend_map: blend_map.clone() }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomTransparentBlended { transparent_color: 0, angle: 2.0, scale_x: 0.7, scale_y: 0.7, blend_map: blend_map.clone() }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
@ -1729,18 +1729,18 @@ fn rotozoom_transparent_offset_blits() {
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 20;
|
let y = 20;
|
||||||
screen.blit(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 1, angle: 1.3, scale_x: 1.0, scale_y: 1.0 }, &bmp, x+16, y+48);
|
screen.blit(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 1, angle: 1.3, scale_x: 1.0, scale_y: 1.0 }, &bmp, x + 16, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 4, angle: 0.3, scale_x: 1.5, scale_y: 1.0 }, &bmp, x+80, y+48);
|
screen.blit(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 4, angle: 0.3, scale_x: 1.5, scale_y: 1.0 }, &bmp, x + 80, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 7, angle: 0.6, scale_x: 1.0, scale_y: 1.5 }, &bmp, x+144, y+48);
|
screen.blit(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 7, angle: 0.6, scale_x: 1.0, scale_y: 1.5 }, &bmp, x + 144, y + 48);
|
||||||
screen.blit(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 13, angle: 2.0, scale_x: 0.7, scale_y: 0.7 }, &bmp, x+208, y+48);
|
screen.blit(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 13, angle: 2.0, scale_x: 0.7, scale_y: 0.7 }, &bmp, x + 208, y + 48);
|
||||||
|
|
||||||
let x = 40;
|
let x = 40;
|
||||||
let y = 110;
|
let y = 110;
|
||||||
unsafe {
|
unsafe {
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 1, angle: 1.3, scale_x: 1.0, scale_y: 1.0 }, &bmp, x+16, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 1, angle: 1.3, scale_x: 1.0, scale_y: 1.0 }, &bmp, x + 16, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 4, angle: 0.3, scale_x: 1.5, scale_y: 1.0 }, &bmp, x+80, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 4, angle: 0.3, scale_x: 1.5, scale_y: 1.0 }, &bmp, x + 80, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 7, angle: 0.6, scale_x: 1.0, scale_y: 1.5 }, &bmp, x+144, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 7, angle: 0.6, scale_x: 1.0, scale_y: 1.5 }, &bmp, x + 144, y + 48);
|
||||||
screen.blit_unchecked(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 13, angle: 2.0, scale_x: 0.7, scale_y: 0.7 }, &bmp, x+208, y+48);
|
screen.blit_unchecked(BlitMethod::RotoZoomTransparentOffset { transparent_color: 0, offset: 13, angle: 2.0, scale_x: 0.7, scale_y: 0.7 }, &bmp, x + 208, y + 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
|
Loading…
Reference in a new issue