Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

59 lignes
1.5 KiB

  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. * bezier.c: bezier curves rendering functions
  17. */
  18. #include "config.h"
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #include "pipi.h"
  23. #include "pipi_internals.h"
  24. int pipi_draw_bezier4(pipi_image_t *img ,
  25. int x1, int y1,
  26. int x2, int y2,
  27. int x3, int y3,
  28. int x4, int y4,
  29. uint32_t c, int n, int aa)
  30. {
  31. if(img->last_modified == PIPI_PIXELS_RGBA_U8)
  32. {
  33. float t;
  34. float x= x1, y= y1;
  35. float lx, ly;
  36. for(t=0; t<1; t+=(1.0f/n))
  37. {
  38. float a = t;
  39. float b = 1 - t;
  40. lx = x; ly = y;
  41. x = (x1*(b*b*b)) + 3*x2*(b*b)*a + 3*x4*b*(a*a) + x3*(a*a*a);
  42. y = (y1*(b*b*b)) + 3*y2*(b*b)*a + 3*y4*b*(a*a) + y3*(a*a*a);
  43. pipi_draw_line(img , lx, ly, x, y, c, aa);
  44. }
  45. pipi_draw_line(img , x, y, x3, y3, c, aa);
  46. }
  47. return 0;
  48. }