Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

60 linhas
1.5 KiB

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