Preview
Loading GPUI
Props
Install
cargo add evilbuttonsUsage
use evilbuttons::EvilEyeButton;
use gpui::rgb;
EvilEyeButton::new("watcher").eye_color(rgb(0x38bdf8))Props
EvilEyeButton is a GPUI RenderOnce builder; its eye state is keyed by id. Every eye prop can change between renders without resetting the eye.
| Method | Type | Default | Description |
|---|---|---|---|
new(id) | impl Into<ElementId> | - | Unique id for the eye state. |
label(s) | impl Into<SharedString> | "I see you" | Label, shown uppercase. |
eye_color(c) | impl Into<Hsla> | #ff6f37 | Iris, glow, and hairline color. |
intensity(v) | f32 | 1.3 | Brightness of the flames. |
pupil_size(v) | f32 | 0.62 | Size of the slit pupil. Lower values make it tighter. |
iris_width(v) | f32 | 0.22 | Width of the iris ring. |
glow_intensity(v) | f32 | 0.5 | Strength of the glow around the iris. |
scale(v) | f32 | 1.7 | Size of the eye in the button. Higher values spread the flames wider. |
noise_scale(v) | f32 | 0.8 | Scale of the flame noise. |
pupil_follow(v) | f32 | 0.8 | How far the pupil tracks the cursor, 0 to 1. |
flame_speed(v) | f32 | 0.8 | Speed of the flames. |
blink(bool) | bool | true | Blink every few seconds on its own. It always blinks on press. |
font_family(family) | impl Into<SharedString> | inherited | Font family for the label. |
on_click(f) | Fn(&ClickEvent, &mut Window, &mut App) | - | Fired on click. |
disabled(bool) | bool | false | Dims the button and ignores input. |
Good to know
- Ported from React Bits'
EvilEyeshader. GPUI has no custom shaders, so the same shader maths and noise texture run on the CPU each frame and are painted as small gradient strips (1px across, 2px down), which keeps the flames sharp at a reasonable cost. - The pupil follows the cursor across the whole window.
- The label's soft eye-coloured glow is approximated with a blurred shadow behind the text, since GPUI has no text shadows.