Skip to content

Instantly share code, notes, and snippets.

View Skaldebane's full-sized avatar
💻
Coding thingys...

Houssam Elbadissi Skaldebane

💻
Coding thingys...
View GitHub Profile
@Skaldebane
Skaldebane / AngledSweepGradient.kt
Created October 12, 2023 07:49
AngledSweepGradient Android
import android.graphics.SweepGradient
import android.os.Build
import androidx.annotation.VisibleForTesting
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.Stable
import androidx.compose.ui.geometry.*
import androidx.compose.ui.graphics.*
import androidx.compose.ui.util.fastForEachIndexed
import androidx.core.graphics.transform
@Skaldebane
Skaldebane / AngledSweepGradient.android.kt
Last active October 19, 2023 14:06
AngledSweepGradient - Sweep gradient implementation for Compose with a customizable start angle
import android.graphics.SweepGradient
import android.os.Build
import androidx.annotation.VisibleForTesting
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.Stable
import androidx.compose.ui.geometry.*
import androidx.compose.ui.graphics.*
import androidx.compose.ui.util.fastForEachIndexed
import androidx.core.graphics.transform
@Skaldebane
Skaldebane / index.css
Created October 6, 2023 01:50
CSS - Animated Border Colors with Conic Gradients [Works on Firefox™]
html { font-family: sans-serif }
.top {
width: 196px;
height: 46px;
margin: 2px;
position: absolute;
top: 0;
left: 0;
right: 0;
@Skaldebane
Skaldebane / AnimationInPopup.kt
Last active March 5, 2023 11:24
Popup with Show/Hide animations. Read comment for more details.
/**
* This popup uses two hacks:
* 1. Deferring the AnimatedVisibility's `visible` state: If `AnimatedVisibility` enters the composition
* with `visible = true` by default, it won't animate. So I work around that by setting it to a state defaulting to
* `false`, then instantly switch it to `true` during composition by means of a `LaunchedEffect`.
*
* 2. Deferring the Popup's hiding until the animation is complete: When we set `show = false`, the `Popup` leaves
* the composition immediately, so the exit animation isn't shown. To work around this, I set the aforementioned
* internal state of the AnimatedVisibility to `false` first (which will start the exit animation), then set
* `show = false` once the exit animation is finished by means of a `DisposableEffect`, whose `onDispose` lambda
@Skaldebane
Skaldebane / IntegerToText.kt
Created August 18, 2022 00:48
Small Kotlin helper function for converting a number to its textual representation, with a heavily functional approach.
fun main() {
while (true) {
val number = input("Number: ").toIntOrNull()
if (number != null)
println(number.getName())
else
println("Invalid Number!")
}
}
@Skaldebane
Skaldebane / main.kt
Created May 23, 2021 15:40
Initial testing for a font viewer for desktop, using Jetpack Compose - Skaldebane.
import androidx.compose.desktop.Window
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle