int main(int argc, char **argv) { char my_char = 'y'; param_test('y', 'z'); sub0(); sub1(&my_char); return 0; }
static void decasteljau(double tol, std::vector<sortedPoint> &discrete, int pos, const std::vector<SPoint3> &pts, double t0, double te) { int order = (int)pts.size() - 1; double dmax2 = 0; for (int i = 1; i < order ; ++i) dmax2 = std::max(dmax2, sqDistPointSegment(pts[i], pts[0], pts[order])); if(dmax2 < tol * tol) return; std::vector<SPoint3> sub0(pts.size()); std::vector<SPoint3> sub1(pts); for (int l = 0; l < order + 1; ++l) { sub0[l] = sub1[0]; for (int i = 0; i < order - l; ++i) sub1[i] = (sub1[i] + sub1[i + 1]) * 0.5; } double tmid = 0.5 * (t0 + te); int newpos = sortedPointInsert(sub1[0], tmid, discrete, pos); decasteljau(tol, discrete, pos, sub0, t0, tmid); decasteljau(tol, discrete, newpos, sub1, tmid, te); }
/* funkcja tworzy bloki tworzace tetramino, zwalnia pamiec juz istniejacych, * jesli takie sa */ void create_color_blocks(int size) { enum color i; /* zwalniam pamiec ze starych blokow jezeli istnieja */ for (i = 0; i < COLOR_COUNT; ++i) if (block[i] != NULL) SDL_FreeSurface(block[i]); /* tworze nowe klocki */ for (i = 0; i < COLOR_COUNT; ++i) { SDL_Rect r; Uint32 color; int th = size * 0.1f; block[i] = create_surface(size, size); /* srodek */ color = SDL_MapRGB(block[i]->format, block_color[i][0], block_color[i][1], block_color[i][2]); SDL_FillRect(block[i], NULL, color); /* gora i lewy bok */ color = SDL_MapRGB(block[i]->format, add0(block_color[i][0], COLOR_DIFF), add0(block_color[i][1], COLOR_DIFF), add0(block_color[i][2], COLOR_DIFF)); r.x = 0; r.y = 0; r.w = block[i]->w; r.h = th; SDL_FillRect(block[i], &r, color); r.w = th; r.h = block[i]->h - th; SDL_FillRect(block[i], &r, color); /* dol i prawy bok */ color = SDL_MapRGB(block[i]->format, sub0(block_color[i][0], COLOR_DIFF), sub0(block_color[i][1], COLOR_DIFF), sub0(block_color[i][2], COLOR_DIFF)); r.y = block[i]->h - th; r.w = block[i]->w; r.h = th; SDL_FillRect(block[i], &r, color); r.x = block[i]->w - th; r.y = r.w = th; r.h = block[i]->h - th; SDL_FillRect(block[i], &r, color); } // overlays Uint32 color; Uint8 alpha = 0x80; selectOverlay = create_surface(size, size); color = SDL_MapRGB(block[0]->format, 0, 0x80, 0xff); SDL_FillRect(selectOverlay, NULL, color); SDL_SetAlpha(selectOverlay, SDL_SRCALPHA, alpha); markOverlay = create_surface(size, size); color = SDL_MapRGB(block[0]->format, 0, 0, 0); SDL_FillRect(markOverlay, NULL, color); SDL_SetAlpha(markOverlay, SDL_SRCALPHA, alpha); previewOverlay = create_surface(size, size); color = SDL_MapRGB(block[0]->format, 0, 0xff, 0); SDL_FillRect(previewOverlay, NULL, color); SDL_SetAlpha(previewOverlay, SDL_SRCALPHA, alpha); invalidOverlay = create_surface(size, size); color = SDL_MapRGB(block[0]->format, 0xff, 0, 0); SDL_FillRect(invalidOverlay, NULL, color); SDL_SetAlpha(invalidOverlay, SDL_SRCALPHA, alpha); }