Skip to content

Conversation

Copy link

Copilot AI commented Dec 16, 2025

Implements a warp speed starfield animation simulating the view from a spaceship window, with three interactive states: cruise (slow-moving points), warp (high-speed streaks), and deceleration.

Implementation

New package: hyperspace/

  • HyperspaceState - Sealed class for animation states
  • Star - Data class with 3D position (x,y,z), velocity, size, color
  • HyperspaceAnimation - Canvas composable rendering 200 stars with depth perspective
  • HyperspacePage - Demo page with state control buttons

Animation mechanics:

  • Stars spawn at screen center, move radially outward
  • Cruise: 1x speed, rendered as points
  • Warp: 15x speed, rendered as lines (dynamic trail length up to 80px)
  • State transitions use animateFloatAsState with configurable easing (1.5s acceleration, 3s deceleration)
  • Continuous redraw via LaunchedEffect + withFrameNanos
  • Stars reset when off-screen for object reuse

Visual effects:

// 3D perspective projection
val scale = 1f / star.z
val screenPos = Offset(
    centerX + (star.x - centerX) * scale,
    centerY + (star.y - centerY) * scale
)

// Dynamic rendering based on speed
if (trailLength > 10f) {
    drawLine(start = prevPos, end = currentPos) // Warp streaks
    drawCircle(center = currentPos)             // Bright endpoint
} else {
    drawCircle(center = currentPos)             // Cruise mode
}

Integration:

  • Added HyperspacePage ID to ids.xml
  • Added navigation button on HomePage
  • Bilingual UI (Chinese/English)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.2.1-all/d8pvvlun5bx6sdtwqhf8y9z4b/gradle-8.2.1/lib/gradle-launcher-8.2.1.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.2.1-all/d8pvvlun5bx6sdtwqhf8y9z4b/gradle-8.2.1/lib/agents/gradle-instrumentation-agent-8.2.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.2.1 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

需求描述

在 sample 模块中实现一个超光速飞行动画效果,模拟星际飞船从舷窗观察星空的视觉效果。使用 Jetpack Compose Canvas 实现。

动画状态

动画需要支持三个状态的平滑过渡:

1. 巡航状态 (Cruise Mode)

  • 代表恒星的光点从屏幕中心向四周缓慢移动
  • 屏幕中心区域持续生成新的光点
  • 光点大小可以有细微变化,模拟不同距离的恒星
  • 移动速度较慢,营造平静的太空巡航感

2. 超光速飞行状态 (Hyperspace/Warp Mode)

  • 光点拉伸成不同长度的线条(星轨效果)
  • 线条从屏幕中心向四周飞速划过
  • 速度大幅提升,线条长度根据速度动态变化
  • 营造强烈的速度感和冲击力

3. 减速回到巡航状态 (Deceleration)

  • 线条速度逐渐降低
  • 线条长度逐渐缩短,平滑过渡回光点形态
  • 最终恢复到巡航状态

技术要求

  1. 使用 Jetpack Compose Canvas 绘制动画
  2. 性能优化:合理管理星星数量,避免过度绘制
  3. 状态管理:使用 Compose State 管理动画状态
  4. 可配置性:提供参数配置星星数量、颜色、速度等
  5. 平滑过渡:状态之间的切换需要平滑动画过渡

实现建议

  1. 创建 Star 数据类存储每个星星的属性(位置、速度、大小等)
  2. 创建 HyperspaceState 枚举或 sealed class 表示动画状态
  3. 创建 HyperspaceAnimation Composable 组件
  4. 在 sample 模块中添加演示页面,提供按钮切换状态

文件位置

sample/src/main/java/ 目录下创建相关文件,可以新建一个 hyperspace 包存放相关代码。

参考效果

类似科幻电影中飞船进入超光速时的星空拉伸效果(如《星球大战》、《星际迷航》中的 warp speed 效果)。

This pull request was created as a result of the following prompt from Copilot chat.

需求描述

在 sample 模块中实现一个超光速飞行动画效果,模拟星际飞船从舷窗观察星空的视觉效果。使用 Jetpack Compose Canvas 实现。

动画状态

动画需要支持三个状态的平滑过渡:

1. 巡航状态 (Cruise Mode)

  • 代表恒星的光点从屏幕中心向四周缓慢移动
  • 屏幕中心区域持续生成新的光点
  • 光点大小可以有细微变化,模拟不同距离的恒星
  • 移动速度较慢,营造平静的太空巡航感

2. 超光速飞行状态 (Hyperspace/Warp Mode)

  • 光点拉伸成不同长度的线条(星轨效果)
  • 线条从屏幕中心向四周飞速划过
  • 速度大幅提升,线条长度根据速度动态变化
  • 营造强烈的速度感和冲击力

3. 减速回到巡航状态 (Deceleration)

  • 线条速度逐渐降低
  • 线条长度逐渐缩短,平滑过渡回光点形态
  • 最终恢复到巡航状态

技术要求

  1. 使用 Jetpack Compose Canvas 绘制动画
  2. 性能优化:合理管理星星数量,避免过度绘制
  3. 状态管理:使用 Compose State 管理动画状态
  4. 可配置性:提供参数配置星星数量、颜色、速度等
  5. 平滑过渡:状态之间的切换需要平滑动画过渡

实现建议

  1. 创建 Star 数据类存储每个星星的属性(位置、速度、大小等)
  2. 创建 HyperspaceState 枚举或 sealed class 表示动画状态
  3. 创建 HyperspaceAnimation Composable 组件
  4. 在 sample 模块中添加演示页面,提供按钮切换状态

文件位置

sample/src/main/java/ 目录下创建相关文件,可以新建一个 hyperspace 包存放相关代码。

参考效果

类似科幻电影中飞船进入超光速时的星空拉伸效果(如《星球大战》、《星际迷航》中的 warp speed 效果)。


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 16, 2025 15:54
…fect

Co-authored-by: Modificator <3425930+Modificator@users.noreply.github.com>
…d spacing

Co-authored-by: Modificator <3425930+Modificator@users.noreply.github.com>
Copilot AI changed the title [WIP] Add hyperspace flight animation in sample module Add hyperspace animation with Canvas-based starfield effect Dec 16, 2025
Copilot AI requested a review from Modificator December 16, 2025 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants