Package: kivy-garden.frostedglass
FrostedGlassFrostedGlassis a widget with translucent frosted glass effect, that
creates a context with the background behind it.The effect created is based on the widget/layout passed in as the background.
You can control the blur size, saturation, luminosity, overlay color, noise
opacity, border radius and the outline (color and width).Installpip install kivy_garden.frostedglassImportpythonimport:from kivy_garden.frostedglass import FrostedGlassorkvlangimport:#: import FrostedGlass kivy_garden.frostedglassUsageFrostedGlasswill apply the effect to the background passed to it. Make sure you assign the correct id of the widget/layout that is behindFrostedGlassto thebackgroundproperty.Example:Image:
    id: bg_image
    pos_hint: {'center_x': 0.5, 'center_y': 0.5}
    source: 'kivy_logo.png'

FrostedGlass:
    pos_hint: {'center_x': 0.5, 'center_y': 0.5}
    size_hint: (None, None)
    size: (180, 130)
    background: bg_image
    blur_size: 20
    saturation: 1.0
    luminosity: 1.5
    overlay_color: "#FFB9008C"
    noise_opacity: 0.15
    border_radius:  dp(0), dp(100), dp(0), dp(100)
    outline_color: "#000000"
    outline_width: 1.2
    Label:
        text: 'FrostedGlass'
        pos_hint: {'center_x': 0.5, 'center_y': 0.5}
        bold: True
        color: 'black'
        font_size: dp(25)FrostedGlass Showcase:You can find the source code in the 🔷examples folder🔷https://user-images.githubusercontent.com/73297572/214139558-f995ac2c-77bb-4952-a82b-212e2f31d65f.mp4Overview ofFrostedGlasscreation processTo reach the final result of theFrostedGlasswidget, the steps described in the image below are followed:FeaturesFrostedGlass is efficient and makes internal optimizations to deliver the best performance while maintaining the quality of the effect, regardless of implementation, for all platforms supported by Kivy.Overview:Automatic effect update, with auto bind to background properties.Updates effect only when needed. The effect update will only occur when some background or FrostedGlass property requires the update.Avoid unnecessary computation of the effect. If any FrostedGlass widget is not visible, it will not be updated.Full control over FrostedGlass properties. The widget is not limited to the frosted glass effect, it can be used simply as an option to achieve gaussian blur of some "background".GuidelinesThe FrostedGlass widget is designed to update the effect whenever there is a change to its properties or background properties that requires an effect update, to keep the effect in sync with the background.But if it doesn't, you can call theupdate_effect()method manually to update the effect.If calling theupdate_effect()method did not update the effect, you may need to call therefresh_effect()method.APIbackgroundTarget widget/layout that will be used as a background toFrostedGlass.
The recomended way to pass the widget is through the widget/layoutid.backgroundis defaults toNone.blur_sizeSize of the gaussian blur aplied to the background.❗️Note: Do not pass relative values such asdporsp.FrostedGlassalready
manages this automatically, according to the device's screen density.blur_sizeis defaults to25.saturationSaturation boost that will be aplied to the background.saturationis defaults to1.2.luminosityLuminosity boost that will be aplied to the background.luminosityis defaults to1.3.overlay_colorColor/tint overlay that will be aplied over the background.overlay_coloris defaults to[0.5, 0.5, 0.5, 0.35].noise_opacityOpacity of the noise texture layer.noise_opacityis a defaults to0.08.border_radiusSpecifies the radius used for the rounded corners clockwise:
top-left, top-right, bottom-right, bottom-left.border_radiusis defaults to[0, 0, 0, 0].outline_colorOutline color.outline_coloris defaults to[1, 1, 1, 1].outline_widthOutline width.outline_widthis defaults to1.update_effect()Updates the effect only once with each method call.❗️Note: Use this method to update the effect only ifFrostedGlassdoesn't update automatically.refresh_effect()Updates the effect only once with each method call. Sould be used as an alternative, whenupdate_effect()doesn't update the effect totally.❗️Note: Use this method to update the effect only ifFrostedGlassdoesn't update automatically andupdate_effect()was not enough to update the effect.CIEvery push or pull request run theGitHub ActionCI.
It tests the code on various OS and also generates wheels that can be released on PyPI upon a
tag. Docs are also generated and uploaded to the repo as well as artifacts of the CI.ContributingCheck out ourcontribution guideand feel free to improve the FrostedGlass flower.🔴 If you have a bug or an idea, create a report to help us improve or suggest an idea for this project by opening an issue🔴 Every contribution is welcome and appreciated!!!LicenseThis software is released under the terms of the MIT License.
Please see theLICENSE.txtfile.