int ft_mouse(int button, int x, int y, t_mlx *mlx) { double u; double v; u = (WIN_W - (double)x * 2.0) / WIN_H; v = (WIN_H - (double)y * 2.0) / WIN_W; if (button == 1 && (x >= 0 && x <= WIN_W) && (y >= 0 && y <= WIN_H)) { mlx_clear_window(mlx->mlx, mlx->win); mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->img, 0, 0); if ((mlx->tmp = ft_seek(u, v, (t_vec){mlx->cam_pos.x + u, mlx->cam_pos.y + v, mlx->cam_pos.z}, mlx)) == NULL) { MSP(mlx->mlx, mlx->win, 630, 720, 0x00FEDC, "no selection"); mlx->selection = 0; return (0); } ft_string_put(mlx); MSP(mlx->mlx, mlx->win, 630, 735, 0x00FEDC, mlx->pos); free(mlx->pos); //(TMP->type != 4) ? free(mlx->rot) : NULL; mlx->selection = 1; } return (0); }
void draw_winner(t_env *e) { int i; char *s[2]; t_clist *save; i = 15; save = e->clist; while (save) { if (save->client_nb == 0) { save = save->next; continue ; } i += 15; asprintf(&s[0], PL3, save->client_nb, save->lvl, save->posy, save->posx, fill_ori(save), save->inv[0], save->inv[1], save->inv[2], save->inv[3], save->inv[4], save->inv[5], save->inv[6], save->teamname); mlx_string_put(e->mlx->mlx, e->mlx->win2, 5, i, WHITE, s[0]); save = save->next; free(s[0]); } i += 15; asprintf(&s[0], "%s won the game !", e->winner); MSP(MLX->mlx, MLX->win2, INFO_WIDTH / 2 - STR_WIN_LEN, i, WHITE, s[0]); }
static PyObject * _minrep(PyObject *self, PyObject *args) { // compares two cyclic strings and returns alphabetically smallest // cyclic shift of the string which contains the smallest such shift // from the pair Py_buffer inputA, inputB, *tmp; if (!PyArg_ParseTuple(args, "y*y*", &inputA, &inputB)) { return NULL; } unsigned int inputA_msp, inputB_msp, inputA_period, inputB_period; inputA_msp = MSP(inputA.len, inputA.buf, &inputA_period); inputB_msp = MSP(inputB.len, inputB.buf, &inputB_period); // positive result: A < B, negative result: A > B, zero: A == B int result = COMPARE2(inputA.len, inputB.len, inputA.buf, inputB.buf, inputA_msp, inputB_msp); // decide between A and B unsigned int tmp_msp; if (result > 0) { // A < B tmp_msp = inputA_msp; tmp = &inputA; } else if (result < 0) { // B < A tmp_msp = inputB_msp; tmp = &inputB; } else if (inputB.len < inputA.len) { // A == B, len(B) < len(A) tmp_msp = inputB_msp; tmp = &inputB; } else { // A == B, len(A) <= len(B) tmp_msp = inputA_msp; tmp = &inputA; } minrep_inplace_msp(tmp->buf, tmp->len, tmp_msp); return Py_BuildValue("s#", tmp->buf, tmp->len); }
void ft_string_put(t_mlx *mlx) { char *s; s = (TMP->type != 3) ? ft_strjoin("size: ", ft_itoa(TMP->size), 'R') : NULL; ft_tmp_string(mlx); if (TMP->type == 1 || TMP->type == 2) { if (TMP->type == 1) MSP(mlx->mlx, mlx->win, 630, 720, 0x00FEDC, "object: cone"); if (TMP->type == 2) MSP(mlx->mlx, mlx->win, 630, 720, 0x00FEDC, "object: cylinder"); //MSP(mlx->mlx, mlx->win, 630, 750, 0x00FEDC, mlx->rot); MSP(mlx->mlx, mlx->win, 630, 765, 0x00FEDC, s); } else if (TMP->type == 3) { MSP(mlx->mlx, mlx->win, 630, 720, 0x00FEDC, "object: plane"); //MSP(mlx->mlx, mlx->win, 630, 750, 0x00FEDC, mlx->rot); } else if (TMP->type == 4) { MSP(mlx->mlx, mlx->win, 630, 720, 0x00FEDC, "object: sphere"); MSP(mlx->mlx, mlx->win, 630, 765, 0x00FEDC, s); } (TMP->type != 3) ? free(s) : NULL; }
int main(int argc, const char** argv) { if (argc != 2) { fprintf(stderr, "An argument must be provided: string of letters or digits\n"); return EXIT_FAILURE; } unsigned int d; size_t n = strlen(argv[1]); char *str = malloc(sizeof(char) * (n + 1)); minrep(str, argv[1], n); str[n] = '\0'; unsigned int msp = MSP(n, argv[1], &d); fprintf(stdout, "%d\t%d\t%s\n", msp + 1, d, str); free(str); return EXIT_SUCCESS; }