|
|
@@ -0,0 +1,59 @@ |
|
|
|
/* |
|
|
|
* libpipi Proper image processing implementation library |
|
|
|
* Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org> |
|
|
|
* 2008 Jean-Yves Lamoureux <jylam@lnxscene.org |
|
|
|
* All Rights Reserved |
|
|
|
* |
|
|
|
* $Id$ |
|
|
|
* |
|
|
|
* This library is free software. It comes without any warranty, to |
|
|
|
* the extent permitted by applicable law. You can redistribute it |
|
|
|
* and/or modify it under the terms of the Do What The Fuck You Want |
|
|
|
* To Public License, Version 2, as published by Sam Hocevar. See |
|
|
|
* http://sam.zoy.org/wtfpl/COPYING for more details. |
|
|
|
*/ |
|
|
|
|
|
|
|
/* |
|
|
|
* bezier.c: bezier curves rendering functions |
|
|
|
*/ |
|
|
|
|
|
|
|
#include "config.h" |
|
|
|
#include "common.h" |
|
|
|
|
|
|
|
#include <stdio.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
#include "pipi.h" |
|
|
|
#include "pipi_internals.h" |
|
|
|
|
|
|
|
|
|
|
|
int pipi_draw_bezier4(pipi_image_t *img , |
|
|
|
int x1, int y1, |
|
|
|
int x2, int y2, |
|
|
|
int x3, int y3, |
|
|
|
int x4, int y4, |
|
|
|
uint32_t c, int n, int aa) |
|
|
|
{ |
|
|
|
if(img->last_modified == PIPI_PIXELS_RGBA_C) |
|
|
|
{ |
|
|
|
float t; |
|
|
|
float x= x1, y= y1; |
|
|
|
float lx, ly; |
|
|
|
for(t=0; t<1; t+=(1.0f/n)) |
|
|
|
{ |
|
|
|
float a = t; |
|
|
|
float b = 1 - t; |
|
|
|
|
|
|
|
lx = x; ly = y; |
|
|
|
|
|
|
|
x = (x1*(b*b*b)) + 3*x2*(b*b)*a + 3*x4*b*(a*a) + x3*(a*a*a); |
|
|
|
y = (y1*(b*b*b)) + 3*y2*(b*b)*a + 3*y4*b*(a*a) + y3*(a*a*a); |
|
|
|
|
|
|
|
pipi_draw_line(img , lx, ly, x, y, c, aa); |
|
|
|
} |
|
|
|
pipi_draw_line(img , x, y, x3, y3, c, aa); |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |