Agsl
No description available
Install / Use
/learn @tbahlai/AgslREADME
AGSL Shaders in Jetpack Compose 🎨
This repository contains the source code for my ProAndroidDev article about exploring AGSL (Android Graphics Shading Language) within Jetpack Compose. It demonstrates how to implement complex mathematical fractals and dynamic backgrounds with high performance.
🚀 Overview
The project showcases three distinct types of shaders:
- Mandelbrot Set: Focuses on coordinate mapping, zooming, and panning on the complex plane.
- Interactive Julia Set: Demonstrates real-time user interaction by linking touch coordinates to shader parameters.
- Animated Background: A practical UI application showing how to create smooth, animated gradients using shaders.
Mandelbrot Set
A classic fractal rendered using the escape-time algorithm.
Performance: Optimized using Modifier.drawWithCache and RuntimeShader caching. Interaction: Supports Pinch-to-Zoom and Panning via TransformableState. Note: Uses a multi-stage color palette for smooth aesthetic transitions.
<img src="screenshots/Mandelbrot-Set.gif" width="360" height="800" alt="Mandelbrot Set" />Interactive Julia Set
Unlike Mandelbrot, the Julia set changes its entire shape based on a constant c.
Real-time Input: The c constant is mapped to the user's touch/drag position. Optimized Drawing: Static uniforms (colors, size) are separated from dynamic inputs (mouse position) to minimize GPU overhead.
<img src="screenshots/Julia-Set.gif" width="360" height="800" alt="Interactive Julia Set" />Animated Background
A practical example of how shaders can replace heavy video backgrounds or complex drawable animations.
Algorithm: Combines multiple sine waves and a radial spotlight effect. Reusable Modifier: Implemented as a custom Modifier.animatedBackground() that can be easily dropped into any Compose project.
<img src="screenshots/Animated-Background.gif" width="360" height="800" alt="Animated Background" />📖 Article
You can find the detailed walkthrough and explanation of this code on my ProAndroidDev profile.
⚙️ Requirements
Android 13 (API 33) or higher (Required for AGSL).
Jetpack Compose 1.4.0+.
Related Skills
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
