region.scm 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. ;; *** create or destroy regions *************************************
  2. (import-lambda-definition-2 create-region () "scx_Create_Region")
  3. (import-xlib-function set-region (display gc r)
  4. "scx_Set_Region")
  5. (import-lambda-definition-2 destroy-region (r) "scx_Destroy_Region")
  6. ;; *** determine if regions are empty or equal ***********************
  7. (import-lambda-definition-2 empty-region? (r) "scx_Empty_Region")
  8. (import-lambda-definition-2 equal-region? (r1 r2) "scx_Equal_Region")
  9. (import-lambda-definition-2 point-in-region? (r x y) "scx_Point_In_Region")
  10. (define-enumerated-type rect-in-region-type :rect-in-region-type
  11. rect-in-region-type? rect-in-region-types rect-in-region-type-name
  12. rect-in-region-type-index
  13. (out in part))
  14. (define-exported-binding "scx-rect-in-region-type" :rect-in-region-type)
  15. (define-exported-binding "scx-rect-in-region-types" rect-in-region-types)
  16. (import-lambda-definition-2 rect-in-region? (r x y w h) "scx_Rect_In_Region")
  17. ;; *** region arithmetic *********************************************
  18. ;; intersect-region! computes the intersection of SRA and SRB and
  19. ;; stores the result in the region DR.
  20. (import-lambda-definition-2 intersect-region! (sra srb dr)
  21. "scx_Intersect_Region")
  22. (define (intersect-region sra srb)
  23. (let ((dr (create-region)))
  24. (intersect-region! sra srb dr)
  25. dr))
  26. (import-lambda-definition-2 union-region! (sra srb dr)
  27. "scx_Union_Region")
  28. (define (union-region sra srb)
  29. (let ((dr (create-region)))
  30. (union-region! sra srb dr)
  31. dr))
  32. (import-lambda-definition-2 union-rect-with-region! (x y w h src dest)
  33. "scx_Union_Rect_With_Region")
  34. (define (union-rect-with-region x y w h src)
  35. (let ((dr (create-region)))
  36. (union-rect-with-region! x y w h src dr)
  37. dr))
  38. (import-lambda-definition-2 subtract-region! (sra srb dr)
  39. "scx_Subtract_Region")
  40. (define (subtract-region sra srb)
  41. (let ((dr (create-region)))
  42. (subtract-region! sra srb dr)
  43. dr))
  44. (import-lambda-definition-2 xor-region! (sra srb dr)
  45. "scx_Xor_Region")
  46. (define (xor-region sra srb)
  47. (let ((dr (create-region)))
  48. (xor-region! sra srb dr)
  49. dr))
  50. (import-lambda-definition-2 offset-region! (r dx dy)
  51. "scx_Offset_Region")
  52. (import-lambda-definition-2 shrink-region! (r dx dy)
  53. "scx_Shrink_Region")
  54. ;; *** generate regions **********************************************
  55. ;; points has to be a list of pairs (x . y).
  56. (import-lambda-definition-2 polygon-region (points fill-rule)
  57. "scx_Polygon_Region")
  58. ;; clip-box returns a list (x y width height)
  59. (import-lambda-definition-2 clip-box (r)
  60. "scx_Clip_Box")