@quenty/sprites 3.4.0 → 3.5.0-canary.241.a4e8214.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.5.0-canary.241.a4e8214.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sprites@3.4.1...@quenty/sprites@3.5.0-canary.241.a4e8214.0) (2022-01-03)
7
+
8
+ **Note:** Version bump only for package @quenty/sprites
9
+
10
+
11
+
12
+
13
+
14
+ ## [3.4.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sprites@3.4.0...@quenty/sprites@3.4.1) (2021-12-30)
15
+
16
+ **Note:** Version bump only for package @quenty/sprites
17
+
18
+
19
+
20
+
21
+
6
22
  # [3.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sprites@3.3.0...@quenty/sprites@3.4.0) (2021-11-20)
7
23
 
8
24
 
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2014 Quenty
3
+ Copyright (c) 2014-2021 Quenty
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,17 +1,20 @@
1
1
  ## Sprites
2
2
  <div align="center">
3
- <a href="http://quenty.github.io/api/">
4
- <img src="https://img.shields.io/badge/docs-website-green.svg" alt="Documentation" />
3
+ <a href="http://quenty.github.io/NevermoreEngine/">
4
+ <img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" />
5
5
  </a>
6
6
  <a href="https://discord.gg/mhtGUS8">
7
- <img src="https://img.shields.io/badge/discord-nevermore-blue.svg" alt="Discord" />
7
+ <img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" />
8
8
  </a>
9
9
  <a href="https://github.com/Quenty/NevermoreEngine/actions">
10
10
  <img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" />
11
11
  </a>
12
12
  </div>
13
+
13
14
  Spritesheet utility for Roblox including a built-in InputImageLibrary
14
15
 
16
+ <div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/InputImageLibrary">View docs →</a></div>
17
+
15
18
  ## Installation
