Skip to content

giphy support #55

@lemurxvulcan

Description

@lemurxvulcan

Feature Request: GIF → ASCII Animation Widget (Giphy Integration)

Summary

Add a widget that fetches GIFs from Giphy, converts frames into ASCII (or terminal-friendly characters), and animates them inside the TUI.

Motivation

This would allow dynamic visual content inside the app while maintaining terminal compatibility. Animated ASCII provides a lightweight, cross-platform way to display media without graphics support.

Use cases:
• Visual feedback or status animations
• Fun or expressive terminal UI elements
• Attention-grabbing content in dashboards or feeds

Proposed Functionality

  1. Giphy Fetch
    • Query Giphy API using a search term or trending endpoint
    • Support:
    • search(query)
    • trending()
    • optional random mode
    • Configurable API key via env variable:

GIPHY_API_KEY

  1. GIF Frame Processing
    • Download GIF
    • Decode into frames
    • Resize to fit widget bounds
    • Convert frames to grayscale
    • Map brightness → ASCII charset

Example charset gradient:

" .:-=+*#%@"

Optional modes:
• ASCII grayscale
• Block characters
• Braille patterns for higher resolution

  1. Animation Engine
    • Render frames sequentially in the widget
    • Respect GIF frame delays
    • Loop animation
    • Allow pause/resume

  2. Widget Behavior
    • Automatically scale to widget size
    • Maintain aspect ratio
    • Support refresh and new search queries

Widget API (proposed)

AsciiGifWidget::new()
.query("cats")
.mode(GifMode::Search)
.charset(Charset::Standard)
.looping(true)
.build();

UI Example

+----------------------------------+
| (=^・ω・^=) |
| /| |\ |
| | ASCII CAT GIF | |
| _______/ |
+----------------------------------+

Implementation Notes

Crates to consider
• reqwest → HTTP requests
• gif or image → decoding GIF frames
• ratatui → rendering frames
• tokio → async fetching & frame timing

Frame conversion flow
1. Fetch GIF
2. Decode frames
3. Resize to widget dimensions
4. Convert pixels → luminance
5. Map luminance → ASCII chars
6. Render frame buffer
7. Sleep for frame delay
8. Repeat

Performance Considerations
• Cache downloaded GIFs
• Limit max resolution to prevent terminal slowdown
• Allow configurable FPS cap
• Use incremental redraws to reduce flicker

Configuration Options

Option Description
max_width frame width cap
fps_limit animation speed limit
charset ASCII mapping style
invert invert brightness mapping
cache enable local caching

Future Enhancements
• Support local GIF files
• Inline emoji mode
• Colorized ANSI rendering
• Multiple concurrent animations
• WebP/APNG support

Acceptance Criteria
• Widget displays animated ASCII GIF
• Giphy search works via API key
• Animation timing matches source frames
• Widget resizes correctly
• No significant flicker during playback

References
https://developers.giphy.com/docs/api/
• ASCII luminance mapping techniques
• ratatui widget rendering patterns

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions