Guest User

Untitled

a guest
Feb 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<graphics.h>
  3.  
  4. void boundaryFill(int x, int y, int fillColor, int boundColor) {
  5. int currentColor = getpixel(x,y);
  6. if((currentColor != fillColor) && (currentColor != boundColor)) {
  7. putpixel(x, y, fillColor);
  8. // delay(1); // <3
  9. boundaryFill(x+1, y, fillColor, boundColor);
  10. boundaryFill(x-1, y, fillColor, boundColor);
  11. boundaryFill(x, y+1, fillColor, boundColor);
  12. boundaryFill(x, y-1, fillColor, boundColor);
  13. }
  14. }
  15.  
  16. void floodFill(int x, int y, int fillColor, int oldColor) {
  17. int currentColor = getpixel(x,y);
  18. if((currentColor == oldColor)) {
  19. putpixel(x, y, fillColor);
  20. // delay(1); // <3
  21. floodFill(x+1, y, fillColor, oldColor);
  22. floodFill(x-1, y, fillColor, oldColor);
  23. floodFill(x, y+1, fillColor, oldColor);
  24. floodFill(x, y-1, fillColor, oldColor);
  25. }
  26. }
  27. void main() {
  28. int gd = DETECT, gm;
  29. initgraph(&gd, &gm, "C:\\TC\\BGI");
  30. setcolor(WHITE);
  31. circle(200, 200, 40);
  32. boundaryFill(200, 200, RED, WHITE);
  33. setcolor(YELLOW);
  34. line(400, 400, 450, 300);
  35. setcolor(GREEN);
  36. line(450, 300, 500, 400);
  37. setcolor(RED);
  38. line(400, 400, 500, 400);
  39. floodFill(450, 375, BLUE, BLACK);
  40. getch();
  41. closegraph();
  42. }
Add Comment
Please, Sign In to add comment