16
19
  ```
17
20
  npm install @quenty/sprites --save
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/sprites",
3
- "version": "3.4.0",
3
+ "version": "3.5.0-canary.241.a4e8214.0",
4
4
  "description": "Spritesheet utility for Roblox including a built-in InputImageLibrary",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,16 +26,16 @@
26
26
  "Quenty"
27
27
  ],
28
28
  "dependencies": {
29
- "@quenty/baseobject": "^3.2.0",
30
- "@quenty/loader": "^3.1.1",
31
- "@quenty/maid": "^2.0.1",
32
- "@quenty/uiobjectutils": "^2.0.0"
29
+ "@quenty/baseobject": "3.3.0-canary.241.a4e8214.0",
30
+ "@quenty/loader": "3.2.0-canary.241.a4e8214.0",
31
+ "@quenty/maid": "2.0.2",
32
+ "@quenty/uiobjectutils": "2.0.1"
33
33
  },
34
34
  "devDependencies": {
35
- "@quenty/string": "^2.2.0"
35
+ "@quenty/string": "2.2.1"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "87ab1435a59a05e7dd745db1dfcec26116d1d71d"
40
+ "gitHead": "a4e821471f35998d63f38a4f4a578e07b4e79035"
41
41
  }
@@ -1,6 +1,6 @@
1
- ---
2
- -- @module DialogSlider.story
3
- -- @author Quenty
1
+ --[[
2
+ @class InputImageLibrary.story
3
+ ]]
4
4
 
5
5
  local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).load(script)
6
6
 
@@ -1,4 +1,7 @@
1
- --- Generated Gestures with Python
1
+ --[[
2
+ Generated Gestures with Python
3
+ @class Gestures
4
+ ]]
2
5
 
3
6
  local parent = script:FindFirstAncestorWhichIsA("ModuleScript")
4
7
  local require = require(parent.Parent.loader).load(parent)
@@ -1,4 +1,7 @@
1
- --- Generated KeyboardDark with Python
1
+ --[[
2
+ Generated KeyboardDark with Python
3
+ @class KeyboardDark
4
+ ]]
2
5
 
3
6
  local parent = script:FindFirstAncestorWhichIsA("ModuleScript")
4
7
  local require = require(parent.Parent.loader).load(parent)
@@ -1,4 +1,7 @@
1
- --- Generated KeyboardLight with Python
1
+ --[[
2
+ Generated KeyboardLight with Python
3
+ @class KeyboardLight
4
+ ]]
2
5
 
3
6
  local parent = script:FindFirstAncestorWhichIsA("ModuleScript")
4
7
  local require = require(parent.Parent.loader).load(parent)
@@ -1,4 +1,7 @@
1
- --- Generated XboxOneDark with Python
1
+ --[[
2
+ Generated XboxOneDark with Python
3
+ @class XboxOneDark
4
+ ]]
2
5
 
3
6
  local parent = script:FindFirstAncestorWhichIsA("ModuleScript")
4
7
  local require = require(parent.Parent.loader).load(parent)
@@ -1,5 +1,7 @@
1
- --- Generated XboxOneLight with Python
2
- -- @author Quenty
1
+ --[[
2
+ Generated XboxOneLight with Python
3
+ @class XboxOneLight
4
+ ]]
3
5
 
4
6
  local parent = script:FindFirstAncestorWhichIsA("ModuleScript")
5
7
  local require = require(parent.Parent.loader).load(parent)
@@ -1,5 +1,9 @@
1
- --- Input image library
2
- -- @module InputImageLibrary
1
+ --[=[
2
+ InputImageLibrary with a variety of dark and light themed icons for inputs on keyboard, xbox, touched events,
3
+ mouse, and more.
4
+
5
+ @class InputImageLibrary
6
+ ]=]
3
7
 
4
8
  local require = require(script.Parent.loader).load(script)
5
9
 
@@ -18,6 +22,11 @@ function InputImageLibrary.new(parentFolder)
18
22
  return self
19
23
  end
20
24
 
25
+ --[=[
26
+ Retrieves all the asset ids to preload
27
+
28
+ @return { string }
29
+ ]=]
21
30
  function InputImageLibrary:GetPreloadAssetIds()
22
31
  local assets = {}
23
32
  for _, platformSheets in pairs(self._spritesheets) do
@@ -39,8 +48,14 @@ function InputImageLibrary:_loadSpriteSheets(parentFolder)
39
48
  end
40
49
  end
41
50
 
42
- ---
43
- -- @treturn Sprite
51
+ --[=[
52
+ Retrieves a sprite from the library
53
+
54
+ @param index number -- The sprite index to get
55
+ @param preferredStyle string -- The preferred style type to retrieve this in
56
+ @param preferredPlatform string -- The preferred platform to get the sprite for
57
+ @return Sprite
58
+ ]=]
44
59
  function InputImageLibrary:GetSprite(index, preferredStyle, preferredPlatform)
45
60
  local sheet = self:_pickSheet(index, preferredStyle, preferredPlatform)
46
61
  if sheet then
@@ -1,6 +1,7 @@
1
- ---
2
- -- @classmod AnimatedSpritesheet
3
- -- @author Quenty
1
+ --[=[
2
+ A spritesheet that is animated. See [AnimatedSpritesheetPlayer] for playback.
3
+ @class AnimatedSpritesheet
4
+ ]=]
4
5
 
5
6
  local require = require(script.Parent.loader).load(script)
6
7
 
@@ -10,6 +11,21 @@ local AnimatedSpritesheet = setmetatable({}, Spritesheet)
10
11
  AnimatedSpritesheet.ClassName = "AnimatedSpritesheet"
11
12
  AnimatedSpritesheet.__index = AnimatedSpritesheet
12
13
 
14
+ --[=[
15
+ @interface AnimatedSpritesheetOptions
16
+ .texture string
17
+ .frames number
18
+ .spritesPerRow number
19
+ .spriteSize Vector2
20
+ .framesPerSecond number
21
+ @within AnimatedSpritesheet
22
+ ]=]
23
+
24
+ --[=[
25
+ Constructs a new AnimatedSpritesheet
26
+ @param options AnimatedSpritesheetOptions
27
+ @return AnimatedSpritesheet
28
+ ]=]
13
29
  function AnimatedSpritesheet.new(options)
14
30
  local self = setmetatable(Spritesheet.new(options.texture), AnimatedSpritesheet)
15
31
 
@@ -31,19 +47,34 @@ function AnimatedSpritesheet.new(options)
31
47
  return self
32
48
  end
33
49
 
34
-
50
+ --[=[
51
+ Gets the sprite size
52
+ @return Vector2
53
+ ]=]
35
54
  function AnimatedSpritesheet:GetSpriteSize()
36
55
  return self._options.spriteSize
37
56
  end
38
57
 
58
+ --[=[
59
+ Gets the frames per a second
60
+ @return number
61
+ ]=]
39
62
  function AnimatedSpritesheet:GetFramesPerSecond()
40
63
  return self._options.framesPerSecond
41
64
  end
42
65
 
43
- function AnimatedSpritesheet:GetPlayTime(framesPerSecond)
44
- return self._options.frames/framesPerSecond
66
+ --[=[
67
+ Gets the play time for the animated sheet
68
+ @return number
69
+ ]=]
70
+ function AnimatedSpritesheet:GetPlayTime()
71
+ return self._options.frames/self._options.framesPerSecond
45
72
  end
46
73
 
74
+ --[=[
75
+ Retrieves the frames for the sprite sheet.
76
+ @return frames
77
+ ]=]
47
78
  function AnimatedSpritesheet:GetFrames()
48
79
  return self._options.frames
49
80
  end
@@ -1,6 +1,6 @@
1
- ---
2
- -- @module DialogSlider.story
3
- -- @author Quenty
1
+ --[[
2
+ @class AnimatedSpritesheet.story
3
+ ]]
4
4
 
5
5
  local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).load(script)
6
6
 
@@ -1,6 +1,7 @@
1
- ---
2
- -- @classmod AnimatedSpritesheetPlayer
3
- -- @author Quenty
1
+ --[=[
2
+ Plays an [AnimatedSpritesheet] for an given image label.
3
+ @class AnimatedSpritesheetPlayer
4
+ ]=]
4
5
 
5
6
  local require = require(script.Parent.loader).load(script)
6
7
 
@@ -13,6 +14,12 @@ local AnimatedSpritesheetPlayer = setmetatable({}, BaseObject)
13
14
  AnimatedSpritesheetPlayer.ClassName = "AnimatedSpritesheetPlayer"
14
15
  AnimatedSpritesheetPlayer.__index = AnimatedSpritesheetPlayer
15
16
 
17
+ --[=[
18
+ Constructs a new AnimatedSpritesheetPlayer
19
+ @param imageLabel ImageLabel
20
+ @param spritesheet AnimatedSpritesheet?
21
+ @return AnimatedSpritesheetPlayer
22
+ ]=]
16
23
  function AnimatedSpritesheetPlayer.new(imageLabel, spritesheet)
17
24
  local self = setmetatable(BaseObject.new(spritesheet), AnimatedSpritesheetPlayer)
18
25
 
@@ -25,6 +32,10 @@ function AnimatedSpritesheetPlayer.new(imageLabel, spritesheet)
25
32
  return self
26
33
  end
27
34
 
35
+ --[=[
36
+ Sets the current sheet and starts play if needed
37
+ @param spritesheet AnimatedSpritesheet
38
+ ]=]
28
39
  function AnimatedSpritesheetPlayer:SetSheet(spritesheet)
29
40
  assert(spritesheet, "Bad spritesheet")
30
41
 
@@ -1,10 +1,27 @@
1
- ---
2
- -- @classmod Sprite
1
+ --[=[
2
+ A single image on a spritesheet.
3
+ @class Sprite
4
+ ]=]
3
5
 
4
6
  local Sprite = {}
5
7
  Sprite.ClassName = "Sprite"
6
8
  Sprite.__index = Sprite
7
9
 
10
+ --[=[
11
+ Data used to construct a sprite.
12
+ @interface SpriteData
13
+ .Texture string
14
+ .Size Vector2
15
+ .Position Vector2
16
+ .Name string
17
+ @within Sprite
18
+ ]=]
19
+
20
+ --[=[
21
+ Constructs a new sprite
22
+ @param data SpriteData
23
+ @return Sprite
24
+ ]=]
8
25
  function Sprite.new(data)
9
26
  assert(data.Texture, "Bad data")
10
27
  assert(data.Size, "Bad data")
@@ -16,6 +33,11 @@ function Sprite.new(data)
16
33
  return self
17
34
  end
18
35
 
36
+ --[=[
37
+ Applies the styling to the gui
38
+ @param gui ImageLabel | ImageButton
39
+ @return Instance
40
+ ]=]
19
41
  function Sprite:Style(gui)
20
42
  gui.Image = self.Texture
21
43
  gui.ImageRectOffset = self.Position
@@ -24,6 +46,11 @@ function Sprite:Style(gui)
24
46
  return gui
25
47
  end
26
48
 
49
+ --[=[
50
+ Returns a new sprite with the specified `instanceType`
51
+ @param instanceType "ImageLabel" | "ImageButton"
52
+ @return ImageLabel | ImageButton
53
+ ]=]
27
54
  function Sprite:Get(instanceType)
28
55
  local gui = Instance.new(instanceType)
29
56
  gui.Size = UDim2.new(0, self.Size.X, 0, self.Size.Y)
@@ -1,5 +1,7 @@
1
- --- Data model for sprite sheets
2
- -- @classmod Spritesheet
1
+ --[=[
2
+ Data model for sprite sheets
3
+ @class Spritesheet
4
+ ]=]
3
5
 
4
6
  local require = require(script.Parent.loader).load(script)
5
7
 
@@ -9,6 +11,11 @@ local Spritesheet = {}
9
11
  Spritesheet.ClassName = "Spritesheet"
10
12
  Spritesheet.__index = Spritesheet
11
13
 
14
+ --[=[
15
+ Constructs a new Spritesheet
16
+ @param texture string
17
+ @return Spritesheet
18
+ ]=]
12
19
  function Spritesheet.new(texture)
13
20
  local self = setmetatable({}, Spritesheet)
14
21
 
@@ -18,10 +25,21 @@ function Spritesheet.new(texture)
18
25
  return self
19
26
  end
20
27
 
28
+ --[=[
29
+ Retrieves the preload asset ids to use
30
+ @return string
31
+ ]=]
21
32
  function Spritesheet:GetPreloadAssetId()
22
33
  return self._texture
23
34
  end
24
35
 
36
+ --[=[
37
+ @param index any
38
+ @param position Vector2
39
+ @param size Vector2
40
+
41
+ Adds a named sprite at the given index
42
+ ]=]
25
43
  function Spritesheet:AddSprite(index, position, size)
26
44
  assert(not self._sprites[index], "Already exists")
27
45
 
@@ -35,6 +53,11 @@ function Spritesheet:AddSprite(index, position, size)
35
53
  self._sprites[index] = sprite
36
54
  end
37
55
 
56
+ --[=[
57
+ Retrieves the sprite for the given index
58
+ @param index any | EnumItem
59
+ @return Sprite?
60
+ ]=]
38
61
  function Spritesheet:GetSprite(index)
39
62
  if not index then
40
63
  warn("[Spritesheet.GetSprite] - Image name cannot be nil")
@@ -53,6 +76,11 @@ function Spritesheet:GetSprite(index)
53
76
  return sprite
54
77
  end
55
78
 
79
+ --[=[
80
+ Returns true if the sprite exists
81
+ @param index any | EnumItem
82
+ @return boolean
83
+ ]=]
56
84
  function Spritesheet:HasSprite(index)
57
85
  return self:GetSprite(index) ~= nil
58
86
  end