22 lines
659 B
C
Executable File
22 lines
659 B
C
Executable File
#include "grid.h"
|
|
|
|
int gridHelper(SDL_Rect* rect, int index, SDL_Rect screen, int zoom, int page){
|
|
#define MARGIN 20
|
|
#define MIN_PADDING 10
|
|
|
|
int x_amount = (screen.w - MARGIN * 2) / (MIN_PADDING + rect->w);
|
|
//int padding = ((screen.w - (MARGIN * 2) - (rect->w * x_amount)) / (x_amount-1));
|
|
//
|
|
int x_offset = ((screen.w - MARGIN * 2) / x_amount);
|
|
int y_offset = ((screen.w - MARGIN * 2) / x_amount);
|
|
|
|
int center = (x_offset - rect->w) / 2;
|
|
|
|
screen.w = 200;
|
|
|
|
rect->w = 40 + zoom;
|
|
rect->h = 40 + zoom;
|
|
rect->y = MARGIN + (y_offset * (index / x_amount)) + center;
|
|
rect->x = MARGIN + (x_offset * (index - (x_amount * (index / x_amount)))) + center;
|
|
}
|