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

Support for circle shape blur #45

Open
tmdroid opened this issue Apr 27, 2020 · 2 comments · May be fixed by #46
Open

Support for circle shape blur #45

tmdroid opened this issue Apr 27, 2020 · 2 comments · May be fixed by #46

Comments

@tmdroid
Copy link

tmdroid commented Apr 27, 2020

Hello,

It would be nice to also support blurring in a shape of circle, not only squares or rectangles.

@tmdroid tmdroid linked a pull request Apr 27, 2020 that will close this issue
@zmunm
Copy link

zmunm commented Dec 24, 2020

Same issue as me but connected PR didn't work for me

In my project, I am using Fresco and I don't have much time, so I solved it by changing to XferRoundFilter after mBlurredBitmap, but it would be nice if the library could be used independently.

@zmunm
Copy link

zmunm commented Jan 6, 2021

Hello. It's a good day to code

I used OutlineProvider and everything is happy now.

Attach some of the code created for databinding.

@BindingAdapter("roundOutlineRadius")
fun View.setRoundOutlineRadiusBinding(roundOutlineRadius: Float) {
    outlineProvider = object : ViewOutlineProvider() {
        override fun getOutline(view: View, outline: Outline?) {
            outline?.setRoundRect(0, 0, view.width, view.height, roundOutlineRadius)
        }
    }

    clipToOutline = true
}

@BindingAdapter("roundAsCircle")
fun View.setRoundAsCircleBinding(isCircle: Boolean) {
    if (isCircle) {
        outlineProvider = object : ViewOutlineProvider() {
            override fun getOutline(view: View, outline: Outline?) {
                val rect = Rect(0, 0, view.width, view.height)
                outline?.setRoundRect(rect, rect.width() / 2f)
            }
        }

        clipToOutline = true
    }
}
            <com.github.mmin18.widget.RealtimeBlurView
                android:layout_width="200dp"
                android:layout_height="200dp"
                android:layout_margin="30dp"
                app:realtimeBlurRadius="5dp"
                app:realtimeOverlayColor="#4fff"
                app:roundAsCircle="@{true}"
                app:layout_constraintStart_toStartOf="@id/image"
                app:layout_constraintTop_toTopOf="@id/image" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants