This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> | |
| <title>Picker 教程 - 分步学习</title> | |
| <style> | |
| * { margin: 0; padding: 0; box-sizing: border-box; } | |
| body { | |
| font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 定义角落数据类 | |
| private data class Corner(val x: Float, val y: Float) | |
| // 智能计算目标角落的函数 | |
| private fun calculateTargetCorner( | |
| currentX: Float, | |
| currentY: Float, | |
| velocityX: Float, | |
| velocityY: Float, | |
| pipWidth: Float, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.yourpackage // 替换成你的包名 | |
| import android.Manifest | |
| import android.content.Context | |
| import android.graphics.Bitmap | |
| import android.graphics.BitmapFactory | |
| import android.graphics.Matrix | |
| import android.util.Log | |
| import android.view.ViewGroup | |
| import androidx.camera.core.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Preview | |
| @Composable | |
| fun TextSpringWithVelocity() { | |
| val animatedY = remember { Animatable(0f) } | |
| // Spring animation spec | |
| val springSpec = spring<Float>( | |
| dampingRatio = 0.5f, // You can adjust the damping ratio for bounce | |
| stiffness = 200f // You can adjust stiffness for speed of movement | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Preview | |
| @Composable | |
| fun PreviewColorSlider() { | |
| Box(modifier = Modifier | |
| .fillMaxSize() | |
| .background(Color.Black)) | |
| val colors = listOf(Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White,Color.White.copy(0.4f), Color.White, ) | |
| ColorSlider( | |
| modifier = Modifier |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Preview | |
| @Composable | |
| fun ListIcon() { | |
| val density = LocalDensity.current | |
| var offsetX by remember { mutableStateOf(0f) } | |
| var offsetY by remember { mutableStateOf(0f) } | |
| val circlePositions = remember { mutableStateListOf<Offset>() } | |
| var enlargedCircleIndex by remember { mutableStateOf(-1) } | |
| // 添加计算相邻缩放的函数 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val MetaballShader = """ | |
| uniform float2 resolution; | |
| uniform shader image; | |
| uniform float time; | |
| half4 main(vec2 fragCoord) { | |
| float2 uv = fragCoord/resolution.xy; | |
| float aspect = resolution.x/resolution.y; | |
| float2 adjustedUV = float2(uv.x * aspect - aspect*0.5, uv.y - 0.5); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private val runtimeShader = """ | |
| uniform shader image; | |
| uniform float2 resolution; | |
| uniform float rectWidth; | |
| uniform float rectHeight; | |
| uniform float intensity; | |
| uniform int tonemap; | |
| half4 main(float2 coord) { | |
| float2 uv = coord.xy / resolution; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val p3Colors = listOf( | |
| Color( | |
| red = 1.0f, | |
| green = 0.247f, | |
| blue = 0.612f, | |
| colorSpace = ColorSpaces.DisplayP3 | |
| ), | |
| Color( | |
| red = 0.117f, | |
| green = 0.251f, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private val runtimeShader = """ | |
| uniform shader image; | |
| uniform float2 resolution; | |
| uniform float rectWidth; | |
| uniform float rectHeight; | |
| uniform float intensity; | |
| uniform int tonemap; | |
| half4 main(float2 coord) { | |
| float2 uv = coord.xy / resolution; |
NewerOlder