checkerspattern.h 683 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Checkers Pattern header
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #ifndef DORAYME_CHECKERSPATTERN_H
  10. #define DORAYME_CHECKERSPATTERN_H
  11. #include <stdio.h>
  12. class CheckersPattern : public Pattern
  13. {
  14. public:
  15. CheckersPattern(Colour a, Colour b) : Pattern(a, b) { };
  16. Colour patternAt(Tuple point)
  17. {
  18. double value = floor(point.x) + floor(point.y) + floor(point.z);
  19. return (modulo(value, 2) == 0)?this->a:this->b;
  20. }
  21. void dumpMe(FILE *fp) {
  22. fprintf(fp, "\"Type\": \"Checkers\",\n");
  23. Pattern::dumpMe(fp);
  24. }
  25. };
  26. #endif /* DORAYME_CHECKERSPATTERN_H */