Easing point highlight alpha

macos-click-through
Jon Valdés 5 years ago
parent 028c36d32a
commit 5c6d1ffa42

@ -1,6 +1,7 @@
use skulpin::skia_safe::{BlendMode, Canvas, Color, Paint, Point, Rect, paint::Style}; use skulpin::skia_safe::{paint::Style, BlendMode, Canvas, Color, Paint, Point, Rect};
use crate::editor::{Colors, Cursor}; use crate::editor::{Colors, Cursor};
use super::animation_utils::*;
pub trait CursorVFX { pub trait CursorVFX {
fn update(&mut self, current_cursor_destination: Point, dt: f32) -> bool; fn update(&mut self, current_cursor_destination: Point, dt: f32) -> bool;
@ -50,11 +51,10 @@ impl CursorVFX for PointHighlight {
paint.set_blend_mode(BlendMode::SrcOver); paint.set_blend_mode(BlendMode::SrcOver);
let base_color: Color = cursor.background(&colors).to_color(); let base_color: Color = cursor.background(&colors).to_color();
let alpha = ((1.0 - self.t) * 255.0) as u8; let alpha = ease(ease_in_quad, 255.0, 0.0, self.t) as u8;
let color = Color::from_argb(alpha, base_color.r(), base_color.g(), base_color.b()); let color = Color::from_argb(alpha, base_color.r(), base_color.g(), base_color.b());
paint.set_color(color); paint.set_color(color);
let size = 3.0 * font_size.1; let size = 3.0 * font_size.1;
let radius = self.t * size; let radius = self.t * size;
let hr = radius * 0.5; let hr = radius * 0.5;
@ -67,20 +67,18 @@ impl CursorVFX for PointHighlight {
match self.mode { match self.mode {
HighlightMode::SonicBoom => { HighlightMode::SonicBoom => {
canvas.draw_oval(&rect, &paint); canvas.draw_oval(&rect, &paint);
}, }
HighlightMode::Ripple => { HighlightMode::Ripple => {
paint.set_style(Style::Stroke); paint.set_style(Style::Stroke);
paint.set_stroke_width(font_size.1 * 0.2); paint.set_stroke_width(font_size.1 * 0.2);
canvas.draw_oval(&rect, &paint); canvas.draw_oval(&rect, &paint);
}, }
HighlightMode::Wireframe => { HighlightMode::Wireframe => {
paint.set_style(Style::Stroke); paint.set_style(Style::Stroke);
paint.set_stroke_width(font_size.1 * 0.2); paint.set_stroke_width(font_size.1 * 0.2);
canvas.draw_rect(&rect, &paint); canvas.draw_rect(&rect, &paint);
},
} }
}
} }
} }

Loading…
Cancel
Save