Skip to content

Commit

Permalink
Sheep Fluff
Browse files Browse the repository at this point in the history
  • Loading branch information
nicole-terc committed May 21, 2022
1 parent d691309 commit c41cc79
Show file tree
Hide file tree
Showing 120 changed files with 467 additions and 150 deletions.
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/
.idea
.DS_Store
/build
/build/
/*/build/
/captures
.externalNativeBuild
.cxx
local.properties
/app/release/
.idea/*
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

21 changes: 0 additions & 21 deletions .idea/gradle.xml

This file was deleted.

16 changes: 0 additions & 16 deletions .idea/misc.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

6 changes: 4 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = ModuleExtension.jvmTarget
Expand Down Expand Up @@ -68,4 +68,6 @@ dependencies {
kapt(libs.jetpack.lifecycle.compiler)
kapt(libs.hilt.compiler)
kapt(libs.room.compiler)

debugImplementation(libs.debug.compose.ui.tooling)
}
24 changes: 0 additions & 24 deletions app/src/androidTest/java/nstv/sheep/ExampleInstrumentedTest.kt

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.ComposableSheepAnimations">
<activity
android:name=".MainActivity"
android:name=".ui.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.ComposableSheepAnimations">
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/nstv/sheep/SheepApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ package nstv.sheep

import android.app.Application


class SheepApplication : Application() {
}
class SheepApplication : Application()
20 changes: 20 additions & 0 deletions app/src/main/java/nstv/sheep/sheep/FluffStyle.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package nstv.sheep.sheep

const val MinAnglePercentage = 10.0
const val MaxAnglePercentage = 20.0

sealed interface FluffStyle {
class Uniform(val numberOfFluffChunks: Int) : FluffStyle

class UniformIntervals(
val percentageIntervals: List<Double> = listOf(
MinAnglePercentage,
MaxAnglePercentage
)
) : FluffStyle

class Random(
val minPercentage: Double = MinAnglePercentage,
val maxPercentage: Double = MaxAnglePercentage
) : FluffStyle
}
44 changes: 44 additions & 0 deletions app/src/main/java/nstv/sheep/sheep/Sheep.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package nstv.sheep.sheep

import kotlin.random.Random

data class Sheep(
val fluffStyle: FluffStyle,
val fluffChunksPercentages: List<Double> = getFluffPercentages(fluffStyle = fluffStyle)
)

private fun getFluffPercentages(
fluffStyle: FluffStyle,
totalPercentage: Double = 100.0
): List<Double> {
val angleChunks: MutableList<Double> = mutableListOf()

var currentSum = 0.0
while (currentSum < totalPercentage) {
var angleChunk = getNextAngleChunkPercentage(
fluffStyle = fluffStyle,
totalPercentage = totalPercentage,
index = angleChunks.size
)
if (currentSum + angleChunk > totalPercentage) {
angleChunk = totalPercentage - currentSum
}
angleChunks.add(angleChunk)
currentSum += angleChunk
}
return angleChunks
}

private fun getNextAngleChunkPercentage(
fluffStyle: FluffStyle,
totalPercentage: Double,
index: Int
): Double =
when (fluffStyle) {
is FluffStyle.Uniform -> totalPercentage.div(fluffStyle.numberOfFluffChunks)
is FluffStyle.UniformIntervals -> fluffStyle.percentageIntervals[index.mod(fluffStyle.percentageIntervals.size)]
is FluffStyle.Random -> Random.nextDouble(
fluffStyle.minPercentage,
fluffStyle.maxPercentage
)
}
Loading

0 comments on commit c41cc79

Please sign in to comment.