penrose-legacy.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* penrose-legacy.h: legacy Penrose tiling functions.
  2. *
  3. * Provides an interface with which to generate Penrose tilings
  4. * by recursive subdivision of an initial tile of choice (one of the
  5. * four sets of two pairs kite/dart, or thin/thick rhombus).
  6. *
  7. * You supply a callback function and a context pointer, which is
  8. * called with each tile in turn: you choose how many times to recurse.
  9. *
  10. * This method of generating Penrose tiling fragments is superseded by
  11. * the completely different algorithm in penrose.c. We keep the legacy
  12. * algorithm around only for interpreting Loopy game IDs generated by
  13. * older versions of the code.
  14. */
  15. #ifndef PUZZLES_PENROSE_LEGACY_H
  16. #define PUZZLES_PENROSE_LEGACY_H
  17. #ifndef PHI
  18. #define PHI 1.6180339887
  19. #endif
  20. typedef struct vector vector;
  21. double penrose_legacy_vx(vector *vs, int i);
  22. double penrose_legacy_vy(vector *vs, int i);
  23. typedef struct penrose_legacy_state penrose_legacy_state;
  24. /* Return non-zero to clip the tree here (i.e. not recurse
  25. * below this tile).
  26. *
  27. * Parameters are state, vector array, npoints, depth.
  28. * ctx is inside state.
  29. */
  30. typedef int (*tile_callback)(penrose_legacy_state *, vector *, int, int);
  31. struct penrose_legacy_state {
  32. int start_size; /* initial side length */
  33. int max_depth; /* Recursion depth */
  34. tile_callback new_tile;
  35. void *ctx; /* for callback */
  36. };
  37. #ifndef PENROSE_ENUM_DEFINED
  38. #define PENROSE_ENUM_DEFINED
  39. enum { PENROSE_P2, PENROSE_P3 };
  40. #endif
  41. extern int penrose_legacy(penrose_legacy_state *state, int which, int angle);
  42. /* Returns the side-length of a penrose tile at recursion level
  43. * gen, given a starting side length. */
  44. extern double penrose_legacy_side_length(double start_size, int depth);
  45. /* Calculate start size and recursion depth required to produce a
  46. * width-by-height sized patch of penrose tiles with the given tilesize */
  47. extern void penrose_legacy_calculate_size(
  48. int which, int tilesize, int w, int h,
  49. double *required_radius, int *start_size, int *depth);
  50. #endif