رسم شكل هندسي بداخله رقم ؟
#1
السلام عليكم
بدي طريقة لرسم دائرة مثلاً وبداخلها رقم أنا بحدده بحيث أنو الرقم عم يتغير أثناء التنفيذ وعدد الدوائر
غير معروف(حسب التنفيذ) وإحداثيات كل دائرة يتغير
الرد
#2
وعليكم السلام
للرسم في الدلفي تستخدم Canvas مع دوال الرسم... إبدأ وسنساعدك إن شاء الله.
لرسم دائرة:
PHP كود :
var
  
i: Integer;

procedure DrawEllipse(X, Y: Integer; lpData: LParam); stdcall;

implementation

procedure DrawEllipse
(X, Y: Integer; lpData: LParam);
begin
  with TObject
(lpData) as TForm do
  
begin
    
if (i mod 10 = 0) then
      Canvas
.Ellipse(x-5, y-5, x+5, y+5);
    
Inc(i);
  
end;
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
  i 
:= 0;
  
LineDDA(0, 0, Width, Height, @DrawEllipse, Integer(yourForm));
end; 
بالتوفيق.
اللهم احقن دماء المسلمين، لا تنسوهم بالدعاء...
الرد
#3
عموما سأوجهك في استخدام Canvas وأنت ابحث أكثر...
أولا: راجع هذه الروابط جيدا:
كود :
http://www.functionx.com/delphi/gdi/drawing101.htm http://www.functionx.com/delphi/gdi/gdicoord.htm http://www.functionx.com/delphi/gdi/drawing1.htm

ثانيا: جرب هذه الدوال:
PHP كود :
Display the rotated text

procedure AngleTextOut
(ACanvas: TCanvas; Angle, X, Y: Integer; Str: string);
var
   
LogRec: TLogFont;
   
OldFontHandle,
   
NewFontHandle: hFont;
 
begin
   GetObject
(ACanvas.Font.Handle, SizeOf(LogRec), Addr(LogRec));
   
LogRec.lfEscapement := Angle*10;
   
NewFontHandle := CreateFontIndirect(LogRec);
   
OldFontHandle := SelectObject(ACanvas.Handle, NewFontHandle);
   
ACanvas.TextOut(X, Y, Str);
   
NewFontHandle := SelectObject(ACanvas.Handle, OldFontHandle);
   
DeleteObject(NewFontHandle);
 
end;
 -----------------------------------------------------------------------------
 
Rotating text on a canvas

// Use this procedure to rotate text on any canvas:

procedure RotateText(CV: TCanvas; const s: string; x, y, d: integer);
var
   
lf: TLogFont;
   
newFont, oldFont: HFONT;
begin
   GetObject
(CV.Font.Handle, SizeOf(lf), @lf);
   
lf.lfEscapement := d * 10;
   
lf.lfOrientation := lf.lfEscapement;
   
lf.lfPitchAndFamily := FIXED_PITCH or FF_DONTCARE;
   
lf.lfOutPrecision := OUT_TT_PRECIS;
   
lf.lfQuality := PROOF_QUALITY;
   
newFont := CreateFontIndirect(lf);
   
oldFont := SelectObject(CV.Handle, newFont);
   
SetBkMode(CV.Handle, TRANSPARENT);
   
CV.TextOut(x, y, s);
   
SelectObject(CV.Handle, oldFont);
   
DeleteObject(newFont);
end;

// d is the number of degrees to rotate. -----------------------------------------------------------------------------
Output text at any angle on canvas

Procedure CanvasTextOutAngle
(C:TCanvas; X,Y:Integer; Angle:Word; S:String);
Var
  
LogRec: TLOGFONT;
  
OldFontHandle,
  
NewFontHandle: HFONT;
Begin
  GetObject
(C.Font.Handle,SizeOf(LogRec),Addr(LogRec));
  
LogRec.lfEscapement:=Angle*10; {10th of a degree}
  
LogRec.lfOrientation:=Angle*10;
  
NewFontHandle := CreateFontIndirect(LogRec);
  
OldFontHandle := SelectObject(C.Handle,NewFontHandle);
  
C.Brush.Style := bsClear;
  
C.TextOut(X,Y,S);
  
NewFontHandle := SelectObject(C.Handle,OldFontHandle);
  
DeleteObject(NewFontHandle);
End;
----------------------------------------------------------------------
determine the 3rd point of an Equilateral Triangle from the other 2 points

procedure CreateEquilateralTriangle
(x1, y1, x2, y2: Double; var x3, y3: Double);
const 
  
Sin60 = 0.86602540378443864676372317075294;
const 
  
Cos60 = 0.50000000000000000000000000000000;
begin
  
{ Translate for x1,y1 to be origin }
  
x2 := x2 - x1;
  
y2 := y2 - y1;
  { 
Rotate 60 degrees and translate back }
  
x3 := ((x2 * Cos60) - (y2 * Sin60)) + x1;
  
y3 := ((y2 * Cos60) + (x2 * Sin60)) + y1;
end;
(* 
End Of Create Equilateral Triangle *)

---------------------------------------------------------------------------
find true angle of a vector or complex number (Arctan)

{
A simple but usefull tiny tip.
This version of Arctan is valid throughout the
interval 
[-PI/2;3/2*PI] unlike normally only ]-PI/2;PI/2[.
It is of use when you need to convert a given vector from rectangular to
polar format
. It is quite handy when you do complex numbers.
}
function 
ArcTan2(x, y: Double): Double;
var
  
retur: Double;
begin
  Retur 
:= 0.0;
  if 
ABS(x) < 0.000000001 then //Close to zero! We declare it to be zero!
  
begin //The small margin gives a slight error, but improves reliability.
    
if y > 0 then
    begin
      Retur 
:= PI / 2; //90 degrees
    
end
    
else
    
begin
      Retur 
:= PI / (-2); //-90 degrees
    
end;
  
end
  
else
  
begin
    
if x > 0 then // 1. or 4. quadrant
    
begin
      Retur 
:= ArcTan(Y / X); // Easy stuff. Normal ArcTan is valid for 1. and 4.
    
end
    
else // 2. or 3. quadrant
    
begin
      Retur 
:= PI - ArcTan(-Y / X);
    
end;
  
end;
  
ArcTan2 := Retur;
end; 
بالتوفيق أخي.
اللهم احقن دماء المسلمين، لا تنسوهم بالدعاء...
الرد


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم