Skip to content

Commit 50d298b

Browse files
hozlucas28TiagoGiannottiGuidolinares
committed
feature: create setPatternCenter function
Co-authored-by: Tiago Giannotti <[email protected]> Co-authored-by: Guidolinares <[email protected]>
1 parent ea83f2b commit 50d298b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

libs/patterns/methods.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,12 @@ void printPatternByConsole(TPattern* pPattern) {
2525

2626
printf("\n");
2727
}
28+
}
29+
30+
void setPatternCenter(TPattern* pPattern) {
31+
int row = pPattern->rows / 2;
32+
int col = pPattern->cols / 2;
33+
34+
pPattern->center[0] = row;
35+
pPattern->center[1] = col;
2836
}

libs/patterns/methods.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,14 @@ void fillPattern(TPattern* pPattern, char with);
2323
*/
2424
void printPatternByConsole(TPattern* pPattern);
2525

26-
#endif // PATTERNS_METHODS_H_INCLUDED
26+
/**
27+
* @brief Sets the center of a pattern structure.
28+
*
29+
* @param pPattern A pointer to the pattern structure.
30+
*
31+
* @warning This function assumes that `pPattern` has been properly initialized with valid `rows`
32+
* and `cols` field values.
33+
*/
34+
void setPatternCenter(TPattern* pPattern);
35+
36+
#endif // PATTERNS_METHODS_H_INCLUDED

0 commit comments

Comments
 (0)