Skip to content

Commit

Permalink
add hide function && move docs to wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor00f committed Mar 4, 2025
1 parent 3c24549 commit 1b44219
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"cSpell.words": [
"Roblox",
"rojo",
"Giflib"
],

"cSpell.ignorePaths": [
"vscode-extension",
".git/objects",
".vscode", // ignore vscode workspace settings
".vscode-insiders",
Expand Down
93 changes: 1 addition & 92 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,95 +2,4 @@

Small library for creating gifs in roblox




## Functions

### Gif functions

`new(Label: Frame, images: { Frame.GifFrame }, loopAnimation: boolean?): Gif` - gif constructor.

`StartAnimation(self: Gif)` - start gif animation

`StopAnimation(self: Gif)` - stop animation

`ResetAnimation(self: Gif)` - Reset animation.

`Preload(self: Gif)` - Preload images. Waiting while images not loading

`SetFrame(self: Gif, frame: number)` - set current frame, that showing now

`Next(self: Gif)` - Next frame

`Destroy(self: Gif)` - Destroy gif. Destroying table, events and frames. Fire Destroying event

### Frame functions

Gif frame struct not contain this methods,but you can call them as `giflib.Frame.<method>(Frame, ...)`. Why? I think it's waste of memory.

`new(id: string, t: number): GifFrame` - Frame constructor

`Show(self: GifFrame, parent: Frame)` - Show frame. `parent` is Gif.ImageLabel

`WaitLoading(self: GifFrame)` - Wait while frame is loading

`Hide(self: GifFrame)`- Hide gif frame

`Destroy(self: GifFrame)` - Destroy gif frame

## Events

`Completed` - Fire on animation is ended. If animation is looped fires on every restarting

`Destroying` - Fire on destroying gif

## Example

```
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local giflib = require(ReplicatedStorage.shared.giflib)
local imageLabel = Instance.new("ImageLabel")
imageLabel.Parent = Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")
imageLabel.Size = UDim2.fromScale(1, 1)
local mygif = giflib.new(
imageLabel,
{
giflib.Frame.new("85510906103514", 0.08),
giflib.Frame.new("108084812514916", 0.08),
giflib.Frame.new("110413056991989", 0.08),
giflib.Frame.new("138519472508007", 0.08),
giflib.Frame.new("76126708840626", 0.08),
giflib.Frame.new("105799496264978", 0.08),
giflib.Frame.new("126677371037972", 0.08),
giflib.Frame.new("110695448399045", 0.08),
giflib.Frame.new("88405074787964", 0.08),
giflib.Frame.new("82234753210135", 0.08),
giflib.Frame.new("126380322008457", 0.08),
giflib.Frame.new("73999504428848", 1)
},
true
)
mygif:StartAnimation()
wait(10)
mygif:StopAnimation()
wait(10)
mygif:StartAnimation() -- continue
wait(10)
mygif:Destroy()
```
you can find docs in [wiki](https://github.com/Ukuroks-games/giflib/wiki/Guide)
15 changes: 14 additions & 1 deletion src/giflib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage")

local algorithm = require(ReplicatedStorage.Packages.stdlib).algorithm

local gifFrame = require(script.Parent.gifFrame)
local Frame = require(script.Parent.gifFrame)

--[[
Expand Down Expand Up @@ -89,6 +90,8 @@ export type Gif = {
]]
Next: (self: Gif) -> nil,

Hide: (self: Gif) -> nil,

--[[
Показывает что анимация завершилась
]]
Expand Down Expand Up @@ -209,6 +212,15 @@ function giflib.Next(self: Gif)
self:SetFrame(self.Frame + 1)
end

--[[
Hide gif frames
]]
function giflib.Hide(self: Gif)
for _, v in pairs(self.Frames) do
gifFrame.Hide(v)
end
end

--[[
Gif constructor
Expand Down Expand Up @@ -241,7 +253,8 @@ function giflib.new(Label: Frame, images: { Frame.GifFrame }, loopAnimation: boo
ResetAnimation = giflib.ResetAnimation,
Preload = giflib.Preload,
SetFrame = giflib.SetFrame,
Next = giflib.Next
Next = giflib.Next,
Hide = giflib.Hide
}

for _, v in pairs(self.Frames) do
Expand Down
2 changes: 1 addition & 1 deletion wally.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "egor00f/giflib"

description = "Library for creating gifs"

version = "0.1.6"
version = "0.1.7"

registry = "https://github.com/UpliftGames/wally-index"

Expand Down

0 comments on commit 1b44219

Please sign in to comment.