Loading...
Searching...
No Matches
obround.c File Reference
`#include "arc/graphics/obround.h"`
`#include "renderer.h"`
`#include <stdlib.h>`

Go to the source code of this file.

## Functions

void | ARC_Obround_Render (ARC_Obround *obround, ARC_Renderer *renderer, ARC_Color *color)
void | ARC_FObround_Render (ARC_FObround *obround, ARC_Renderer *renderer, ARC_Color *color)

## Function Documentation

## ARC_FObround_Render()

void ARC_FObround_Render | ( | ARC_FObround * | obround,
|  | ARC_Renderer * | renderer,
|  | ARC_Color * | color )

Definition at line 45 of file obround.c.

{
ARC_Obround casted = ARC_FObround_CastToObround(obround);
ARC_Obround_Render(&casted, renderer, color);
}
ARC_Obround_Render
void ARC_Obround_Render(ARC_Obround *obround, ARC_Renderer *renderer, ARC_Color *color)
Definition obround.c:6
ARC_FObround_CastToObround
ARC_Obround ARC_FObround_CastToObround(ARC_FObround *obround)
casts FObround to Obround
Definition obround.c:12
ARC_Obround
Definition obround.h:10

References ARC_FObround_CastToObround(), and ARC_Obround_Render().

## ARC_Obround_Render()

void ARC_Obround_Render | ( | ARC_Obround * | obround,
|  | ARC_Renderer * | renderer,
|  | ARC_Color * | color )

Definition at line 6 of file obround.c.

{
SDL_SetRenderDrawColor((SDL_Renderer *)renderer, color->r, color->g, color->b, color->a);
int32_t diameter = (obround->r * 2);
int32_t x = (obround->r - 1);
int32_t y = 0;
int32_t tx = 1;
int32_t ty = 1;
int32_t error = (tx - diameter);
SDL_RenderDrawLine((SDL_Renderer *)renderer, obround->x - obround->r, obround->y - (obround->h / 2), obround->x - obround->r, obround->y + (obround->h / 2));
SDL_RenderDrawLine((SDL_Renderer *)renderer, obround->x + obround->r, obround->y - (obround->h / 2), obround->x + obround->r, obround->y + (obround->h / 2));
while(x >= y){
// Each of the following renders an octant of the circle
SDL_RenderDrawPoint((SDL_Renderer *)renderer, obround->x + x, obround->y - y - (obround->h / 2));
SDL_RenderDrawPoint((SDL_Renderer *)renderer, obround->x + x, obround->y + y + (obround->h / 2));
SDL_RenderDrawPoint((SDL_Renderer *)renderer, obround->x - x, obround->y - y - (obround->h / 2));
SDL_RenderDrawPoint((SDL_Renderer *)renderer, obround->x - x, obround->y + y + (obround->h / 2));
SDL_RenderDrawPoint((SDL_Renderer *)renderer, obround->x + y, obround->y - x - (obround->h / 2));
SDL_RenderDrawPoint((SDL_Renderer *)renderer, obround->x + y, obround->y + x + (obround->h / 2));
SDL_RenderDrawPoint((SDL_Renderer *)renderer, obround->x - y, obround->y - x - (obround->h / 2));
SDL_RenderDrawPoint((SDL_Renderer *)renderer, obround->x - y, obround->y + x + (obround->h / 2));
if(error <= 0){
++y;
error += ty;
ty += 2;
}
if(error > 0){
--x;
tx += 2;
error += (tx - diameter);
}
}
}
ARC_Color::a
uint8_t a
Definition color.h:11
ARC_Color::r
uint8_t r
Definition color.h:11
ARC_Color::b
uint8_t b
Definition color.h:11
ARC_Color::g
uint8_t g
Definition color.h:11
ARC_Obround::r
int32_t r
Definition obround.h:13
ARC_Obround::x
int32_t x
Definition obround.h:11
ARC_Obround::y
int32_t y
Definition obround.h:12
ARC_Obround::h
int32_t h
Definition obround.h:14

References ARC_Color::a, ARC_Color::b, ARC_Color::g, ARC_Obround::h, ARC_Color::r, ARC_Obround::r, ARC_Obround::x, and ARC_Obround::y.

Referenced by ARC_FObround_Render().