Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 52daebd

Browse files
committed
the brush effect!
1 parent 8ed2f0f commit 52daebd

File tree

4 files changed

+32
-27
lines changed

4 files changed

+32
-27
lines changed

‎app/src/main/java/dev/baseio/composeplayground/MainActivity.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class MainActivity : ComponentActivity() {
7474
GlowingRingLoader(Modifier.align(Alignment.Center))
7575
}
7676
}
77-
0 -> {
77+
6 -> {
7878
Box(Modifier.fillMaxSize()) {
7979
YahooWeatherAndSun(Modifier.align(Alignment.Center))
8080
}
@@ -93,7 +93,7 @@ class MainActivity : ComponentActivity() {
9393
14 -> {
9494
ShootingStarsAnimation()
9595
}
96-
6 -> {
96+
0 -> {
9797
NetflixIntroAnimation()
9898
}
9999
11 -> {

‎app/src/main/java/dev/baseio/composeplayground/ui/animations/ChatMessageReactions.kt‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fun ChatMessageReactions(modifier: Modifier) {
6060

6161
}
6262

63-
Column(horizontalAlignment = Alignment.CenterHorizontally){
63+
Column(horizontalAlignment = Alignment.CenterHorizontally){
6464
Button(onClick = {
6565
isShowReaction = !isShowReaction
6666
}) {
@@ -141,7 +141,8 @@ fun ChatMessageReactions(modifier: Modifier) {
141141
Box(
142142
modifier = Modifier
143143
.fillMaxWidth()
144-
.height(200.dp).background(MaterialTheme.colors.background)
144+
.height(200.dp)
145+
.background(MaterialTheme.colors.background)
145146
) {
146147
AnmolVerma(Modifier.align(Alignment.Center))
147148
}
@@ -150,13 +151,13 @@ fun ChatMessageReactions(modifier: Modifier) {
150151
}
151152

152153
@Composable
153-
privatefun bottom() = TransformOrigin(0.5f, 1f)
154+
fun bottom() = TransformOrigin(0.5f, 1f)
154155

155156
@Composable
156-
privatefun bottomTrailing() = TransformOrigin(1f, 1f)
157+
fun bottomTrailing() = TransformOrigin(1f, 1f)
157158

158159
@Composable
159-
privatefun bottomLeading() = TransformOrigin(0.5f, 1f)
160+
fun bottomLeading() = TransformOrigin(0.5f, 1f)
160161

161162
@Composable
162-
privatefun topTrailing() = TransformOrigin(1f, 0f)
163+
fun topTrailing() = TransformOrigin(1f, 0f)

‎app/src/main/java/dev/baseio/composeplayground/ui/animations/NetFlixIntroAnimation.kt‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import androidx.compose.ui.unit.times
1919
import dev.baseio.composeplayground.contributors.AnmolVerma
2020
import dev.baseio.composeplayground.ui.animations.netflixanim.EffectBrush
2121
import dev.baseio.composeplayground.ui.animations.netflixanim.EffectLumieres
22-
import kotlinx.coroutines.delay
2322
import kotlinx.coroutines.launch
2423

2524
val baseColor = Color(0xffe40913)
@@ -177,22 +176,22 @@ fun NetflixIntro(modifier: Modifier) {
177176
.rotate(180f)
178177
.background(fadingLumieresBox.value),
179178
brushMovingbrush1,
180-
showingLumieres,nWidth
179+
showingLumieres,nWidth
181180
)
182181

183182
EffectBrushTwo(
184183
modifier = Modifier
185184
.fillMaxWidth(0.19f)
186185
.fillMaxHeight()
187186
.offset(x = (57.8 / 100).times(nWidth), y = 0.dp)
188-
.rotate(180f), brushMovingbrush2
187+
.rotate(180f), brushMovingbrush2,nWidth
189188
)
190189
EffectBrushThree(
191190
modifier = Modifier
192191
.fillMaxWidth(0.19f)
193192
.fillMaxHeight(1.5f)
194193
.offset(x = (40.5 / 100).times(nWidth), y = (-25 / 100).times(nHeight))
195-
.rotate(-19.5f), brushMovingbrush3
194+
.rotate(-19.5f), brushMovingbrush3,nWidth
196195
)
197196
}
198197

@@ -202,18 +201,20 @@ fun NetflixIntro(modifier: Modifier) {
202201
@Composable
203202
fun EffectBrushTwo(
204203
modifier: Modifier,
205-
brushMovingbrush: Animatable<Float, AnimationVector1D>
204+
brushMovingbrush: Animatable<Float, AnimationVector1D>,
205+
nWidth: Dp
206206
) {
207-
EffectBrush(brushMovingbrush, modifier)
207+
EffectBrush(brushMovingbrush, modifier, nWidth)
208208
}
209209

210210

211211
@Composable
212212
fun EffectBrushThree(
213213
modifier: Modifier,
214-
brushMoving: Animatable<Float, AnimationVector1D>
214+
brushMoving: Animatable<Float, AnimationVector1D>,
215+
nWidth: Dp
215216
) {
216-
EffectBrush(brushMoving, modifier)
217+
EffectBrush(brushMoving, modifier,nWidth)
217218
}
218219

219220
@Composable
@@ -223,13 +224,13 @@ fun EffectBrushOne(
223224
showingLumieres: Animatable<Float, AnimationVector1D>,
224225
nWidth: Dp
225226
) {
226-
EffectBrush(brushMoving, modifier)
227-
228-
EffectLumieres(
229-
showingLumieres,Modifier
230-
.fillMaxWidth(0.195f)
231-
.fillMaxHeight()
232-
.offset(x = (22.4 / 100).times(nWidth), y = 0.dp)
233-
)
227+
EffectBrush(brushMoving, modifier, nWidth)
228+
229+
EffectLumieres(
230+
showingLumieres,Modifier
231+
.fillMaxWidth(0.195f)
232+
.fillMaxHeight()
233+
.offset(x = (22.4 / 100).times(nWidth), y = 0.dp)
234+
)
234235
}
235236

‎app/src/main/java/dev/baseio/composeplayground/ui/animations/netflixanim/EffectBrush.kt‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import kotlin.random.Random
2525
@Composable
2626
fun EffectBrush(
2727
brushMoving: Animatable<Float, AnimationVector1D>,
28-
modifier: Modifier
28+
modifier: Modifier,
29+
nWidth: Dp
2930
) {
3031

3132
val brushList by remember {
@@ -40,10 +41,12 @@ fun EffectBrush(
4041
) {
4142
repeat(brushList.size) {
4243
val brushFur = brushList[it]
43-
44+
val xOffset =
45+
(brushFur.left / 100).times(LocalDensity.current.run { nWidth.toPx().times(0.19f) })
4446
Box(
4547
modifier = Modifier
46-
.fillMaxWidth()
48+
.width(LocalDensity.current.run { brushFur.width.toDp() })
49+
.offset { IntOffset(xOffset.toInt(), 0) }
4750
.fillMaxHeight()
4851
.graphicsLayer(translationY = brushMoving.value.times(height.div(100)))
4952
.background(brushFur.background)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /