-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
421d908
commit 26e6047
Showing
62 changed files
with
3,017 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: mini_sprite | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- .github/workflows/mini_sprite.yaml | ||
- packages/mini_sprite/** | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- .github/workflows/mini_sprite.yaml | ||
- packages/mini_sprite/** | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
channel: 'stable' | ||
cache: true | ||
- uses: bluefireteam/melos-action@main | ||
|
||
- name: Install Dependencies | ||
run: melos bootstrap | ||
|
||
- name: Format | ||
run: melos exec --scope mini_sprite dart format --set-exit-if-changed lib | ||
|
||
- name: Analyze | ||
run: melos exec --scope mini_sprite dart analyze --fatal-infos --fatal-warnings . | ||
|
||
- name: Run Tests | ||
run: melos exec --scope mini_sprite flutter test --coverage | ||
|
||
- name: Check Code Coverage | ||
uses: VeryGoodOpenSource/very_good_coverage@v1 | ||
with: | ||
path: packages/mini_sprite/coverage/lcov.info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: mini_sprite_editor | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- .github/workflows/mini_sprite_editor.yaml | ||
- packages/mini_sprite_editor/** | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- .github/workflows/mini_sprite_editor.yaml | ||
- packages/mini_sprite_editor/** | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
channel: 'stable' | ||
cache: true | ||
- uses: bluefireteam/melos-action@main | ||
|
||
- name: Install Dependencies | ||
run: melos bootstrap | ||
|
||
- name: Format | ||
run: melos exec --scope mini_sprite_editor flutter format --set-exit-if-changed lib | ||
|
||
- name: Analyze | ||
run: melos exec --scope mini_sprite_editor flutter analyze --fatal-infos --fatal-warnings . | ||
|
||
- name: Run Tests | ||
run: melos exec --scope mini_sprite_editor flutter test --coverage | ||
|
||
- name: Check Code Coverage | ||
uses: VeryGoodOpenSource/very_good_coverage@v1 | ||
with: | ||
path: packages/mini_sprite_editor/coverage/lcov.info |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
.idea/runConfigurations/melos_flutter_run_mini_sprite_editor.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: mini_sprite | ||
repository: https://github.com/bluefireteam/mini_sprite | ||
packages: | ||
- packages/** | ||
- . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="WEB_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Dart SDK" level="project" /> | ||
<orderEntry type="library" name="Dart Packages" level="project" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# See https://www.dartlang.org/guides/libraries/private-files | ||
|
||
# Files and directories created by pub | ||
.dart_tool/ | ||
.packages | ||
build/ | ||
pubspec.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# mini_sprite | ||
|
||
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link] | ||
[![License: MIT][license_badge]][license_link] | ||
|
||
A Very Good Project created by Very Good CLI. | ||
|
||
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg | ||
[license_link]: https://opensource.org/licenses/MIT | ||
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg | ||
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include: package:very_good_analysis/analysis_options.3.0.0.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
library mini_sprite; | ||
|
||
export 'src/mini_sprite.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/// {@template mini_sprite} | ||
/// A class used to manipulate a matrix of pixels. | ||
/// first dimension of the [pixels] array is the y coordinate, | ||
/// second is the x coordinate. | ||
/// {@endtemplate} | ||
class MiniSprite { | ||
/// {@macro mini_sprite} | ||
MiniSprite(this.pixels); | ||
|
||
/// {@macro mini_sprite} | ||
/// | ||
/// Creates an empty sprite with the given width and height. | ||
MiniSprite.empty(int width, int height) | ||
: pixels = | ||
List.generate(height, (_) => List.generate(width, (_) => false)); | ||
|
||
/// {@macro mini_sprite} | ||
/// | ||
/// Returns a [MiniSprite] from the serialized data. | ||
factory MiniSprite.fromDataString(String value) { | ||
final blocks = value.split(';'); | ||
|
||
final size = blocks.removeAt(0).split(','); | ||
final height = int.parse(size[0]); | ||
final width = int.parse(size[1]); | ||
|
||
final flatten = blocks.map((rawBlock) { | ||
final blockSplit = rawBlock.split(','); | ||
|
||
final count = int.parse(blockSplit[0]); | ||
final value = int.parse(blockSplit[1]) == 1; | ||
|
||
return List.filled(count, value); | ||
}).fold<List<bool>>(List<bool>.empty(), (value, list) { | ||
return [ | ||
...value, | ||
...list, | ||
]; | ||
}); | ||
|
||
final pixels = List.generate( | ||
height, | ||
(_) => List.generate( | ||
width, | ||
(_) { | ||
return flatten.removeAt(0); | ||
}, | ||
), | ||
); | ||
|
||
return MiniSprite(pixels); | ||
} | ||
|
||
/// The matrix of pixels. | ||
final List<List<bool>> pixels; | ||
|
||
/// Returns this as a data string. | ||
String toDataString() { | ||
final dimensions = '${pixels.length},${pixels[0].length}'; | ||
|
||
var counter = 0; | ||
bool? last; | ||
|
||
final blocks = <String>[]; | ||
|
||
for (var y = 0; y < pixels.length; y++) { | ||
for (var x = 0; x < pixels[y].length; x++) { | ||
if (last == null) { | ||
last = pixels[y][x]; | ||
counter = 1; | ||
} else { | ||
if (last == pixels[y][x]) { | ||
counter++; | ||
} else { | ||
blocks.add('$counter,${last ? 1 : 0}'); | ||
last = pixels[y][x]; | ||
counter = 1; | ||
} | ||
} | ||
} | ||
} | ||
if (last != null) { | ||
blocks.add('$counter,${last ? 1 : 0}'); | ||
} | ||
|
||
return '$dimensions;${blocks.join(';')}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="WEB_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" /> | ||
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" /> | ||
<excludeFolder url="file://$MODULE_DIR$/.pub" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build" /> | ||
</content> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Dart SDK" level="project" /> | ||
<orderEntry type="library" name="Dart Packages" level="project" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: mini_sprite | ||
description: A simple sprite format for building 1bit styled graphics. | ||
version: 1.0.0+1 | ||
publish_to: none | ||
|
||
environment: | ||
sdk: ">=2.17.0 <3.0.0" | ||
|
||
dev_dependencies: | ||
coverage: ^1.1.0 | ||
mocktail: ^0.3.0 | ||
test: ^1.19.2 | ||
very_good_analysis: ^3.0.0 |
Oops, something went wrong.