source: libpipi/trunk/pipi/paint/bezier.c @ 2902

Last change on this file since 2902 was 2902, checked in by Sam Hocevar, 11 years ago

Support C99 types on Win32 through the same hacks as in libcaca.

File size: 1.5 KB
Line 
1/*
2 *  libpipi       Pathetic image processing interface library
3 *  Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
4 *                2008 Jean-Yves Lamoureux <jylam@lnxscene.org
5 *                All Rights Reserved
6 *
7 *  $Id$
8 *
9 *  This library is free software. It comes without any warranty, to
10 *  the extent permitted by applicable law. You can redistribute it
11 *  and/or modify it under the terms of the Do What The Fuck You Want
12 *  To Public License, Version 2, as published by Sam Hocevar. See
13 *  http://sam.zoy.org/wtfpl/COPYING for more details.
14 */
15
16/*
17 * bezier.c: bezier curves rendering functions
18 */
19
20#include "config.h"
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <string.h>
25
26#include "pipi.h"
27#include "pipi_internals.h"
28
29
30int pipi_draw_bezier4(pipi_image_t *img ,
31                      int x1, int y1,
32                      int x2, int y2,
33                      int x3, int y3,
34                      int x4, int y4,
35                      uint32_t c, int n, int aa)
36{
37    if(img->last_modified == PIPI_PIXELS_RGBA_C)
38    {
39        float t;
40        float x= x1, y= y1;
41        float lx, ly;
42        for(t=0; t<1; t+=(1.0f/n))
43        {
44            float a = t;
45            float b = 1 - t;
46
47            lx = x; ly = y;
48
49            x = (x1*(b*b*b)) + 3*x2*(b*b)*a + 3*x4*b*(a*a) + x3*(a*a*a);
50            y = (y1*(b*b*b)) + 3*y2*(b*b)*a + 3*y4*b*(a*a) + y3*(a*a*a);
51
52            pipi_draw_line(img , lx, ly, x, y, c, aa);
53        }
54        pipi_draw_line(img , x, y, x3, y3, c, aa);
55    }
56
57    return 0;
58}
Note: See TracBrowser for help on using the repository browser.