Skip to content

Commit 2331aba

Browse files
authored
Merge branch 'codewithnick:main' into main
2 parents 148e7d8 + 09e5dbc commit 2331aba

File tree

31 files changed

+10374
-1768
lines changed

31 files changed

+10374
-1768
lines changed

.github/issue-assigner.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Remove or comment the line from yml if you don't need that feature
2+
3+
# The name of bot you would like to be mentioned by users. {name} will be replaced by the below name
4+
name: "ASCII_BOT"
5+
6+
######################## Issue assignment ########################
7+
8+
# Prompt entered by user to request assign the issue to him/her
9+
assign-prompt: "@{name} claim" # For example, @issue-assigner claim
10+
11+
# Comment from bot if the issue got already assigned to the user requesting
12+
issue-already-assigned: "You have already been assigned to this issue."
13+
14+
# Maximum number of assignees for an issue
15+
max-assignees: 1
16+
17+
# Maximum number of assignees reached for the requested issue
18+
max-assignees-reached: "Sorry, maximum limit for assignees in this issue has reached. Please check other issues or contact a maintainer."
19+
20+
# Maximum number of open issues a user can have assigned at a time in the repo
21+
max-issues-for-user: 4
22+
23+
# If all OK, the comment from bot to tell that issue got assigned
24+
assigned-comment: "This issue has been successfully assigned to you! 🚀"
25+
26+
######################## Issue un-assignment ########################
27+
28+
# Prompt entered by user to request un-assignment of the issue to him/her
29+
unassign-prompt: "@{name} abandon"
30+
31+
# If the issue was already not assigned to the user
32+
issue-was-not-assigned: "You were not assigned to this issue."
33+
34+
# If criteria is matched, the issue will get un-assigned
35+
unassigned-comment: "You have been unassigned to this issue successfully."
36+
37+
######################## Issue Opened ########################
38+
39+
# If the user who opened issue is NOT a maintainer of the repo
40+
issue-opener-not-maintainer: "Thank you for opening this issue. You can wait for a discusssion with maintainers or Comment '@{name} claim' to get this issue assigned or '@{name} abandon' to get this issue unassigned."
41+
42+
# If the user who opened issue IS a maintainer of the repo
43+
issue-opener-is-maintainer: "Comment '@{name} claim' to get this issue assigned or '@{name} abandon' to get this issue unassigned."

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
readme_path: readme.md
1717
image_size: 70
1818
use_username: true
19-
columns_per_row: 7
19+
columns_per_row: 6

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
.vscode
77
.\test.cpp
88
CharGen
9+
example.cpp
10+
example

Ascii.h

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@
44
#define ASCII_H
55

66
#include <string>
7+
#include <memory>
78
#include "./Fonts/fonts.h"
89
#include "./Fonts/SevenStar/sevenstar.h"
910
#include "./Fonts/Boomer/boomer.h"
1011
#include "./Fonts/Straight/straight.h"
1112
#include "./Fonts/starwar/starwar.h"
12-
#include "./Fonts/Carlos/carlos.h"
13+
#include "./Fonts/carlos/carlos.h"
1314
#include "./Fonts/banner/banner.h"
15+
#include "./Fonts/block/block.h"
16+
#include "./Fonts/amongus/amongus.h"
17+
#include "./Fonts/drpepper/drpepper.h"
18+
#include "./Fonts/small/small.h"
19+
#include "./Fonts/3d-diagonal/3d-diagonal.h"
1420

1521
namespace ascii
1622
{
@@ -21,58 +27,82 @@ namespace ascii
2127
straight,
2228
starwar,
2329
carlos,
24-
banner
30+
banner,
31+
block,
32+
amongus,
33+
drpepper,
34+
small,
35+
threeD_diagonal
2536
};
2637

2738
class Ascii
2839
{
2940

3041
public:
31-
// std::string fontName;
32-
Fonts *font;
42+
std::unique_ptr<Fonts> font;
3343
Ascii(const FontName &fontName)
3444
{
35-
// std::cout<<"initialised ascii";
3645
if (fontName == FontName::sevenstar)
3746
{
38-
// std::cout<<"initialised sevenstar";
39-
this->font = new SevenStar();
47+
this->font.reset(new SevenStar());
4048
}
4149
else if (fontName == FontName::boomer)
4250
{
43-
// std::cout<<"initialised sevenstar";
44-
this->font = new Boomer();
51+
this->font.reset(new Boomer());
4552
}
4653
else if (fontName == FontName::straight)
4754
{
48-
49-
this->font = new Straight();
55+
this->font.reset(new Straight());
5056
}
5157
else if (fontName == FontName::starwar)
5258
{
53-
this->font = new Starwar();
59+
this->font.reset(new Starwar());
5460
}
5561
else if (fontName == FontName::carlos)
5662
{
57-
this->font = new Carlos();
63+
this->font.reset(new Carlos());
5864
}
5965
else if (fontName == FontName::banner)
6066
{
61-
// std::cout<<"initialised sevenstar";
62-
this->font = new Banner();
67+
this->font.reset(new Banner());
68+
}
69+
else if (fontName == FontName::block)
70+
{
71+
this->font.reset(new Block());
72+
}
73+
else if (fontName == FontName::amongus)
74+
{
75+
this->font.reset(new Amongus());
76+
}
77+
else if (fontName == FontName::drpepper)
78+
{
79+
this->font.reset(new Drpepper());
80+
}
81+
else if (fontName == FontName::small)
82+
{
83+
this->font.reset(new Small());
84+
}
85+
else if (fontName == FontName::threeD_diagonal)
86+
{
87+
this->font.reset(new ThreeD_Diagonal());
6388
}
6489
else
6590
{
6691
exit(500);
6792
}
6893
}
69-
void print(const std::string &text)
94+
95+
96+
void reset()
7097
{
98+
font->resetMatrix();
99+
}
71100

72-
char **character = nullptr;
73-
// std::cout<<"printing";
101+
void print(const std::string &text)
102+
{
103+
vs character;
74104

75-
for (int i = 0; i < text.size(); i++)
105+
for (size_t i = 0; i < text.size(); i++)
76106
{
77107
char c = text[i];
78108

@@ -206,14 +236,14 @@ namespace ascii
206236
else if (c == '9')
207237
character = font->nine();
208238

209-
//for space
239+
// for space
210240
else if (c == ' ')
211241
character = font->space();
212242

213243
font->pushChar(character);
214244
}
215245
font->printvector();
216-
// font->destroyspace();
246+
font->resetMatrix();
217247
}
218248
};
219249
} // namespace ascii

