You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libraries/Lelebees.MdkScriptMixin.SpriteCompositor/Lelebees.MdkScriptMixin.SpriteCompositor/readme.md
+49-52Lines changed: 49 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,56 +9,37 @@ An API wrapper that supports composing new sprites from multiple existing ones.
9
9
## Usage
10
10
11
11
You can instantiate regular sprites using the helper methods of the `Sprites` class. These return a builder (except for
12
-
`Sprites.Group()`, which returns a group directly) that can be used to further configure the initial values of the
12
+
`Sprites.Compose()`, which returns a composite sprite directly) that can be used to further configure the initial values
13
+
of the
13
14
sprite.
14
15
15
16
All sprites and sprite groups implement the `Sprite` interface, which you can use to `Translate()`, `Rotate()`, or
16
17
`Scale()` a sprite after instantiation, among other things. Individual Sprite types may have additional properties and
17
-
methods available, like `TextureSprite`'s `Mirror()` functions.
18
-
19
-
See the [demo project](https://github.com/malforge/mdk2-packages/blob/main/libraries/Lelebees.MdkScriptMixin.SpriteCompositor/SpriteCompositor.Demo/Program.cs) for a detailed example.
20
-
21
-
### Grouping Sprites
22
-
23
-
You can group sprites by calling `Sprites.Group()` or creating a `new SimpleSpriteGroup()`.
24
-
25
-
If this implementation does
26
-
not fit your needs, you can extend the `SpriteGroup` abstract class. If you do, you will be required to implement the
27
-
`Clone()` and `GetChildren()` methods.
28
-
29
-
**Avoid creating a new list in `GetChildren()`**, as the function is invoked
30
-
whenever a transformation is applied to the group. I recommend using the following example as a guide:
If, for some reason, the abstract `SpriteGroup` class also does not suit your needs, you can implement the `Sprite`
61
-
interface directly, though if you feel the need to do so, there may be a structural problem with your program.
18
+
methods available.
19
+
20
+
See
21
+
the [demo project](https://github.com/malforge/mdk2-packages/blob/main/libraries/Lelebees.MdkScriptMixin.SpriteCompositor/SpriteCompositor.Demo/Program.cs)
22
+
for a detailed example.
23
+
24
+
### Composing Sprites
25
+
26
+
You can compose a new sprite by calling `Sprites.Compose()` or creating a `new CompositeSprite()`. This Composite sprite
27
+
will act just like a normal sprite, even though it is made up of multiple child sprites.
28
+
29
+
Once you have created a composite sprite, you cannot add or remove child sprites. If you need to perform operations on
30
+
multiple sprites without creating a composite sprite, use the dedicated `Sprites` methods which are clarified below.
31
+
32
+
If these options do not
33
+
not fit your needs, you can extend the `CompositeSprite` class, or implement the `Sprite` interface yourself.
34
+
35
+
You should avoid composing a sprite that has both `TextSprite` objects and `TextureSprite` objects as they behave
36
+
differently and can cause unexpected behavior when grouped together.
37
+
38
+
### Performing Transformations On Groups
39
+
40
+
Sometimes you don't want to compose a sprite, but you do want to apply the same transformation to multiple sprites.
41
+
In this case the `Sprites` abstract class has `Translate()`, `Scale()` and `Rotate()` functions available that can
42
+
transform multiple sprites at once.
62
43
63
44
### Anchors
64
45
@@ -69,22 +50,38 @@ an `Anchor` will also scale the distance to the anchor point.
69
50
70
51
### Displaying Sprites
71
52
72
-
In order to draw your composed sprites to an LCD screen, you'll need to call the `Sprite.AsRenderable()` method, which will
53
+
In order to draw your composed sprites to an LCD screen, you'll need to call the `Sprite.AsRenderable()` method, which
54
+
will
73
55
return an array of `MySprite` objects that your sprite consists of. You can draw these to the screen in one go
74
56
using the `MySpriteDrawFrame.AddRange()` method. `AsRenderable()` takes an optional `RectangleF viewport` as parameter.
75
57
Supplying this will move the sprites so that (0,0) is the center of the viewport.
76
58
77
59
## Legal
60
+
78
61
`Copyright (c) 2026 Lelebees`
79
62
80
-
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
63
+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
64
+
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
65
+
version.
81
66
82
-
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
67
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
68
+
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
69
+
details.
83
70
84
-
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
71
+
You should have received a copy of the GNU Lesser General Public License along with this program. If not,
72
+
see <https://www.gnu.org/licenses/>.
85
73
86
74
### License
87
-
You can find a copy of the [GNU General Public License](https://github.com/malforge/mdk2-packages/blob/main/libraries/Lelebees.MdkScriptMixin.SpriteCompositor/Lelebees.MdkScriptMixin.SpriteCompositor/COPYING) and [GNU Lesser General Public License](https://github.com/malforge/mdk2-packages/blob/main/libraries/Lelebees.MdkScriptMixin.SpriteCompositor/Lelebees.MdkScriptMixin.SpriteCompositor/COPYING.LESSER) next to this source code in COPYING and COPYING.LESSER respectively.
75
+
76
+
You can find a copy of
77
+
the [GNU General Public License](https://github.com/malforge/mdk2-packages/blob/main/libraries/Lelebees.MdkScriptMixin.SpriteCompositor/Lelebees.MdkScriptMixin.SpriteCompositor/COPYING)
78
+
and [GNU Lesser General Public License](https://github.com/malforge/mdk2-packages/blob/main/libraries/Lelebees.MdkScriptMixin.SpriteCompositor/Lelebees.MdkScriptMixin.SpriteCompositor/COPYING.LESSER)
79
+
next to this source code in COPYING and COPYING.LESSER respectively.
88
80
89
81
### Reaching out
90
-
You can reach me as @lelebees on Discord, or through the project's [Github Repository](https://github.com/Lelebees/mdk2-packages-sprite-compositor). Please note while reaching out on Discord that I generally do not accept random friend requests. @Mention me in the [programmable block channel](https://discord.com/channels/125011928711036928/216219467959500800) of the Keen Software House Discord Server to get a hold of me.
82
+
83
+
You can reach me as @lelebees on Discord, or through the
84
+
project's [GitHub Repository](https://github.com/Lelebees/mdk2-packages-sprite-compositor). Please note while reaching
85
+
out on Discord that I generally do not accept random friend requests. @Mention me in
86
+
the [programmable block channel](https://discord.com/channels/125011928711036928/216219467959500800) of the Keen
87
+
Software House Discord Server to get a hold of me.
Copy file name to clipboardExpand all lines: libraries/Lelebees.MdkScriptMixin.SpriteCompositor/Lelebees.MdkScriptMixin.SpriteCompositor/src/sprite/Sprites.cs
Copy file name to clipboardExpand all lines: libraries/Lelebees.MdkScriptMixin.SpriteCompositor/Lelebees.MdkScriptMixin.SpriteCompositor/src/sprite/atoms/TextureSprite.cs
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11
11
You should have received a copy of the GNU Lesser General Public License along with Sprite Compositor.
Copy file name to clipboardExpand all lines: libraries/Lelebees.MdkScriptMixin.SpriteCompositor/Lelebees.MdkScriptMixin.SpriteCompositor/src/sprite/molecules/CompositeSprite.cs
Copy file name to clipboardExpand all lines: libraries/Lelebees.MdkScriptMixin.SpriteCompositor/SpriteCompositor.Test/src/sprite/atoms/TextureSpriteTest.cs
+2-4Lines changed: 2 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -34,10 +34,8 @@ public void ArbitraryRotationsSetCorrectRotation(params double[] radians)
34
34
{
35
35
sprite.Rotate(angle);
36
36
}
37
-
38
-
// Note here (and this is not obvious) that unlike the angle struct, a sprite's rotation value can grow indefinitely
39
-
// This means that values above and below 2 * Math.PI are possible. The test keeps this in mind.
0 commit comments