Skip to content

Commit f1ba391

Browse files
committed
feat: release v1.1.0
1 parent efb9195 commit f1ba391

File tree

10 files changed

+88
-73
lines changed

10 files changed

+88
-73
lines changed

.vscode/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"cSpell.words": [
3+
"doublestruck",
4+
"figlet",
5+
"fullwidth",
6+
"grayscale",
7+
"hardblank",
8+
"hardblanks",
9+
"smush",
10+
"smushed",
11+
"Smushes",
12+
"smushing",
13+
"strikethrough"
14+
]
15+
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.1.0
2+
- update dependencies and improve documentation
3+
14
## 1.0.0
25
- `enough_ascii_art` is now [null safe](https://dart.dev/null-safety/tour) #127
36
- removed integration of fonts, as this is not supported by Dart

analysis_options.yaml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
# Defines a default set of lint rules enforced for
2-
# projects at Google. For details and rationale,
3-
# see https://github.com/dart-lang/pedantic#enabled-lints.
4-
include: package:pedantic/analysis_options.yaml
5-
6-
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
7-
# Uncomment to specify additional rules.
8-
# linter:
9-
# rules:
10-
# - camel_case_types
11-
12-
analyzer:
13-
# exclude:
14-
# - path/to/excluded/files/**
1+
include: package:lints/recommended.yaml

lib/enough_ascii_art.dart

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
/// Brought to you by 𝔼𝕟𝕠𝕦𝕘𝕙 𝕊𝕠𝕗𝕥𝕨𝕒𝕣𝕖
44
library enough_ascii_art;
55

6-
import 'package:enough_ascii_art/src/figlet/figlet.dart';
7-
import 'package:enough_ascii_art/src/figlet/font.dart';
8-
import 'package:enough_ascii_art/src/unicode_font_converter.dart';
96
import 'package:image/image.dart';
107
import 'src/figlet/figlet.dart';
8+
import 'src/figlet/font.dart';
119
import 'src/image_converter.dart';
1210
import 'src/emoticon_converter.dart';
11+
import 'src/unicode_font_converter.dart';
1312

1413
export 'src/image_converter.dart';
1514
export 'src/emoticon_converter.dart';
@@ -25,22 +24,26 @@ const String _asciiGrayScaleCharacters = '#@%=+*:-. ';
2524
///
2625
/// [image] the image to be converted
2726
/// [maxWidth] the optional maximum width of the image in characters, defaults to 80
28-
/// [maxHeight] the optional maximum height of th eimage in characters, defaults to null, so the image is caled linearily
29-
/// [charSet] the optional charset from darkest to lightest character, defaults to '#@%=+*:-. '
30-
/// [invert] allows to invert pixels, so that a dark pixel gets a bright characater and vise versa. This is useful when printing bight text on a dark background (console). Defaults to false.
27+
/// [maxHeight] the optional maximum height of th image in characters, defaults to null, so the image is called linearly
28+
/// [charset] the optional charset from darkest to lightest character, defaults to '#@%=+*:-. '
29+
/// [invert] allows to invert pixels, so that a dark pixel gets a bright character and vise versa. This is useful when printing bight text on a dark background (console). Defaults to false.
3130
/// [fontHeightCompensationFactor] the optional factor between 0 and 1 that is used to adjust the height of the image. Most fonts have a greater height than width, so this factor allows to compensate this. Defaults to 0.6.
32-
String convertImage(Image image,
33-
{int maxWidth = 80,
34-
int? maxHeight,
35-
String charset = _asciiGrayScaleCharacters,
36-
bool invert = false,
37-
double fontHeightCompensationFactor = 0.6}) {
38-
return ImageConverter.convertImage(image,
39-
maxWidth: maxWidth,
40-
maxHeight: maxHeight,
41-
charset: charset,
42-
invert: invert,
43-
fontHeightCompensationFactor: fontHeightCompensationFactor);
31+
String convertImage(
32+
Image image, {
33+
int maxWidth = 80,
34+
int? maxHeight,
35+
String charset = _asciiGrayScaleCharacters,
36+
bool invert = false,
37+
double fontHeightCompensationFactor = 0.6,
38+
}) {
39+
return ImageConverter.convertImage(
40+
image,
41+
maxWidth: maxWidth,
42+
maxHeight: maxHeight,
43+
charset: charset,
44+
invert: invert,
45+
fontHeightCompensationFactor: fontHeightCompensationFactor,
46+
);
4447
}
4548

4649
/// Replaces all common smileys with their ASCII representation
@@ -52,15 +55,21 @@ String convertEmoticons(String text,
5255
return EmoticonConverter.convertEmoticons(text, style);
5356
}
5457

55-
/// Rendes the given [text] in the specified [font].
58+
/// Renders the given [text] in the specified [font].
5659
///
57-
/// Optionally specify the [direction], which defaults to [FigletRenderDirection.LeftToRight]
58-
String renderFiglet(String text, Font font,
59-
{FigletRenderDirection direction = FigletRenderDirection.LeftToRight}) {
60+
/// Optionally specify the [direction], which defaults to [FigletRenderDirection.leftToRight]
61+
String renderFiglet(
62+
String text,
63+
Font font, {
64+
FigletRenderDirection direction = FigletRenderDirection.leftToRight,
65+
}) {
6066
return FIGlet.renderFIGure(text, font, direction: direction);
6167
}
6268

6369
/// Renders the given [text] in the specified [font].
64-
String renderUnicode(String text, UnicodeFont font) {
70+
String renderUnicode(
71+
String text,
72+
UnicodeFont font,
73+
) {
6574
return UnicodeFontConverter.encode(text, font);
6675
}

lib/src/figlet/figlet.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import 'package:enough_ascii_art/src/figlet/renderer.dart';
22

33
import 'font.dart';
44

5-
enum FigletRenderDirection { LeftToRight, TopToBottom }
5+
enum FigletRenderDirection { leftToRight, topToBottom }
66

77
/// Helper class to render a FIGure
88
class FIGlet {
9-
/// Rendes the given [text] in the specified [font].
9+
/// Renders the given [text] in the specified [font].
1010
///
11-
/// Optionally specify the [direction], which defaults to [FigletRenderDirection.LeftToRight]
11+
/// Optionally specify the [direction], which defaults to [FigletRenderDirection.leftToRight]
1212
static String renderFIGure(String text, Font font,
13-
{FigletRenderDirection direction = FigletRenderDirection.LeftToRight}) {
13+
{FigletRenderDirection direction = FigletRenderDirection.leftToRight}) {
1414
var renderer = Renderer();
1515
return renderer.render(text, font, direction);
1616
}

lib/src/figlet/renderer.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class Renderer {
1010
/// [text] the text to render
1111
/// [font] the FIGlet font to be used for rendering
1212
/// [maxLineWidth] the optional maximum width for a single line, currently ignored
13-
/// [horizontalLayouts] the optional rules for horizontal layouting
14-
/// [verticalLayouts] the options rules for vertical layouting, currently ignored
13+
/// [horizontalLayouts] the optional rules for horizontal layout
14+
/// [verticalLayouts] the options rules for vertical layout, currently ignored
1515
String render(
1616
String text,
1717
Font font,
@@ -21,7 +21,7 @@ class Renderer {
2121
List<VerticalLayout>? verticalLayouts,
2222
}) {
2323
horizontalLayouts ??= font.horizontalLayouts;
24-
if (direction == FigletRenderDirection.LeftToRight) {
24+
if (direction == FigletRenderDirection.leftToRight) {
2525
return _renderLR(text, font, horizontalLayouts!);
2626
} else {
2727
return _renderTB(text, font);
@@ -78,8 +78,8 @@ class _RenderLine {
7878
static const int _runeRightBracket = 93; // ]
7979
static const int _runeLeftBrace = 123; // {
8080
static const int _runeRightBrace = 125; // }
81-
static const int _runeLeftParenthese = 40; // (
82-
static const int _runeRightParenthese = 41; // )
81+
static const int _runeLeftParenthesis = 40; // (
82+
static const int _runeRightParenthesis = 41; // )
8383
static const int _runeForwardSlash = 47; // /
8484
static const int _runeBackwardSlash = 92; // \
8585
static const int _runeSmallerThan = 60; // <
@@ -95,8 +95,8 @@ class _RenderLine {
9595
_runeRightBracket,
9696
_runeLeftBrace,
9797
_runeRightBrace,
98-
_runeLeftParenthese,
99-
_runeRightParenthese,
98+
_runeLeftParenthesis,
99+
_runeRightParenthesis,
100100
_runeSmallerThan,
101101
_runeLargerThan
102102
];
@@ -221,10 +221,10 @@ class _RenderLine {
221221
rightRune == _runeRightBrace) || // {}
222222
(leftRune == _runeRightBrace &&
223223
rightRune == _runeLeftBrace) || // }{
224-
(leftRune == _runeLeftParenthese &&
225-
rightRune == _runeRightParenthese) || // ()
226-
(leftRune == _runeRightParenthese &&
227-
rightRune == _runeLeftParenthese)) // )(
224+
(leftRune == _runeLeftParenthesis &&
225+
rightRune == _runeRightParenthesis) || // ()
226+
(leftRune == _runeRightParenthesis &&
227+
rightRune == _runeLeftParenthesis)) // )(
228228
{
229229
// replace right character:
230230
isLayoutRuleAppliedForLine = true;
@@ -259,7 +259,7 @@ class _RenderLine {
259259

260260
// Universal smushing simply overrides the sub-character from the earlier FIGcharacter with the sub-character
261261
// from the later FIGcharacter.
262-
// This produces an "overlapping" effect with some FIGfonts, wherin the latter FIGcharacter may appear to be "in front".
262+
// This produces an "overlapping" effect with some FIGfonts, wherein the latter FIGcharacter may appear to be "in front".
263263
case HorizontalLayout.universalSmushing:
264264
isLayoutRuleAppliedForLine = true;
265265
break;

lib/src/image_converter.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import 'package:image/image.dart';
44
class ImageConverter {
55
static const String _asciiGrayScaleCharacters = '#@%=+*:-. ';
66

7-
/// Converts the image to ASCII text.
7+
/// Converts the [image] to ASCII text.
88
///
99
/// [image] the image to be converted
10-
/// [maxWidth] the optional maximum width of the image in characters, defaults to 80
11-
/// [maxHeight] the optional maximum height of the image in characters, defaults to null, so the image is scaled linearily
12-
/// [charSet] the optional charset from darkest to lightest character, defaults to '#@%=+*:-. '
13-
/// [invert] allows to invert pixels, so that a dark pixel gets a bright characater and vise versa. This is useful when printing bight text on a dark background (console). Defaults to false.
10+
/// [maxWidth] the optional maximum width of the image in characters, defaults to `80`
11+
/// [maxHeight] the optional maximum height of the image in characters, defaults to null, so the image is scaled linearly
12+
/// [charset] the optional charset from darkest to lightest character, defaults to '#@%=+*:-. '
13+
/// [invert] allows to invert pixels, so that a dark pixel gets a bright character and vise versa. This is useful when printing bight text on a dark background (console). Defaults to false.
1414
/// [fontHeightCompensationFactor] the optional factor between 0 and 1 that is used to adjust the height of the image. Most fonts have a greater height than width, so this factor allows to compensate this. Defaults to 0.6.
1515
static String convertImage(Image image,
1616
{int maxWidth = 80,
@@ -35,8 +35,7 @@ class ImageConverter {
3535
for (var y = 0; y < scaledImage.height; y++) {
3636
for (var x = 0; x < scaledImage.width; x++) {
3737
var pixel = scaledImage.getPixel(x, y);
38-
var grayscale =
39-
(pixel >> 16 & 0xff) | (pixel >> 8 & 0xff) | (pixel & 0xff);
38+
var grayscale = (pixel.r as int) | (pixel.g as int) | (pixel.b as int);
4039
var index = (grayscale * (charset.length - 1) / 255).floor();
4140
if (invert) {
4241
index = (charset.length - 1) - index;

lib/src/unicode_font_converter.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,14 @@ class UnicodeFontConverter {
219219
final to = _fonts[toFont]!;
220220
final buffer = StringBuffer();
221221
final characters = Characters(text);
222-
characters.forEach((element) {
222+
for (final element in characters) {
223223
final index = from.indexOf(element);
224224
if (index == -1) {
225225
buffer.write(element);
226226
} else {
227227
buffer.write(to[index]);
228228
}
229-
});
229+
}
230230
return buffer.toString();
231231
}
232232

pubspec.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
name: enough_ascii_art
2-
description: Generates ASCII art using image to ASCII, FIGlet text banner support and emoticon to text conversions.
3-
version: 1.0.0
2+
description: Generates ASCII art using image to ASCII, FIGlet text banner
3+
support and emoticon to text conversions.
4+
version: 1.1.0
45
homepage: https://github.com/Enough-Software/enough_ascii_art
56

67
environment:
78
sdk: '>=2.12.0 <3.0.0'
89

910
dependencies:
10-
image: ^3.0.5
1111
characters: ^1.1.0
12-
12+
image: ^4.0.0
13+
1314
dev_dependencies:
14-
pedantic: ^1.8.0
15-
test: ^1.6.0
15+
lints: ^2.0.1
16+
test: ^1.22.0

test/enough_ascii_art_test.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:enough_ascii_art/enough_ascii_art.dart';
2-
import 'package:enough_ascii_art/src/unicode_font_converter.dart';
32
import 'package:test/test.dart';
43

54
void main() {
@@ -21,13 +20,15 @@ void main() {
2120
group('Unicode font tests', () {
2221
test('Convert to double struck', () {
2322
expect(
24-
UnicodeFontConverter.encode('hello world', UnicodeFont.doublestruck),
25-
'𝕙𝕖𝕝𝕝𝕠 𝕨𝕠𝕣𝕝𝕕');
23+
UnicodeFontConverter.encode('hello world', UnicodeFont.doublestruck),
24+
'𝕙𝕖𝕝𝕝𝕠 𝕨𝕠𝕣𝕝𝕕',
25+
);
2626
});
2727
test('Convert to fraktur', () {
2828
expect(
29-
UnicodeFontConverter.encode('hello world', UnicodeFont.frakturBold),
30-
'𝖍𝖊𝖑𝖑𝖔 𝖜𝖔𝖗𝖑𝖉');
29+
UnicodeFontConverter.encode('hello world', UnicodeFont.frakturBold),
30+
'𝖍𝖊𝖑𝖑𝖔 𝖜𝖔𝖗𝖑𝖉',
31+
);
3132
});
3233
});
3334
}

0 commit comments

Comments
 (0)