<commit_before>#include "shapes.h"

/* ---------------------------------- TEXT ---------------------------------- */
Text *createText(void *font, const char *string) {
    Text *newTxt = (Text *) malloc(sizeof(Text));

    newTxt->font = font;
    newTxt->string = string;

    newTxt->x = 0.0;
    newTxt->y = 0.0;

    return newTxt;
}

void drawText(Text *text) {
    if(text == NULL || text->font == NULL || text->string == NULL) return;

    int strsize = strlen(text->string);

    glRasterPos2f(text->x, text->y);

    int i = 0;
    for(i = 0; i < strsize; i++) {
        glutBitmapCharacter(text->font, text->string[i]);
    }
}

void freeText(Text *text) {
    if(text) {
        if(text->font != NULL){
            free(text->font);
            text->font = NULL;
        }
        free(text);
        text = NULL;
    }
}
/* ---------------------------------- TEXT ---------------------------------- */

/* -------------------------------- TRIANGLE -------------------------------- */

Triangle *createTriangle(float width, float height, int type){

    Triangle *newTri = (Triangle *) malloc(sizeof(Triangle));

    newTri->width = width;
    newTri->height = height;

    if (type == 0) {

      newTri->x[0] = 0.0;
      newTri->y[0] = 0.0;

      newTri->x[1] = width;
      newTri->y[1] = 0.0;

      newTri->x[2] = 0;
      newTri->y[2] = height;

    else {

      newTri->x[0] = 0.0;
      newTri->y[0] = 0.0;

      newTri->x[1] = width;
      newTri->y[1] = 0.0;

      newTri->x[2] = width/2;
      newTri->y[2] = height;
    }

    return newTri;
}

void setTriangleCoordinates(Triangle *tri, float x1, float y1, float x2,
                                           float y2, float x3, float y3) {
  if (tri == NULL) return;

  tri->x[0] = x1;
  tri->y[0] = y1;

  tri->x[1] = x2;
  tri->y[1] = y2;

  tri->x[2] = x3;
  tri->y[2] = y3;
}

void setTriangleColor(Triangle *tri, float r, float g, float b){
    if (tri == NULL) return;

    tri->color[0] = r;
    tri->color[1] = g;
    tri->color[2] = b;
}

void drawTriangle(Triangle *tri) {
    if(tri == NULL) return;

    glColor3f(tri->color[0], tri->color[1], tri->color[2]);

    glBegin(GL_TRIANGLES);
        glVertex2f(tri->x[0], tri->y[0]);
        glVertex2f(tri->x[1], tri->y[1]);
        glVertex2f(tri->x[2], tri->y[2]);
    glEnd();
}

void freeTriangle(Triangle *tri){
    if (tri) {
            free(tri);
            tri = NULL;
    }
}
/* -------------------------------- TRIANGLE -------------------------------- */

/* ----------------------------- QUADRILATERAL ------------------------------ */
// 0-------1
// |       |
// |       |
// 3-------2
// Quad Coordinates
Quadrilateral* createQuad(float c_x, float c_y, float width, float height, float thickness) {
    Quadrilateral* quad = (Quadrilateral *) malloc(sizeof(Quadrilateral));

    quad->width = width;
    quad->height = height;
    quad->thickness = thickness;

    quad->x[0] = c_x;
    quad->y[0] = c_y;

    quad->x[1] = c_x + width;
    quad->y[1] = c_y;

    quad->x[2] = c_x + width;
    quad->y[2] = c_y - height;

    quad->x[3] = c_x;
    quad->y[3] = c_y - height;

    return quad;
}

void setQuadColor(Quadrilateral *quad, float r, float g, float b){
    if (quad == NULL) return;

    quad->color[0] = r;
    quad->color[1] = g;
    quad->color[2] = b;
}

void drawQuadHollow(Quadrilateral* quad) {
    if (quad == NULL) return;

    glColor3f(quad->color[0], quad->color[1], quad->color[2]);

    glLineWidth(quad->thickness);
<commit_msg>c_x e c_y representao o centro do quadrado<commit_after>#include "shapes.h"

/* ---------------------------------- TEXT ---------------------------------- */
Text *createText(void *font, const char *string) {
    Text *newTxt = (Text *) malloc(sizeof(Text));

    newTxt->font = font;
    newTxt->string = string;

    newTxt->x = 0.0;
    newTxt->y = 0.0;

    return newTxt;
}

void drawText(Text *text) {
    if(text == NULL || text->font == NULL || text->string == NULL) return;

    int strsize = strlen(text->string);

    glRasterPos2f(text->x, text->y);

    int i = 0;
    for(i = 0; i < strsize; i++) {
        glutBitmapCharacter(text->font, text->string[i]);
    }
}

void freeText(Text *text) {
    if(text) {
        if(text->font != NULL){
            free(text->font);
            text->font = NULL;
        }
        free(text);
        text = NULL;
    }
}
/* ---------------------------------- TEXT ---------------------------------- */

/* -------------------------------- TRIANGLE -------------------------------- */

Triangle *createTriangle(float width, float height, int type){

    Triangle *newTri = (Triangle *) malloc(sizeof(Triangle));

    newTri->width = width;
    newTri->height = height;

    if (type == 0) {

      newTri->x[0] = 0.0;
      newTri->y[0] = 0.0;

      newTri->x[1] = width;
      newTri->y[1] = 0.0;

      newTri->x[2] = 0;
      newTri->y[2] = height;

    else {

      newTri->x[0] = 0.0;
      newTri->y[0] = 0.0;

      newTri->x[1] = width;
      newTri->y[1] = 0.0;

      newTri->x[2] = width/2;
      newTri->y[2] = height;
    }

    return newTri;
}

void setTriangleCoordinates(Triangle *tri, float x1, float y1, float x2,
                                           float y2, float x3, float y3) {
  if (tri == NULL) return;

  tri->x[0] = x1;
  tri->y[0] = y1;

  tri->x[1] = x2;
  tri->y[1] = y2;

  tri->x[2] = x3;
  tri->y[2] = y3;
}

void setTriangleColor(Triangle *tri, float r, float g, float b){
    if (tri == NULL) return;

    tri->color[0] = r;
    tri->color[1] = g;
    tri->color[2] = b;
}

void drawTriangle(Triangle *tri) {
    if(tri == NULL) return;

    glColor3f(tri->color[0], tri->color[1], tri->color[2]);

    glBegin(GL_TRIANGLES);
        glVertex2f(tri->x[0], tri->y[0]);
        glVertex2f(tri->x[1], tri->y[1]);
        glVertex2f(tri->x[2], tri->y[2]);
    glEnd();
}

void freeTriangle(Triangle *tri){
    if (tri) {
            free(tri);
            tri = NULL;
    }
}
/* -------------------------------- TRIANGLE -------------------------------- */

/* ----------------------------- QUADRILATERAL ------------------------------ */
// 0-------1
// |   .   |
// |       |
// 3-------2
// Quad Coordinates
Quadrilateral* createQuad(float c_x, float c_y, float width, float height, float thickness) {
    Quadrilateral* quad = (Quadrilateral *) malloc(sizeof(Quadrilateral));

    quad->width = width;
    quad->height = height;
    quad->thickness = thickness;

    quad->x[0] = c_x - width/2;
    quad->y[0] = c_y + height/2;

    quad->x[1] = c_x + width/2;
    quad->y[1] = c_y + height/2;

    quad->x[2] = c_x - width/2;
    quad->y[2] = c_y - height/2;

    quad->x[3] = c_x + width/2;
    quad->y[3] = c_y - height/2;

    return quad;
}

void setQuadColor(Quadrilateral *quad, float r, float g, float b){
    if (quad == NULL) return;

    quad->color[0] = r;
    quad->color[1] = g;
    quad->color[2] = b;
}

void drawQuadHollow(Quadrilateral* quad) {
    if (quad == NULL) return;

    glColor3f(quad->color[0], quad->color[1], quad->color[2]);

    glLineWidth(quad->thickness);

{'fraction_non_alphanumeric': 0.2632765178194112, 'fraction_numerical': 0.025637413720242287, 'mean_word_length': 1.6611694152923537, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 131, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '756274', 'n_tokens_mistral': 2670, 'n_tokens_neox': 2544, 'n_words': 533}