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

Last change on this file since 2844 was 2844, checked in by Sam Hocevar, 12 years ago

Fix headers.

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#include "common.h"
22
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26
27#include "pipi.h"
28#include "pipi_internals.h"
29
30
31int pipi_draw_bezier4(pipi_image_t *img ,
32                      int x1, int y1,
33                      int x2, int y2,
34                      int x3, int y3,
35                      int x4, int y4,
36                      uint32_t c, int n, int aa)
37{
38    if(img->last_modified == PIPI_PIXELS_RGBA_C)
39    {
40        float t;
41        float x= x1, y= y1;
42        float lx, ly;
43        for(t=0; t<1; t+=(1.0f/n))
44        {
45            float a = t;
46            float b = 1 - t;
47
48            lx = x; ly = y;
49
50            x = (x1*(b*b*b)) + 3*x2*(b*b)*a + 3*x4*b*(a*a) + x3*(a*a*a);
51            y = (y1*(b*b*b)) + 3*y2*(b*b)*a + 3*y4*b*(a*a) + y3*(a*a*a);
52
53            pipi_draw_line(img , lx, ly, x, y, c, aa);
54        }
55        pipi_draw_line(img , x, y, x3, y3, c, aa);
56    }
57
58    return 0;
59}
Note: See TracBrowser for help on using the repository browser.