On this page:
10.1 Clipping Helpers
clip-range
clip-rect
double-clip-range
double-clip-rect
clip-range/  scale
10.2 Sorting Helpers
order-pairs
10.3 Generic Syntax Variant Helpers
make-variant-id
8.10

10 RRLL: Helpers

Dominik Pantůček <dominik.pantucek@trustica.cz>

Racket Rogue-Like Library: Miscellaneous Helpers

These are miscellaneous modules containing commonly used algorithms and/or (optionally enabled) unsafe ops for some data structures.

10.1 Clipping Helpers

 (require rrll/helper/clipping) package: rrll-helpers

This module contains clipping helpers used by other RRLL packages.

procedure

(clip-range x w bx bw)  
fixnum? fixnum?
  x : fixnum?
  w : fixnum?
  bx : fixnum?
  bw : fixnum?
Makes sure the range from x (inclusive) to (+ x w) (exclusive) fits within the range bx (inclusive) to (+ bx bw) (exclusive).

Returns clipped x and w. If returned w is not positive?, it should be treated as empty range.

procedure

(clip-rect x y w h bx by bw bh)  
fixnum? fixnum? fixnum? fixnum?
  x : fixnum?
  y : fixnum?
  w : fixnum?
  h : fixnum?
  bx : fixnum?
  by : fixnum?
  bw : fixnum?
  bh : fixnum?
Uses clip-range to clip both horizontal and vertical range of a rectangle against another rectangle.

procedure

(double-clip-range sx sw dx dw)  
fixnum? fixnum? fixnum? fixnum?
  sx : fixnum?
  sw : fixnum?
  dx : fixnum?
  dw : fixnum?
Like clip-range but if dx is negative, makes sure it is 0 and adjusts sx accordingly before clipping it further.

Returns all four values clipped - although dw is never changed.

procedure

(double-clip-rect sx sy sw sh dx dy dw dh)  
fixnum?
fixnum?
fixnum?
fixnum?
fixnum?
fixnum?
fixnum?
fixnum?
  sx : fixnum?
  sy : fixnum?
  sw : fixnum?
  sh : fixnum?
  dx : fixnum?
  dy : fixnum?
  dw : fixnum?
  dh : fixnum?
Uses double-clip-range to clip a rectangle against another.

The dw and dh arguments are returned unchanged.

procedure

(clip-range/scale x w bx bw us ue)  
fixnum? fixnum? flonum? flonum?
  x : fixnum?
  w : fixnum?
  bx : fixnum?
  bw : fixnum?
  us : flonum?
  ue : flonum?
Like clip-range but also clips associated flonum? coordinates proportionally.

10.2 Sorting Helpers

 (require rrll/helper/ordering) package: rrll-helpers

This module contains helpers for sorting vertices of triangles on screen.

procedure

(order-pairs x1 y1 x2 y2 x3 y3)  
fixnum?
fixnum?
fixnum?
fixnum?
fixnum?
fixnum?
  x1 : fixnum?
  y1 : fixnum?
  x2 : fixnum?
  y2 : fixnum?
  x3 : fixnum?
  y3 : fixnum?
Returns the three pairs sorted by the Y-coordinate.

10.3 Generic Syntax Variant Helpers

 (require rrll/helper/syntax) package: rrll-helpers

This module reprovides all of racket/base for syntax stage and the make-variant-id for syntax stage as well.

procedure

(make-variant-id stx fmt sids ...)  syntax?

  stx : syntax?
  fmt : string?
  sids : any/c
Returns a new syntax identifier in the same scope as stx using fmt format string and format argument list sids.