ringpattern.h 606 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Ring Pattern header
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #ifndef DORAYME_RINGSUPPORT_H
  10. #define DORAYME_RINGSUPPORT_H
  11. #include <pattern.h>
  12. class RingPattern : public Pattern
  13. {
  14. public:
  15. RingPattern(Colour a, Colour b) : Pattern(a, b) { };
  16. Colour patternAt(Tuple point)
  17. {
  18. Tuple distance = this->b - this->a;
  19. double fraction = point.x - floor(point.x);
  20. Tuple ret = this->a + distance * fraction;
  21. return Colour(ret.x, ret.y, ret.z);
  22. }
  23. };
  24. #endif //DORAYME_RINGSUPPORT_H