OCRudoku  v1.0
Resolve word grid with ease
Loading...
Searching...
No Matches
RenderingUtils.h File Reference
#include <SDL2/SDL.h>
Include dependency graph for RenderingUtils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  anchore_point
 

Typedefs

typedef struct anchore_point anchore_point
 

Functions

SDL_Rect anchore_to_rect (SDL_Window *window, anchore_point anchore)
 Converts an anchore_point to an SDL_Rect based on the window size.
 
void render_full_anchored_image_file (const char *file, SDL_Renderer *renderer, SDL_Window *window, anchore_point anchore)
 Renders an image file to the renderer using an anchore_point for positioning.
 
anchore_point rect_to_anchore (SDL_Rect rect)
 Converts an SDL_Rect to an anchore_point.
 
SDL_Rect to_positive_rect (SDL_Rect rect)
 Converts an SDL_Rect to a positive SDL_Rect.
 
anchore_point pixel_to_pourcent_anchore (SDL_Window *window, anchore_point anch)
 Converts pixel-based anchore_point offsets to percentage-based offsets.
 
SDL_Rect get_surface_full_rect (SDL_Surface *surface)
 Gets the full rectangle of an SDL_Surface.
 

Typedef Documentation

◆ anchore_point

typedef struct anchore_point anchore_point

Function Documentation

◆ anchore_to_rect()

SDL_Rect anchore_to_rect ( SDL_Window * window,
anchore_point anchore )

Converts an anchore_point to an SDL_Rect based on the window size.

This function takes an anchore_point structure and converts it into an SDL_Rect structure. The conversion is based on the size of the given SDL_Window. The resulting SDL_Rect will be positioned and sized according to the anchore_point's properties.

Parameters
windowA pointer to the SDL_Window from which the size will be obtained.
anchoreThe anchore_point structure containing the anchoring information.
Returns
SDL_Rect The resulting SDL_Rect structure after conversion.

◆ get_surface_full_rect()

SDL_Rect get_surface_full_rect ( SDL_Surface * surface)

Gets the full rectangle of an SDL_Surface.

This function returns an SDL_Rect structure that represents the full area of the given SDL_Surface. The rectangle's position will be set to (0, 0) and its width and height will match the surface's width and height.

Parameters
surfaceA pointer to the SDL_Surface from which the rectangle will be obtained.
Returns
SDL_Rect The resulting SDL_Rect structure representing the full area of the surface.

◆ pixel_to_pourcent_anchore()

anchore_point pixel_to_pourcent_anchore ( SDL_Window * window,
anchore_point anch )

Converts pixel-based anchore_point offsets to percentage-based offsets.

This function takes an anchore_point structure with pixel-based offsets and converts them to percentage-based offsets relative to the size of the given SDL_Window. The resulting anchore_point will have its offsets expressed as percentages of the window's width and height.

Parameters
windowA pointer to the SDL_Window from which the size will be obtained.
anchThe anchore_point structure containing the pixel-based offsets.
Returns
anchore_point The resulting anchore_point structure with percentage-based offsets.

◆ rect_to_anchore()

anchore_point rect_to_anchore ( SDL_Rect rect)

Converts an SDL_Rect to an anchore_point.

This function takes an SDL_Rect structure and converts it into an anchore_point structure. The conversion is based on the position and size of the given SDL_Rect. The resulting anchore_point will have its offsets set according to the SDL_Rect's properties.

Parameters
rectThe SDL_Rect structure containing the rectangle information.
Returns
anchore_point The resulting anchore_point structure after conversion.

◆ render_full_anchored_image_file()

void render_full_anchored_image_file ( const char * file,
SDL_Renderer * renderer,
SDL_Window * window,
anchore_point anchore )

Renders an image file to the renderer using an anchore_point for positioning.

This function renders an image file to the specified SDL_Renderer. The image is positioned and sized according to the provided anchore_point structure, which is converted to an SDL_Rect based on the size of the given SDL_Window.

Parameters
fileThe path to the image file to be rendered.
rendererA pointer to the SDL_Renderer where the image will be rendered.
windowA pointer to the SDL_Window from which the size will be obtained.
anchoreThe anchore_point structure containing the anchoring information.

◆ to_positive_rect()

SDL_Rect to_positive_rect ( SDL_Rect rect)

Converts an SDL_Rect to a positive SDL_Rect.

This function takes an SDL_Rect structure and ensures that its width and height are positive values. If the width or height is negative, it adjusts the x or y position accordingly and converts the width or height to a positive value.

Parameters
rectThe SDL_Rect structure to be converted.
Returns
SDL_Rect The resulting SDL_Rect structure with positive width and height.