-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
6444b03
commit 247fde7
Showing
17 changed files
with
457 additions
and
123 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
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
29 changes: 29 additions & 0 deletions
29
shared/src/androidMain/kotlin/com/toasterofbread/spmp/widget/component/GlanceCanvas.kt
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,29 @@ | ||
package com.toasterofbread.spmp.widget.component | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.geometry.Size | ||
import androidx.compose.ui.graphics.Canvas | ||
import androidx.compose.ui.graphics.ImageBitmap | ||
import androidx.compose.ui.graphics.asAndroidBitmap | ||
import androidx.compose.ui.platform.LocalDensity | ||
import androidx.compose.ui.unit.DpSize | ||
import androidx.glance.GlanceModifier | ||
import androidx.glance.Image | ||
import androidx.glance.ImageProvider | ||
|
||
@Composable | ||
fun GlanceCanvas(size: DpSize, modifier: GlanceModifier, draw: @Composable Canvas.(Size) -> Unit) { | ||
val image: ImageBitmap = | ||
with (LocalDensity.current) { | ||
ImageBitmap(size.width.roundToPx(), size.height.roundToPx()) | ||
} | ||
|
||
val canvas: Canvas = Canvas(image) | ||
draw(canvas, Size(image.width.toFloat(), image.height.toFloat())) | ||
|
||
Image( | ||
ImageProvider(image.asAndroidBitmap()), | ||
null, | ||
modifier | ||
) | ||
} |
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
Oops, something went wrong.