Questions tagged [android-jetpack-compose-canvas]

79 questions
2
votes
1 answer

Unable to find minus() of Path in Jetpack Compose

I am trying to use this minus extension function of Path in Jetpack Compose code. But I am getting an unresolved reference error. Code @Composable fun PathDiff() { Canvas( modifier = Modifier .fillMaxSize(), ) { …
2
votes
1 answer

Jetpack compose Canvas blendmode not working as expected

I'm attempting to apply blend mode to two shapes within Jetpack compose's canvas. Based on this blog I know roughly what the expected output should look like though I am not getting similar results. For example, with the following simple Box +…
2
votes
2 answers

Convert flutter painter to compose

I have code in flutter and I have to write an app in android (kotlin). How can I convert flutter painter to display in android compose? import 'dart:math' as math; import 'dart:ui' as ui; import 'package:flutter/material.dart'; class FaceOutline…
2
votes
1 answer

Jetpack Compose watermark or write on Bitmap with androidx.compose.ui.graphics.Canvas?

With androidx.compose.foundation.Canvas, default Canvas for Jetpack Compose, or Spacer with Modifier.drawBehind{} under the hood @Composable fun Canvas(modifier: Modifier, onDraw: DrawScope.() -> Unit) = …
Thracian
  • 43,021
  • 16
  • 133
  • 222
2
votes
1 answer

How to create HSL saturation and lightness change gradient or brush editor with Jetpack Compose?

I'm building a Color picker with Jetpack Compose and trying to implement Saturation and Lightness picker rhombus(rectangle rotated 45 degrees) as can be seen in images but couldn't able to find a good method to display colors as they supposed to…
2
votes
2 answers

How to convert dp values to x and y float values for Corner radius?

I'm creating dashed rectangle with 12 dp corner radius. I'm using canvas for that. In that we can't give corner radius in dp or px. Canvas(modifier = Modifier.fillMaxSize()) { drawRoundRect(color = Color.Red, style = stroke,…
1
vote
1 answer

Android Compose - Why is drawText in Canvas being cut off at bottom but not at top?

I'm relatively new to Android Compose and as a project, I'm trying to design a bar graph. Gathering various examples, I'm now trying to design the axes in a Canvas composable with a DrawScope. Once I've drawn the lines, my next task was to create…
1
vote
2 answers

Gradient Line color in jetpack compose

I want to draw gradient line in jetpack compose. I tried some code but it was not correct as my expected. Expected Output Actual Output Code @Preview(showBackground = true) @Composable fun DrawTimeLine() { Column(Modifier.fillMaxSize()) { …
1
vote
0 answers

Avoid Multiple Canvas view overlap each other in jetpack compose

I am building a timeline view. I have a list which is coming server. I just mocked 4 items on the list to show the view possibilities. The problem is having that my canvas view is overlap to each other. If I used the background color, it overlaps…
1
vote
1 answer

How to use IntrinsicSize.Min with canvas in jetpack compose

I am following the document of Intrinsics. I want to wrap the canvas view. I want to use canvas into multiple times because I want to make timeline view. So drawing in the canvas is everything works…
1
vote
1 answer

How to draw item with padding in jetpack compose

I am drawing Circle and Text on Canvas in jetpack compose. I draw it without any problem through coordinate of Canvas. When I place the circle on start side of Text it too far away. It look like this way I tried this piece of…
1
vote
1 answer

How to draw text in Jetpack compose at the center of another object?

I am trying to draw text inside a circle in Jetpack Compose. I drew the circle with the center being the center of the canvas. Now I want to draw text exactly at the center of the circle. The drawText function inside the canvas in Jetpack compose…
1
vote
1 answer

Flow pulse animation in jetpack compose

I want to build flow pulse animation. I build something similar to that but that one is not accurate what I want for my requirement. I want something like this library. @Composable fun PulseView() { val infiniteTransition =…
1
vote
0 answers

Preview not working on using canvas in jetpack compose

I am working Canvas and I tried to draw image on canvas but it not showing me on preview window. @Preview(showBackground = true) @Composable fun DrawImagePreview() { val vector = ImageVector.vectorResource(id = R.drawable.xyz) val…
1
vote
1 answer

How to draw an image inside a drawable with its boundaries limited to that drawable with compose

After a lot of research and tries, I decided to ask you for some help. I have 2 drawables that I'd like to merge into one. The one going on top should be limited to the shape of the one behind. This is what I've come up with but for some reason, the…