Giter Site home page Giter Site logo

glassmorphicui's Introduction

GlassmorphicUI

Glassmorphic UI in Roblox.

Please consider supporting my work.

image

Installation

Via wally:

[dependencies]
GlassmorphicUI = "boatbomber/[email protected]"

Alternatively, grab the .rbxm standalone model from the latest release.

Usage

Setting up glassy effects:

You can add a GlassmorphicUI tag to a Frame or other GuiObject to automatically add a glassmorphic background to it. Adding a GlassmorphicUI tag to an ImageLabel will apply the glass effects to it directly, instead of adding a background image.

Of course, you'll need to require the module in order for it to run even if you only use tags and don't intend to call any of its functions directly.

If you prefer to use the API directly instead of CollectionService tags, you can use the GlassmorphicUI.new() function to create a new glassy ImageLabel, GlassmorphicUI.applyGlassToImageLabel() to apply the glassmorphic effect to an existing ImageLabel, or GlassmorphicUI.addGlassBackground() to add a glassy background to an existing GuiObject. See the API section below for more details on those functions.

Modifying the visuals:

You can modify the glassmorphic effect by changing the BackgroundTransparency and BackgroundColor3 properties of the ImageLabel. You can also use a BlurRadius attribute to modify the blur radius of the glassmorphic effect. It is compatible with UICorners and all other ImageLabel properties.

A higher BackgroundTransparency will make the glassmorphic effect more prominent as the blurry elements underneath become more visible. The BackgroundColor3 will affect the tint of the glass. A lower BlurRadius will let you see more detail behind the glass. Be aware that a lower BlurRadius will make the imperfections of the approximated effect more obvious and ugly.

You can also use GlassmorphicUI.setDefaultBlurRadius() to set the default blur radius for all glassmorphic images. This will not affect images that have already been created.

API

function GlassmorphicUI.new(): ImageLabel

Returns an ImageLabel with a glassmorphic effect.

local GlassmorphicUI = require(Path.To.GlassmorphicUI)

local glassyimage = GlassmorphicUI.new()
glassyimage:SetAttribute("BlurRadius", 5)
glassyimage.BackgroundTransparency = 0.5
glassyimage.BackgroundColor3 = Color3.fromRGB(7, 48, 84)
glassyimage.Size = UDim2.fromScale(0.3, 0.3)
glassyimage.Position = UDim2.fromScale(0.5, 0.5)
glassyimage.AnchorPoint = Vector2.new(0.5, 0.5)
glassyimage.Parent = ScreenGui
function GlassmorphicUI.applyGlassToImageLabel(ImageLabel: ImageLabel): ()

Takes an existing ImageLabel and applies the glassmorphic effect to it. Useful for integrating GlassmorphicUI with existing UI systems.

local GlassmorphicUI = require(Path.To.GlassmorphicUI)

local glassyimage = Instance.new("ImageLabel")
glassyimage.BackgroundTransparency = 0.5
glassyimage.BackgroundColor3 = Color3.fromRGB(7, 48, 84)
glassyimage.Size = UDim2.fromScale(0.3, 0.3)
glassyimage.Position = UDim2.fromScale(0.5, 0.5)
glassyimage.AnchorPoint = Vector2.new(0.5, 0.5)
glassyimage.Parent = ScreenGui

GlassmorphicUI.applyGlassToImageLabel(glassyimage)
function GlassmorphicUI.addGlassBackground(GuiObject: GuiObject): ImageLabel

Takes an existing GuiObject (such as a Frame) and parents a glassy ImageLabel inside it. The ImageLabel will have a very low ZIndex as to appear as the background of the GuiObject. The GuiObject will be forced to have a BackgroundTransparency of 1, otherwise the effect would just show your GuiObject's background behind the glass. Useful for integrating GlassmorphicUI with existing UI systems.

local GlassmorphicUI = require(Path.To.GlassmorphicUI)

local frame = Instance.new("Frame")
frame.Size = UDim2.fromScale(0.2, 0.2)
frame.Parent = script.Parent

local glassyimage = GlassmorphicUI.addGlassBackground(frame)
glassyimage.BackgroundTransparency = 0.5
glassyimage.BackgroundColor3 = Color3.fromRGB(7, 48, 84)
function GlassmorphicUI.forceUpdate(ImageLabel: ImageLabel): ImageLabel

Forces a refresh of the glassmorphic effect on an ImageLabel. Use sparingly, as this is an expensive operation. Intended to be used when you need an immediate and total update due to major background changes, such as closing a menu underneath the glass or teleporting the player to a new location.

function GlassmorphicUI.pauseUpdates(Window: ImageLabel): ImageLabel

Pauses updates to the glassmorphic effect on an ImageLabel. Useful for reducing lag when you have a lot of glassmorphic images that don't need to update every frame.

For example, if you have a glassmorphic effect on top of a background that never changes, you can just never update.

local glassyimage = GlassmorphicUI.pauseUpdates(GlassmorphicUI.new())

The initial update always happens, even if paused, so the glass won't be blank when created.

function GlassmorphicUI.resumeUpdates(Window: ImageLabel): ImageLabel

Resumes updates to the glassmorphic effect on an ImageLabel that has been paused by GlassmorphicUI.pauseUpdates.

function GlassmorphicUI.setDefaultBlurRadius(BlurRadius: number): ()

Sets the default blur radius for all glassmorphic images. Does not affect images that have already been created.

glassmorphicui's People

Contributors

boatbomber avatar

Stargazers

Byran avatar late avatar Peerawit Piwsawang avatar  avatar ObviouslyThree avatar  avatar Maks avatar InKrnl avatar Arlo avatar luna avatar richard avatar Enrique avatar Pada avatar KYRYLO avatar Jan Bernard Abaincia avatar Lewin Kelly avatar Ray avatar Hyde avatar  avatar  avatar ZoyKad avatar Arid avatar James avatar  avatar Avafe avatar piqu avatar aqzp avatar Legit avatar  avatar Jaden Bryant avatar val avatar arlo avatar  avatar Wolfite avatar script avatar Emiliano Fernandez avatar  avatar aaron adriano avatar  avatar Marin M avatar Six avatar 1mm avatar Jerse avatar LocalX avatar  avatar FunkyWorm avatar Alex Hafner avatar Cam avatar NikSavc avatar ScriptOn avatar Neon avatar  avatar Efe Bıkmaz avatar Cameron Campbell avatar  avatar  avatar Rusty H. avatar Lucas Gangstad avatar  avatar Finch avatar  avatar Frankiee avatar Mouhamadou Sissoko avatar Redus avatar Joe Smaller avatar maddie (SepiaSpinda) avatar Tenchigon avatar Isaiah avatar Justin avatar rosalina saige avatar  avatar Jimmy avatar Brooke Rhodes avatar Bobo avatar David Duque avatar RainyLofi avatar  avatar Ossie avatar Sasial avatar Martin avatar iFrexsim avatar Clown avatar Oscar W. Halland avatar  avatar vocksel avatar Dvd avatar Devi avatar  avatar  avatar Voidus X avatar  avatar

Watchers

 avatar Sasial avatar  avatar

glassmorphicui's Issues

[enhancement] Automatic Blurring

It would be useful if you could run a function in the module that would automatically apply the Glassmorphic effect to any existing and new objects with the AutoBlur Tag.
I would Imagine the function to look like this:
GlassmorphicUI.setupAutoApply(Path to GUI Object)
and it would Apply to all child objects of that GUI Objects.
Yes, this can be implemented in separate scripts but it would be nice to be able to drop the module in a new project and with 2 lines of code to setup the blur.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.