home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-05-05 | 2.3 KB | 121 lines | [TEXT/CWIE] |
- unit MyMathUtils;
-
- interface
-
- uses
- Types;
-
- function Min (a, b: longint): longint;
- {$IFC not GENERATINGPOWERPC}
- inline
- $201F, $2E9F, $B097, $6C02, $2E80;
- {$ENDC}
-
- function Max (a, b: longint): longint;
- {$IFC not GENERATINGPOWERPC}
- inline
- $201F, $2E9F, $B097, $6F02, $2E80;
- {$ENDC}
-
- function Pin (a, b, c: longint): longint;
- {$IFC not GENERATINGPOWERPC}
- inline
- $201F, $221F, $B280, $6F02, $2200, $201F, $B280, $6C02, $2200, $2E81;
- {$ENDC}
-
- function Choose (cond: boolean; a, b: longint): longint;
- {$IFC not GENERATINGPOWERPC}
- inline
- $201F, $221F, $4A1F, $6602, $2200, $2E81;
- {$ENDC}
-
- function RectWidth( const r: Rect ): longint;
- function RectHeight( const r: Rect ): longint;
- procedure CenterRect (var rectA: Rect; const rectB: Rect);
- procedure OffsetRectTo( var r: Rect; h, v: integer );
- procedure OffsetPt( var pt: Point; dh, dv: integer );
-
- function GoodBNOT(x:longint): longint;
-
- implementation
-
- {$IFC GENERATINGPOWERPC}
- function Max (a, b: longint): longint;
- begin
- if a > b then begin
- Max := a;
- end else begin
- Max := b;
- end;
- end;
-
- function Min (a, b: longint): longint;
- begin
- if a < b then begin
- Min := a;
- end else begin
- Min := b;
- end;
- end;
-
- function Pin (a, b, c: longint): longint;
- begin
- if b < a then begin
- Pin := a;
- end else if b > c then begin
- Pin := c;
- end else begin
- Pin := b;
- end;
- end;
-
- function Choose (cond: boolean; a, b: longint): longint;
- begin
- if cond then begin
- Choose := a;
- end else begin
- Choose := b;
- end;
- end;
- {$ENDC}
-
- function RectWidth( const r: Rect ): longint;
- begin
- RectWidth := r.right - r.left;
- end;
-
- function RectHeight( const r: Rect ): longint;
- begin
- RectHeight := r.bottom - r.top;
- end;
-
- procedure CenterRect (var rectA: Rect; const rectB: Rect);
- var
- width, height: integer;
-
- begin
- width := RectWidth( rectA );
- height :=RectHeight( rectA );
- OffsetRectTo( rectA, rectB.left + ((RectWidth( rectB ) div 2) - (width div 2)), rectB.top + ((RectHeight( rectB ) div 2) - (height div 2)));
- end;
-
- procedure OffsetRectTo( var r: Rect; h, v: integer );
- begin
- r.right := h + RectWidth( r );
- r.bottom := v + RectHeight( r );
- r.left := h;
- r.top := v;
- end;
-
- procedure OffsetPt( var pt: Point; dh, dv: integer );
- begin
- pt.h := pt.h + dh;
- pt.v := pt.v + dv;
- end;
-
- function GoodBNOT(x:longint): longint;
- begin
- GoodBNOT := not(x);
- end;
-
- end.