-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d691309
commit c41cc79
Showing
120 changed files
with
467 additions
and
150 deletions.
There are no files selected for viewing
This file contains 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
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/* |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
24 changes: 0 additions & 24 deletions
24
app/src/androidTest/java/nstv/sheep/ExampleInstrumentedTest.kt
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
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 | ||
} |
This file contains 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
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 | ||
) | ||
} |
Oops, something went wrong.