Wajahat Karim

    2 years ago
    Hey folks! I am trying to draw a
    in the Canvas. I can only see methods like
    etc, but there's no method for either bitmap drawing (like I get bitmap from VectorDrawable) or directly for
    . I did tried it using the the vector path in form of string like in this example ( from @Jorge Castillo . But, I am not able to fill color inside the path with this method. I want to fill the whole drawable from inside. Can anyone tell me how can I do this?
    Jorge Castillo

    Jorge Castillo

    2 years ago
    There are probably other ways but if you've got the path you can draw path and use a paint with fill style so it fills the content. There are examples about that on that repository also
    Nader Jawad

    Nader Jawad

    2 years ago
    ImageAsset is Compose's Bitmap API. So DrawScope.drawImage should be what you would use there. If you have an object you can call asImageAsset to convert to the compose API
    If you have a VectorPainter (fully resolved VectorDrawable) and you want to draw it within a DrawScope you can just call vectorPainter.draw within a DrawScope receiver scope. You could get a DrawScope receiver scope in various ways either through Modifier.drawBehind or as the trailing lambda in the Canvas composable