Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageVector is blurry when used with Image() + Modifier.scale() #4872

Closed
alexstyl opened this issue May 25, 2024 · 2 comments
Closed

ImageVector is blurry when used with Image() + Modifier.scale() #4872

alexstyl opened this issue May 25, 2024 · 2 comments
Labels
bug Something isn't working submitted

Comments

@alexstyl
Copy link

alexstyl commented May 25, 2024

Describe the bug

When I use an Image holding an ImageVector and I scale it say x4, the end result is a blurry image instead of a scrip one.

Code:

Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
        Row {
            Image(Add, null, Modifier.scale(1f))
            Spacer(Modifier.width(40.dp))
            Image(Add, null, Modifier.scale(4f))
        }
    }

Affected platforms
I tried on Desktop

Versions

  • Libraries:
    • Compose Multiplatform version: 1.6.10

Screenshots

image

Additional context
ImageVector I used:

val Add: ImageVector by lazy {
    ImageVector.Builder(name = "add", defaultWidth = 40.0.dp, defaultHeight = 40.0.dp, viewportWidth = 40.0f, viewportHeight = 40.0f).apply {
        path(fill = SolidColor(Color(0xFF212121)), fillAlpha = 1f, stroke = null, strokeAlpha = 1f, strokeLineWidth = 1.0f, strokeLineCap = StrokeCap.Butt, strokeLineJoin = StrokeJoin.Miter, strokeLineMiter = 1f, pathFillType = PathFillType.NonZero) {
            moveTo(20f, 31.458f)
            quadToRelative(-0.542f, 0f, -0.917f, -0.396f)
            quadToRelative(-0.375f, -0.395f, -0.375f, -0.937f)
            verticalLineToRelative(-8.833f)
            horizontalLineTo(9.875f)
            quadToRelative(-0.583f, 0f, -0.958f, -0.375f)
            reflectiveQuadTo(8.542f, 20f)
            quadToRelative(0f, -0.583f, 0.375f, -0.958f)
            reflectiveQuadToRelative(0.958f, -0.375f)
            horizontalLineToRelative(8.833f)
            verticalLineTo(9.833f)
            quadToRelative(0f, -0.541f, 0.375f, -0.916f)
            reflectiveQuadTo(20f, 8.542f)
            quadToRelative(0.542f, 0f, 0.938f, 0.375f)
            quadToRelative(0.395f, 0.375f, 0.395f, 0.916f)
            verticalLineToRelative(8.834f)
            horizontalLineToRelative(8.792f)
            quadToRelative(0.583f, 0f, 0.958f, 0.395f)
            quadToRelative(0.375f, 0.396f, 0.375f, 0.938f)
            quadToRelative(0f, 0.542f, -0.375f, 0.917f)
            reflectiveQuadToRelative(-0.958f, 0.375f)
            horizontalLineToRelative(-8.792f)
            verticalLineToRelative(8.833f)
            quadToRelative(0f, 0.542f, -0.395f, 0.937f)
            quadToRelative(-0.396f, 0.396f, -0.938f, 0.396f)
            close()
        }
    }.build()
}
@alexstyl alexstyl added bug Something isn't working submitted labels May 25, 2024
@alexstyl
Copy link
Author

alexstyl commented May 25, 2024

There seems to be strong opinions on Slack whether this is a bug or not (discussion).

From my POV, I am using a vector, and I see a scale() modifier that doesn't scale the vector. the way image works internally sounds like an implementation detail to me.

The same scenario using html + css is trivial to achieve.

I'm happy to use an alternative API if available to achieve the same result.

@alexstyl alexstyl changed the title ImageVector is blurry when used with Modifier.scale() ImageVector is blurry when used with Image + Modifier.scale() May 25, 2024
@alexstyl alexstyl changed the title ImageVector is blurry when used with Image + Modifier.scale() ImageVector is blurry when used with Image() + Modifier.scale() May 25, 2024
@alexstyl
Copy link
Author

alexstyl commented May 25, 2024

Turns out the same behavior is present on Jetpack Compose. I was asked to open a new issue on Google's issue tracker.

Closing this one.

EDIT: Link to issue on GTracker: https://issuetracker.google.com/u/3/issues/342701234

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working submitted
Projects
None yet
Development

No branches or pull requests

1 participant