Рисование КРИВЫХ в Delphi 2



В: У кого-нибудь есть исходный код или какая-либо информация для рисования кривых Безье? Я должен использовать их в своем компоненте. Пожалуйста используйте для ответа мой адрес электронной почты.

Я решил ответить на этот крик души - причина?: 1. Не первый раз вижу подобный вопрос, 2. Задача настолько избита, что я без труда нашел ответ в своем архиве. (BTW: У меня есть более старые решения, чем это ;-P)

Тем не менее эта технология жива до сих пор и приносит свои плоды:


(********************************************************************)
(*                         GRAPHIX TOOLBOX 4.0                      *)
(*       Copyright (c) 1985, 87 by  Borland International, Inc.     *)
(********************************************************************)
unit GShell;

interface

{------------------------------ вырезано --------------------------}

procedure Bezier(A: PlotArray; MaxContrPoints: integer;
  var B: PlotArray; MaxIntPoints: integer);

implementation

{------------------------------ вырезано --------------------------}

procedure Bezier {(A : PlotArray; MaxContrPoints : integer;
var B : PlotArray; MaxIntPoints : integer)};
const
  MaxControlPoints = 25;
type
  CombiArray = array[0..MaxControlPoints] of Float;
var
  N: integer;
  ContrPoint, IntPoint: integer;
  T, SumX, SumY, Prod, DeltaT, Quot: Float;
  Combi: CombiArray;
begin
  MaxContrPoints := MaxContrPoints - 1;
  DeltaT := 1.0 / (MaxIntPoints - 1);
  Combi[0] := 1;
  Combi[MaxContrPoints] := 1;
  for N := 0 to MaxContrPoints - 2 do
    Combi[N + 1] := Combi[N] * (MaxContrPoints - N) / (N + 1);
  for IntPoint := 1 to MaxIntPoints do
  begin
    T := (IntPoint - 1) * DeltaT;
    if T <= 0.5 then
    begin
      Prod := 1.0 - T;
      Quot := Prod;
      for N := 1 to MaxContrPoints - 1 do
        Prod := Prod * Quot;
      Quot := T / Quot;
      SumX := A[MaxContrPoints + 1, 1];
      SumY := A[MaxContrPoints + 1, 2];
      for N := MaxContrPoints downto 1 do
      begin
        SumX := Combi[N - 1] * A[N, 1] + Quot * SumX;
        SumY := Combi[N - 1] * A[N, 2] + Quot * SumY;
      end;
    end
    else
    begin
      Prod := T;
      Quot := Prod;
      for N := 1 to MaxContrPoints - 1 do
        Prod := Prod * Quot;
      Quot := (1 - T) / Quot;
      SumX := A[1, 1];
      SumY := A[1, 2];
      for N := 1 to MaxContrPoints do
      begin
        SumX := Combi[N] * A[N + 1, 1] + Quot * SumX;
        SumY := Combi[N] * A[N + 1, 2] + Quot * SumY;
      end;
    end;
    B[IntPoint, 1] := SumX * Prod;
    B[IntPoint, 2] := SumY * Prod;
  end;
end; { Bezier }

end. { GShell }





Похожие по теме исходники

Рисование кривой звука

Рисование математических формул

Рисование компаса

Рисование стержней

 

Рисование Луны

Рисование по маске

Delphi Magazine

Tetris DelphiX

 

Quake Delphi Sources

Delphi MMOG

Delphi Яндекс Директ

Delphi to HTML Converter

 

Проверка знаний Delphi

Is Delphi Dying Monitor

Autosave Delphi 7