Files
lazarus-ccr/components/mbColorLib/mbutils.pas
wp_xxyyzz 5221fae91e mbColorLib: Improved handling of hints.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5464 8e941d3f-bd1b-0410-a28a-d453659cc2b4
2016-12-12 12:51:46 +00:00

38 lines
729 B
ObjectPascal

unit mbUtils;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
procedure Clamp(var AValue:Integer; AMin, AMax: Integer);
function PointInCircle(p: TPoint; Size: integer): boolean;
function PtInCircle(p, ctr: TPoint; Radius: Integer): Boolean;
implementation
procedure Clamp(var AValue: integer; AMin, AMax: integer);
begin
if AValue < AMin then AValue := AMin;
if AValue > AMax then AValue := AMax;
end;
function PointInCircle(p: TPoint; Size: integer): boolean;
var
r: integer;
begin
r := size div 2;
Result := (sqr(p.x - r) + sqr(p.y - r) <= sqr(r));
end;
function PtInCircle(p, ctr: TPoint; Radius: Integer): Boolean;
begin
Result := sqr(p.x - ctr.x) + sqr(p.y - ctr.y) <= sqr(Radius);
end;
end.