CONTRIBUTING.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,46 @@
22

33
Changes and improvements are more than welcome! ❤ Feel free to fork and open a pull request.
44

5+
To read The Technical aspects you might want to refer [This](./Documentation/Structure.md)
6+
57
Please consider the following :
68

79
1. Fork it!
8-
2. Add your new features
9-
- To add a new font visit [here](#font)
10-
- To add a new character visit [here](#new-char)
10+
2. Open an issue, if it does not already exist (Example: Add char 'A' in DrPepper Font) and ask to get assigned.
11+
3. Add your new features
12+
- To add a new font visit [here](#add-a-new-font)
13+
- To add a new character visit [here](#add-a-new-char-in-a-font)
14+
4. Update README.md (if needed)
15+
5. Add Screenshots of your working file
16+
6. Send us a pull request.
17+
18+
## Things you can do
19+
20+
### Improve The Documentation
21+
22+
Good Documentation is a Base for every code base , if you feel there is something missing , not clear in the docs or code needs more comments or can be made prettier, or ever if you find a typo, You can Contribute to Documentation.
23+
24+
1. Open an issue and mention the possible areas of improvement.
25+
2. Wait for discussion with maintainers and get assigned.
26+
3. Improve the documentation and send us a new Pull Request.
27+
28+
### Report/Fix a Bad Character in a Font
1129

12-
3. Update README.md (if needed)
13-
4. Submit a pull request.
30+
1. Open a new issue and post screenshots of the terminal.
31+
2. Mention the font and character which has a problem.
32+
3. Mention Expected and Actual result
1433

15-
## Font
34+
### Add a new Font
1635

1736
1. Select a non-duplicate name for font
1837
2. Copy the fontname directory from templates directory to Fonts directoy. Rename this directory to the name of your font
1938
3. In that directory, rename the header file and the md file to the name of your font.
2039
4. Set the specified grid size for your font in the appropriate macro fields.
2140
5. Now, In "Ascii.h" #include your font
22-
6. then, Add the condition of your font in the if else block
23-
7. Add some previews to the md file.
41+
6. Then, Add the condition of your font in the if else block
42+
7. Add some previews to the md file.
2443

25-
## New-Char
44+
### Add a New-Char in a Font
2645

2746
1. Select a character which is not previously used in a font
2847
2. In your selected font's header file uncomment the respective function.

Documentation/Structure.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This file contains the abstract working of the codebase
2+
3+
## Structure
4+
5+
### Font class:
6+
7+
It is the parent of all font classes (amongus,drpepper,etc) all other font classes inherit attributes and methods from this class , the virtual functions are overridden in the child classes and are triggered on runtime using runtime polymorphism.
8+
9+
##### Attributes and Methods:
10+
11+
###### Private:
12+
13+
`vector<vector<char>> letters;`
14+
2D vector to store the characters in each of the font
15+
This vector is what is actually printed on the screen
16+
17+
`unsigned int def_rows;`
18+
Total number of rows in the font
19+
`unsigned int def_cols;`
20+
Total number of columns in the font
21+
`unsigned int char_rows;`
22+
The row size of each character in the font
23+
`unsigned int char_cols;`
24+
The column size of each character in the font
25+
`unsigned int curr_col;`
26+
The current position of the column in the font,
27+
Keeping track of this helps us insert new characters into the letters vector
28+
29+
###### Protected:
30+
`char **getCharGrid(unsigned int rows = 0, unsigned int cols = 0)`
31+
return a 2D character grid of size `rows` and `cols` with each `char=' '`, which can be overwritten later, basically helps in creating new memory space for characters
32+
33+
###### Public:
34+
35+
`Fonts::Fonts(int def_rows, int def_cols)`
36+
37+
This constructor initializes the rows and columns of the font
38+
and fills the vector `this.letter` with spaces
39+
40+
`void printvector()`
41+
42+
This function dumps the 2D vector `this.letter` on the screen
43+
44+
`void pushchar(**character)`
45+
46+
This function pushes a character into the 2D vector `this.letter` at the current column `curr_col` position
47+
48+
**All Virtual functions:**
49+
These are to be overwriten in the child classes as each letter will be different in each font, each function is supposed to return a 2D character grid of the respective character
50+
virtual functions include:
51+
`virtual char **a()` to `virtual char **z()`
52+
`virtual char **A()` to `virtual char **Z()`
53+
`virtual char **Zero()` to `virtual char **Nine()`
54+
`virtual char **space()`

0 commit comments

Comments
 (0)