<commit_before>/*****************************************************************************
 * This file is part of gfxprim library.                                     *
 *                                                                           *
 * Gfxprim is free software; you can redistribute it and/or                  *
 * modify it under the terms of the GNU Lesser General Public                *
 * License as published by the Free Software Foundation; either              *
 * version 2.1 of the License, or (at your option) any later version.        *
 *                                                                           *
 * Gfxprim is distributed in the hope that it will be useful,                *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
 * Lesser General Public License for more details.                           *
 *                                                                           *
 * You should have received a copy of the GNU Lesser General Public          *
 * License along with gfxprim; if not, write to the Free Software            *
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,                        *
 * Boston, MA  02110-1301  USA                                               *
 *                                                                           *
 * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos                            *
 *                         <<EMAIL>>                  *
 *                                                                           *
 * Copyright (C) 2009-2010 <NAME> <<EMAIL>>                       *
 *                                                                           *
 *****************************************************************************/

/*
 * A filled circle drawing algorithm.
 *
 * A filled circle is drawn in the same way as an unfilled one,
 * in a top-down, line per line manner, except that we don't need to draw
 * four points in each X step. Instead, we just iterate X
 * until we accumulate enough Y changes to reach the next line,
 * and then draw the full line.
 */

/*
 * This macro defines a filled circle drawing function.
 * Arguments:
 *     CONTEXT_T - user-defined type of drawing context (passed to HLINE)
 *     PIXVAL_T  - user-defined pixel value type (passed to HLINE)
 *     HLINE     - horizontal line drawing function f(context, x0, x1, y, pixval)
 *     FN_NAME   - name of the function to be defined
 */
#define DEF_FILLCIRCLE_FN(FN_NAME, CONTEXT_T, PIXVAL_T, HLINE) \
void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, \
	unsigned int r, PIXVAL_T pixval) \
{ \
	int x, y, error; \
	for (x = 0, error = -r, y = r; y >= 0; y--) { \
		while (error < 0) { \
			error += 2*x + 1; \
			x++; \
		} \
		error += -2*y + 1; \
		HLINE(context, xcenter-x+1, xcenter+x-1, ycenter-y, pixval); \
		HLINE(context, xcenter-x+1, xcenter+x-1, ycenter+y, pixval); \
	} \
}
<commit_msg>Added a special case for circle with r == 0.<commit_after>/*****************************************************************************
 * This file is part of gfxprim library.                                     *
 *                                                                           *
 * Gfxprim is free software; you can redistribute it and/or                  *
 * modify it under the terms of the GNU Lesser General Public                *
 * License as published by the Free Software Foundation; either              *
 * version 2.1 of the License, or (at your option) any later version.        *
 *                                                                           *
 * Gfxprim is distributed in the hope that it will be useful,                *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
 * Lesser General Public License for more details.                           *
 *                                                                           *
 * You should have received a copy of the GNU Lesser General Public          *
 * License along with gfxprim; if not, write to the Free Software            *
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,                        *
 * Boston, MA  02110-1301  USA                                               *
 *                                                                           *
 * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos                            *
 *                         <jiri.bluebear.dl<EMAIL>>                  *
 *                                                                           *
 * Copyright (C) 2009-2010 <NAME> <<EMAIL>>                       *
 *                                                                           *
 *****************************************************************************/

/*
 * A filled circle drawing algorithm.
 *
 * A filled circle is drawn in the same way as an unfilled one,
 * in a top-down, line per line manner, except that we don't need to draw
 * four points in each X step. Instead, we just iterate X
 * until we accumulate enough Y changes to reach the next line,
 * and then draw the full line.
 */

/*
 * This macro defines a filled circle drawing function.
 * Arguments:
 *     CONTEXT_T - user-defined type of drawing context (passed to HLINE)
 *     PIXVAL_T  - user-defined pixel value type (passed to HLINE)
 *     HLINE     - horizontal line drawing function f(context, x0, x1, y, pixval)
 *     FN_NAME   - name of the function to be defined
 */
#define DEF_FILLCIRCLE_FN(FN_NAME, CONTEXT_T, PIXVAL_T, HLINE) \
void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, \
	unsigned int r, PIXVAL_T pixval) \
{ \
	/* for r == 0, circle degenerates to a point */ \
	if (r == 0) { \
		HLINE(context, xcenter, xcenter, ycenter, pixval); \
		return; \
	} \
\
	int x, y, error; \
	for (x = 0, error = -r, y = r; y >= 0; y--) { \
		while (error < 0) { \
			error += 2*x + 1; \
			x++; \
		} \
		error += -2*y + 1; \
		HLINE(context, xcenter-x+1, xcenter+x-1, ycenter-y, pixval); \
		HLINE(context, xcenter-x+1, xcenter+x-1, ycenter+y, pixval); \
	} \
}

{'fraction_non_alphanumeric': 0.12685258964143425, 'fraction_numerical': 0.013864541832669323, 'mean_word_length': 1.3799772468714449, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 42, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6589744', 'n_tokens_mistral': 1611, 'n_tokens_neox': 1480, 'n_words': 601}