Şimdi Ara

Windows 10 hesap makinesine, denklem çizebilme özelliği ekleniyor

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
1 Misafir - 1 Masaüstü
5 sn
6
Cevap
0
Favori
270
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj

  • Microsoft, Windows 10'daki Hesap Makinesi uygulaması için önemli bir yeni özellik üzerinde çalışıyor. Şirket uygulamayı bu ayın başlarında GitHub'da açık kaynaklı hale getirmişti ve şu ana kadar otuzdan fazla kişinin bu konuda katkıda bulunduğu ifade ediliyor.

     


    Öğrencilerin cebir öğrenmesini kolaylaştıracak


    Yeni bir rapora göre Microsoft, Hesap Makinesi uygulamasına bir grafik modu eklemek için çalışıyor. Bu özellik uygulama üzerinde matematik denklemlerinin çizilebilmesini sağlayacak. Fikir, şirkette mühendis olarak çalışan Dave Grochocki'den geldi ve bu yenilikle, özellikle öğrencilerin cebir öğrenmesinin kolaylaştırılması hedefleniyor.


    Amerika Birleşik Devletleri
    'ndeki öğrencilerin çoğunun cebir konusunda başarısız oldukları açıklanırken, gelişmiş matematik, bilim ve mühendislik konuları için cebirin çok önemli olduğu ifade ediliyor. Bu özellik şu anda geliştirilme aşamasında olduğundan, tüm kullanıcılara ne zaman sunulacağı konusunda henüz net bir tarih olmadığını da belirtelim.

      







  • Amma tatava yapmışlar, çok daha gelişmişinin kodu şu kadar, haber yapılması bile abes.

    unit UntMain;

    interface

    uses
    Windows, Messages, Variants, Graphics, Classes, Controls, Forms,
    Dialogs, SysUtils, StdCtrls, ExtCtrls, Math, ComCtrls;

    type
    TFrmGraph = class(TForm)
    Panel1: TPanel;
    GroupBox1: TGroupBox;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    RadioButton4: TRadioButton;
    RadioButton5: TRadioButton;
    LCoef1: TLabel;
    LCoef2: TLabel;
    LCoef3: TLabel;
    LCoef4: TLabel;
    Coef1: TEdit;
    UDCoef2: TUpDown;
    Coef2: TEdit;
    Coef3: TEdit;
    Coef4: TEdit;
    UDCoef1: TUpDown;
    UDCoef4: TUpDown;
    UDCoef3: TUpDown;
    Bevel4: TBevel;
    PaintBox1: TPaintBox;
    StatusBar1: TStatusBar;
    GroupBox2: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Edit2: TEdit;
    UpDown1: TUpDown;
    ChBoxGridLinesX: TCheckBox;
    ChBoxAxisValuesX: TCheckBox;
    cbXApp: TComboBox;
    GroupBox3: TGroupBox;
    Label3: TLabel;
    ChBoxGridLinesY: TCheckBox;
    ChBoxAxisValuesY: TCheckBox;
    Edit3: TEdit;
    UpDown2: TUpDown;
    Label23: TLabel;
    Label4: TLabel;
    Button2: TButton;
    Button1: TButton;
    Button3: TButton;
    GraphColor: TColorBox;
    BkColor: TColorBox;
    procedure Button1Click(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure Coef1Change(Sender: TObject);
    procedure PaintBox1Paint(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure Edit4KeyPress(Sender: TObject; var Key: Char);
    procedure BkColorChange(Sender: TObject);
    procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
    Y: Integer);
    private
    XGridLineCount : ShortInt; // Don't give odd values
    YGridLineCount : ShortInt; // Don't give odd values
    FXIncrement : Single; // smaller given values makes slower the graph to
    // be drawn
    DemoFXValue : Integer; // Demo Function Value holder

    FGraphBmp : TBitmap;
    procedure SaveActivePaint;
    procedure DestroyActivePaint;
    { Private declarations }
    public
    { Public declarations }
    procedure GetParameters;
    procedure DrawGraphGridLines;
    procedure DrawAxisOrdinate;
    procedure DrawGraph;
    function FunctionName : string;
    function PowerN(base : Extended; expo : Integer) : Extended;
    end;

    var
    FrmGraph: TFrmGraph;

    implementation

    {$R *.dfm}

    procedure TFrmGraph.Button1Click(Sender: TObject);
    begin
    {Destroy Active Screen First}
    DestroyActivePaint;

    PaintBox1.Refresh;
    PaintBox1.Canvas.Pen.Color:=clBlack;
    {Get Function Name}
    StatusBar1.Panels[9].Text := FunctionName;
    { Get Grid Lines Count for XY and X Increment value, Demo Function first}
    GetParameters;
    { Draw Main XY Axis }
    DrawAxisOrdinate;
    { Draw XY Value GridLines and XY Axis Values}
    if ChBoxGridLinesX.Checked or ChBoxAxisValuesX.Checked or
    ChBoxGridLinesY.Checked or ChBoxAxisValuesY.Checked then
    DrawGraphGridLines;
    { Finally Draw the Graph }
    DrawGraph;
    {Save Active Screen preventing blank windows}
    SaveActivePaint;
    end;

    procedure TFrmGraph.DrawAxisOrdinate;
    var ZeroX, ZeroY : Integer;
    begin
    { Draw x=0 and y=0}
    ZeroX := PaintBox1.Width div 2;
    ZeroY := PaintBox1.Height div 2;

    with PaintBox1.Canvas do
    begin
    Brush.Color := clBlack;
    Brush.Style := bsClear;
    Pen.Style := psSolid;
    Pen.Width := 3;
    // Draw x, y
    Polyline([Point(ZeroX, 0), Point(ZeroX, PaintBox1.Height)]);
    Polyline([Point(0, ZeroY), Point(PaintBox1.Width, ZeroY)]);
    end;

    end;

    procedure TFrmGraph.DrawGraphGridLines;
    var i, pW, pH : Integer;
    begin
    pW := PaintBox1.Width;
    pH := PaintBox1.Height;

    with PaintBox1.Canvas do
    begin
    Pen.Style := psDot;
    Pen.Width := 1;
    { Draw x = [-XridLineCount..XGridLineCount] }
    for i:= 0 to XGridLineCount-1 do
    begin
    if i<> XGridLineCount/2 then //Don't draw x = 0
    begin
    if ChBoxGridLinesX.Checked then
    Polyline([
    Point(Round( pW * (1 - i/XGridLineCount) ), 0),
    Point(Round( pW * (1 - i/XGridLineCount) ), pH)
    ]
    );
    end;
    if ChBoxAxisValuesX.Checked then
    TextOut(Round( pW * (1 - i/XGridLineCount) )+1, Round(pH/2)+2, IntToStr(Round(XGridLineCount/2)-i) );
    end;
    { Draw y = [-YridLineCount..YGridLineCount] }
    for i:= 0 to YGridLineCount-1 do
    if i<> YGridLineCount/2 then //Don't draw y = 0
    begin
    if ChBoxGridLinesY.Checked then
    Polyline([
    Point(0, Round( pH *(1 - i/YGridLineCount) ) ),
    Point(pW,Round( pH *(1 - i/YGridLineCount) ) )
    ]
    );
    if ChBoxAxisValuesY.Checked then
    TextOut(pW div 2 + 2, Round( pH * (1 - i/YGridLineCount) )+1, IntToStr(i-Round(YGridLineCount/2)) );
    end;
    end;
    end;

    procedure TFrmGraph.DrawGraph;
    var x, y : Extended;
    pPosX, pPosY : Integer;
    ZeroX, ZeroY : Integer;
    pW, pH : Integer;
    begin
    pW := PaintBox1.Width;
    pH := PaintBox1.Height;

    ZeroX := pW div 2;
    ZeroY := pH div 2;

    PaintBox1.Canvas.Lock;
    PaintBox1.Canvas.Pen.Style := psSolid;
    x:=-XGridLineCount/2; y:=0;
    repeat
    // Handles the Changes of the function coeeficients and redraws
    case DemoFXValue of
    1: y:= UDCoef1.Position * sin(x * UDCoef2.Position);
    2: y:= UDCoef1.Position * cos(x * UDCoef2.Position);
    3: y:= UDCoef1.Position * x + UDCoef2.Position;
    4: y:= UDCoef1.Position * Power(x, 2) + UDCoef2.Position * x + UDCoef3.Position;
    5: y:= UDCoef1.Position * Power(x, 3) + UDCoef2.Position * Power(x, 2)
    + UDCoef3.Position * x + UDCoef4.Position;
    end;
    pPosX := ZeroX + Round(x * pW /XGridLineCount);
    pPosY := ZeroY - Round(y * pH /YGridLineCount);
    PaintBox1.Canvas.Pixels[pPosX, pPosY] := GraphColor.Selected;
    // Incremented Calculation of X Approach
    x:= x + FXIncrement;
    until x > XGridLineCount / 2;
    PaintBox1.Canvas.Unlock;
    end;

    procedure TFrmGraph.GetParameters;
    var i:Integer;
    begin
    XGridLineCount := UpDown1.Position * 2; { X Axis Grid Lines }
    YGridLineCount := UpDown2.Position * 2; { Y Axis Grid Lines }
    FXIncrement := StrToFloat(cbXApp.Text); { X Approach Increment Count }

    { Decide Which Function to be drawn }
    for i:=1 to 5 do
    if TRadioButton(FindComponent('RadioButton'+IntToStr(i))).Checked then
    DemoFXValue := i;
    {Get Function Name}
    StatusBar1.Panels[9].Text := FunctionName;
    end;

    procedure TFrmGraph.RadioButton1Click(Sender: TObject);
    var i:Integer;
    coefCount : Integer;
    begin
    { Show belonging Function Coeeficients }
    coefCount := 0;
    for i:=1 to 4 do
    begin
    TEdit(FindComponent('Coef'+IntToStr(i))).Enabled := False;
    TLabel(FindComponent('LCoef'+IntToStr(i))).Enabled := False;
    TUpDown(FindComponent('UDCoef'+IntToStr(i))).Enabled := False;
    end;

    if (RadioButton1.Checked) or (RadioButton2.Checked) or
    (RadioButton3.Checked) then coefCount := 2;
    if (RadioButton4.Checked) then coefCount := 3;
    if (RadioButton5.Checked) then coefCount := 4;

    for i:=1 to coefCount do
    begin
    TEdit(FindComponent('Coef'+IntToStr(i))).Enabled := True;
    TLabel(FindComponent('LCoef'+IntToStr(i))).Enabled := True;
    TUpDown(FindComponent('UDCoef'+IntToStr(i))).Enabled := True;
    end;

    GetParameters;
    end;

    procedure TFrmGraph.Button2Click(Sender: TObject);
    begin
    { Form Close }
    Close;
    end;

    procedure TFrmGraph.Button3Click(Sender: TObject);
    begin
    MessageBox(
    Handle,
    ':: FxGraphView Demo v1.0.4 by XaoCody...'+#13+
    ':: July 06th, 2003 - Delphi 7'+#13+
    ':: ---------------------------------------- '+#13+
    ':: FxGraphView Version History ::'+#13+
    ':: v1.0.4 : Axis Grid and Value Disable/Enable Options'+#13+
    ':: : DoubleBuffer Correction'+#13+
    ':: v1.0.3 : GraphPan and Position Values'+#13+
    ':: v1.0.2 : Lossless Canvas, XApproach Combo'+#13+
    ':: v1.0.1 : FunctionName is available'+#13+
    ':: v1.0.0 : Generic'+#13+
    ':: ---------------------------------------- '+#13+
    ':: v1.0.5 will handle function creation...'+#13+
    ':: Check for updates...',
    'FxGraphView v1.0.4',
    MB_OK
    );
    end;
    procedure TFrmGraph.Edit2Change(Sender: TObject);
    begin
    Button1.Click;
    end;

    function TFrmGraph.FunctionName : string;
    var s1, s2, s3, s4 : string;
    begin
    ////////////////////////////////////////////////////////////////////////
    // Function Type f(x) = a * sin(b * x)
    ////////////////////////////////////////////////////////////////////////
    Result:='f(x) = ';
    if RadioButton1.Checked then s2 := 'sin';
    if RadioButton2.Checked then s2 := 'cos';

    if (RadioButton1.Checked) or (RadioButton2.Checked) then
    // Adjust format with coeffs as 'a * sin(b*x)' or 'a * cos(b*x)'
    begin
    case UDCoef1.Position of
    0: Result:= Result + '0';
    1: Result:= Result + s2;
    -1: Result:= Result + '-' + s2;
    else Result:= Result + Coef1.Text + ' * ' + s2;
    end;

    case UDCoef2.Position of
    0:
    begin
    if RadioButton1.Checked then Result:= 'f(x) = 0';
    if RadioButton2.Checked then Result:= 'f(x) = 1';
    end;
    1: if Result<> 'f(x) = 0' then Result:= Result + '(x)';
    -1: if Result<> 'f(x) = 0' then Result:= Result + '(-x)';
    else if Result<> 'f(x) = 0' then Result:= Result +'('+ Coef2.Text + 'x)';
    end;

    if (UDCoef1.Position = 0) and (UDCoef2.Position = 0) then Result := 'f(x) = 0';
    end;

    ////////////////////////////////////////////////////////////////////////
    // Function Type f(x) = a * x + b
    ////////////////////////////////////////////////////////////////////////
    if RadioButton3.Checked then
    begin
    Result:='f(x) = ';
    case UDCoef1.Position of
    0: Result := Result; //No change
    1: Result := Result + 'x';
    -1: Result := Result + '-x';
    else Result := Result + Coef1.Text + 'x';
    end;

    case UDCoef2.Position of
    0: Result := Result; //No change
    else
    begin
    if (UDCoef2.Position > 0) and (UDCoef1.Position <> 0) then Result:=Result + ' + ';
    Result := Result + ' ' + Coef2.Text;
    end;
    end;

    if (UDCoef2.Position = 0) and (UDCoef1.Position = 0) then Result:= Result + '0';
    end;

    ////////////////////////////////////////////////////////////////////////
    // Function Type f(x) = a * x^2 + b * x + c
    ////////////////////////////////////////////////////////////////////////
    if RadioButton4.Checked then
    begin
    case UDCoef1.Position of
    0 : s1 := '';
    1 : s1 := 'x^2 ';
    -1: s1 := '-x^2 ';
    else s1 := Coef1.Text + 'x^2 ';
    end;

    case UDCoef2.Position of
    0 : s2 := '';
    1 : s2 := 'x ';
    -1: s2 := '-x ';
    else s2 := ' ' + Coef2.Text + 'x ';
    end;

    case UDCoef3.Position of
    0 : s3 := '';
    else s3 := ' ' + Coef3.Text;
    end;

    //Write one by one
    Result:= s1;
    if s2 <> '' then
    begin
    if (UDCoef2.Position > 0) and (Result<>'') then s2:= '+' + s2;
    end;
    Result := Result + s2;

    if s3 <> '' then
    begin
    if (UDCoef3.Position > 0) and (Result<>'') then s3:= '+' + s3;
    end;
    Result := Result + s3;

    if Result = '' then Result:= 'f(x) = 0'
    else Result := 'f(x) = ' + Result;
    end;

    ////////////////////////////////////////////////////////////////////////
    // Function Type f(x) = a * x^3 + b * x^2 + cx + d
    ////////////////////////////////////////////////////////////////////////
    if RadioButton5.Checked then
    begin
    case UDCoef1.Position of
    0 : s1 := '';
    1 : s1 := 'x^3 ';
    -1: s1 := '-x^3 ';
    else s1 := Coef1.Text + 'x^3 ';
    end;

    case UDCoef2.Position of
    0 : s2 := '';
    1 : s2 := 'x^2 ';
    -1: s2 := '-x^2 ';
    else s2 := ' ' + Coef2.Text + 'x^2 ';
    end;

    case UDCoef3.Position of
    0 : s3 := '';
    1 : s3 := 'x ';
    -1: s3 := '-x ';
    else s3 := ' ' + Coef3.Text + 'x ';
    end;

    case UDCoef4.Position of
    0 : s4 := '';
    else s4 := ' ' + Coef4.Text;
    end;

    //Write one by one
    Result:= s1;
    if s2 <> '' then
    begin
    if (UDCoef2.Position > 0) and (Result<>'') then s2:= '+' + s2;
    end;
    Result := Result + s2;

    if s3 <> '' then
    begin
    if (UDCoef3.Position > 0) and (Result<>'') then s3:= '+' + s3;
    end;
    Result := Result + s3;

    if s4 <> '' then
    begin
    if (UDCoef4.Position > 0) and (Result<>'') then s4:= '+' + s4;
    end;
    Result := Result + s4;

    if Result = '' then Result:= 'f(x) = 0'
    else Result := 'f(x) = ' + Result;
    end;
    end;

    procedure TFrmGraph.Coef1Change(Sender: TObject);
    begin
    {When coefficients are changed then Get Function Name}
    StatusBar1.Panels[9].Text := FunctionName;
    end;

    procedure TFrmGraph.SaveActivePaint;
    var graphRect : TRect;
    begin
    if Assigned(FGraphBmp) then FreeAndNil(FGraphBmp);
    FGraphBmp := TBitmap.Create;
    FGraphBmp.Width := PaintBox1.Width;
    FGraphBmp.Height := PaintBox1.Height;
    graphRect.Left := 0;
    graphRect.Top := 0;
    graphRect.Right := FGraphBmp.Width;
    graphRect.Bottom := FGraphBmp.Height;
    FGraphBmp.Canvas.CopyRect(graphRect, PaintBox1.Canvas, PaintBox1.ClientRect);
    end;

    procedure TFrmGraph.PaintBox1Paint(Sender: TObject);
    begin
    if Assigned(FGraphBmp) then
    PaintBox1.Canvas.Draw(0,0, FGraphBmp);
    end;

    procedure TFrmGraph.DestroyActivePaint;
    begin
    if Assigned(FGraphBmp) then FreeAndNil(FGraphBmp);
    end;


    procedure TFrmGraph.FormDestroy(Sender: TObject);
    begin
    DestroyActivePaint;
    end;

    procedure TFrmGraph.FormActivate(Sender: TObject);
    begin
    FGraphBmp := nil;
    DoubleBuffered := True;
    end;

    procedure TFrmGraph.Edit4KeyPress(Sender: TObject; var Key: Char);
    begin
    if not (ord(key) in [48..57]) then
    Key := #0; {Return '0' if the pressed key is not numerical}
    end;

    procedure TFrmGraph.BkColorChange(Sender: TObject);
    begin
    Color := BkColor.Selected;
    Button1.Click;
    end;

    procedure TFrmGraph.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
    X, Y: Integer);
    var zeroX, zeroY : Integer;
    posX, posY : Extended;
    pW, pH : Integer;
    gridLineWidthX : Integer;
    gridLineWidthY : Integer;
    s : string;
    begin
    pW := PaintBox1.Width;
    pH := PaintBox1.Height;

    zeroX := pW div 2;
    zeroY := pH div 2;

    gridLineWidthX := zeroX div UpDown1.Position;
    gridLineWidthY := zeroY div UpDown2.Position;

    posX :=0; posY :=0;

    //Draw Graph Follower
    PaintBox1.Refresh;
    PaintBox1.Canvas.Pen.Style := psSolid;
    PaintBox1.Canvas.Pen.Width := 1;
    PaintBox1.Canvas.Polyline([Point(X, 0), Point(X, PaintBox1.Height)]);
    PaintBox1.Canvas.Polyline([Point(0, Y), Point(PaintBox1.Width, Y)]);

    //Define GraphX Positons
    if X <> zeroX then posX := (X - zeroX) / gridLineWidthX;
    if X = zeroX then posX := 0;

    //Define GraphX Positons
    if Y <> zeroY then posY := (zeroY - Y) / gridLineWidthY;
    if X = zeroY then posY := 0;

    StatusBar1.Panels[1].Text := IntToStr(X);
    StatusBar1.Panels[3].Text := IntToStr(Y);
    StatusBar1.Panels[5].Text := Format('%.2f', [posX]);
    StatusBar1.Panels[7].Text := Format('%.2f', [posY]);

    case DemoFXValue of
    1: s := Format('f( %.2f ) = %.2f', [posX, UDCoef1.Position * sin(UDCoef2.Position * posX)]);
    2: s := Format('f( %.2f ) = %.2f', [posX, UDCoef1.Position * cos(UDCoef2.Position * posX)]);
    3: s := Format('f( %.2f ) = %.2f', [posX, UDCoef1.Position * posX + UDCoef2.Position]);
    4: s := Format('f( %.2f ) = %.2f', [posX, UDCoef1.Position * PowerN(posX,2)
    + UDCoef2.Position * posX + UDCoef3.Position]);
    5: s := Format('f( %.2f ) = %.2f', [posX, UDCoef1.Position * PowerN(posX,3)
    + UDCoef2.Position * PowerN(posX,2) + UDCoef3.Position * posX + UDCoef4.Position]);
    end;

    StatusBar1.Panels[8].Text := s;
    end;

    function TFrmGraph.PowerN(base : Extended; expo : Integer) : Extended;
    var i:Integer;
    begin
    if expo < 0 then begin Result:=-1; exit; end;

    Result := 1;
    for i:=1 to expo do
    Result := Result * base;
    end;

    end.
  • kolay şeyler bunlaaar bunu mu yapamıyor ameriganlar.

  • Amma tatava yapmışlar, çok daha gelişmişinin kodu şu kadar, haber yapılması bile abes. Windows 10 hesap makinesine, denklem çizebilme özelliği ekleniyor

    unit UntMain;

    interface

    uses
    Windows, Messages, Variants, Graphics, Classes, Controls, Forms,
    Dialogs, SysUtils, StdCtrls, ExtCtrls, Math, ComCtrls;

    type
    TFrmGraph = class(TForm)
    Panel1: TPanel;
    GroupBox1: TGroupBox;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    RadioButton4: TRadioButton;
    RadioButton5: TRadioButton;
    LCoef1: TLabel;
    LCoef2: TLabel;
    LCoef3: TLabel;
    LCoef4: TLabel;
    Coef1: TEdit;
    UDCoef2: TUpDown;
    Coef2: TEdit;
    Coef3: TEdit;
    Coef4: TEdit;
    UDCoef1: TUpDown;
    UDCoef4: TUpDown;
    UDCoef3: TUpDown;
    Bevel4: TBevel;
    PaintBox1: TPaintBox;
    StatusBar1: TStatusBar;
    GroupBox2: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Edit2: TEdit;
    UpDown1: TUpDown;
    ChBoxGridLinesX: TCheckBox;
    ChBoxAxisValuesX: TCheckBox;
    cbXApp: TComboBox;
    GroupBox3: TGroupBox;
    Label3: TLabel;
    ChBoxGridLinesY: TCheckBox;
    ChBoxAxisValuesY: TCheckBox;
    Edit3: TEdit;
    UpDown2: TUpDown;
    Label23: TLabel;
    Label4: TLabel;
    Button2: TButton;
    Button1: TButton;
    Button3: TButton;
    GraphColor: TColorBox;
    BkColor: TColorBox;
    procedure Button1Click(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure Coef1Change(Sender: TObject);
    procedure PaintBox1Paint(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure Edit4KeyPress(Sender: TObject; var Key: Char);
    procedure BkColorChange(Sender: TObject);
    procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
    Y: Integer);
    private
    XGridLineCount : ShortInt; // Don't give odd values
    YGridLineCount : ShortInt; // Don't give odd values
    FXIncrement : Single; // smaller given values makes slower the graph to
    // be drawn
    DemoFXValue : Integer; // Demo Function Value holder

    FGraphBmp : TBitmap;
    procedure SaveActivePaint;
    procedure DestroyActivePaint;
    { Private declarations }
    public
    { Public declarations }
    procedure GetParameters;
    procedure DrawGraphGridLines;
    procedure DrawAxisOrdinate;
    procedure DrawGraph;
    function FunctionName : string;
    function PowerN(base : Extended; expo : Integer) : Extended;
    end;

    var
    FrmGraph: TFrmGraph;

    implementation

    {$R *.dfm}

    procedure TFrmGraph.Button1Click(Sender: TObject);
    begin
    {Destroy Active Screen First}
    DestroyActivePaint;

    PaintBox1.Refresh;
    PaintBox1.Canvas.Pen.Color:=clBlack;
    {Get Function Name}
    StatusBar1.Panels[9].Text := FunctionName;
    { Get Grid Lines Count for XY and X Increment value, Demo Function first}
    GetParameters;
    { Draw Main XY Axis }
    DrawAxisOrdinate;
    { Draw XY Value GridLines and XY Axis Values}
    if ChBoxGridLinesX.Checked or ChBoxAxisValuesX.Checked or
    ChBoxGridLinesY.Checked or ChBoxAxisValuesY.Checked then
    DrawGraphGridLines;
    { Finally Draw the Graph }
    DrawGraph;
    {Save Active Screen preventing blank windows}
    SaveActivePaint;
    end;

    procedure TFrmGraph.DrawAxisOrdinate;
    var ZeroX, ZeroY : Integer;
    begin
    { Draw x=0 and y=0}
    ZeroX := PaintBox1.Width div 2;
    ZeroY := PaintBox1.Height div 2;

    with PaintBox1.Canvas do
    begin
    Brush.Color := clBlack;
    Brush.Style := bsClear;
    Pen.Style := psSolid;
    Pen.Width := 3;
    // Draw x, y
    Polyline([Point(ZeroX, 0), Point(ZeroX, PaintBox1.Height)]);
    Polyline([Point(0, ZeroY), Point(PaintBox1.Width, ZeroY)]);
    end;

    end;

    procedure TFrmGraph.DrawGraphGridLines;
    var i, pW, pH : Integer;
    begin
    pW := PaintBox1.Width;
    pH := PaintBox1.Height;

    with PaintBox1.Canvas do
    begin
    Pen.Style := psDot;
    Pen.Width := 1;
    { Draw x = [-XridLineCount..XGridLineCount] }
    for i:= 0 to XGridLineCount-1 do
    begin
    if i<> XGridLineCount/2 then //Don't draw x = 0
    begin
    if ChBoxGridLinesX.Checked then
    Polyline([
    Point(Round( pW * (1 - i/XGridLineCount) ), 0),
    Point(Round( pW * (1 - i/XGridLineCount) ), pH)
    ]
    );
    end;
    if ChBoxAxisValuesX.Checked then
    TextOut(Round( pW * (1 - i/XGridLineCount) )+1, Round(pH/2)+2, IntToStr(Round(XGridLineCount/2)-i) );
    end;
    { Draw y = [-YridLineCount..YGridLineCount] }
    for i:= 0 to YGridLineCount-1 do
    if i<> YGridLineCount/2 then //Don't draw y = 0
    begin
    if ChBoxGridLinesY.Checked then
    Polyline([
    Point(0, Round( pH *(1 - i/YGridLineCount) ) ),
    Point(pW,Round( pH *(1 - i/YGridLineCount) ) )
    ]
    );
    if ChBoxAxisValuesY.Checked then
    TextOut(pW div 2 + 2, Round( pH * (1 - i/YGridLineCount) )+1, IntToStr(i-Round(YGridLineCount/2)) );
    end;
    end;
    end;

    procedure TFrmGraph.DrawGraph;
    var x, y : Extended;
    pPosX, pPosY : Integer;
    ZeroX, ZeroY : Integer;
    pW, pH : Integer;
    begin
    pW := PaintBox1.Width;
    pH := PaintBox1.Height;

    ZeroX := pW div 2;
    ZeroY := pH div 2;

    PaintBox1.Canvas.Lock;
    PaintBox1.Canvas.Pen.Style := psSolid;
    x:=-XGridLineCount/2; y:=0;
    repeat
    // Handles the Changes of the function coeeficients and redraws
    case DemoFXValue of
    1: y:= UDCoef1.Position * sin(x * UDCoef2.Position);
    2: y:= UDCoef1.Position * cos(x * UDCoef2.Position);
    3: y:= UDCoef1.Position * x + UDCoef2.Position;
    4: y:= UDCoef1.Position * Power(x, 2) + UDCoef2.Position * x + UDCoef3.Position;
    5: y:= UDCoef1.Position * Power(x, 3) + UDCoef2.Position * Power(x, 2)
    + UDCoef3.Position * x + UDCoef4.Position;
    end;
    pPosX := ZeroX + Round(x * pW /XGridLineCount);
    pPosY := ZeroY - Round(y * pH /YGridLineCount);
    PaintBox1.Canvas.Pixels[pPosX, pPosY] := GraphColor.Selected;
    // Incremented Calculation of X Approach
    x:= x + FXIncrement;
    until x > XGridLineCount / 2;
    PaintBox1.Canvas.Unlock;
    end;

    procedure TFrmGraph.GetParameters;
    var i:Integer;
    begin
    XGridLineCount := UpDown1.Position * 2; { X Axis Grid Lines }
    YGridLineCount := UpDown2.Position * 2; { Y Axis Grid Lines }
    FXIncrement := StrToFloat(cbXApp.Text); { X Approach Increment Count }

    { Decide Which Function to be drawn }
    for i:=1 to 5 do
    if TRadioButton(FindComponent('RadioButton'+IntToStr(i))).Checked then
    DemoFXValue := i;
    {Get Function Name}
    StatusBar1.Panels[9].Text := FunctionName;
    end;

    procedure TFrmGraph.RadioButton1Click(Sender: TObject);
    var i:Integer;
    coefCount : Integer;
    begin
    { Show belonging Function Coeeficients }
    coefCount := 0;
    for i:=1 to 4 do
    begin
    TEdit(FindComponent('Coef'+IntToStr(i))).Enabled := False;
    TLabel(FindComponent('LCoef'+IntToStr(i))).Enabled := False;
    TUpDown(FindComponent('UDCoef'+IntToStr(i))).Enabled := False;
    end;

    if (RadioButton1.Checked) or (RadioButton2.Checked) or
    (RadioButton3.Checked) then coefCount := 2;
    if (RadioButton4.Checked) then coefCount := 3;
    if (RadioButton5.Checked) then coefCount := 4;

    for i:=1 to coefCount do
    begin
    TEdit(FindComponent('Coef'+IntToStr(i))).Enabled := True;
    TLabel(FindComponent('LCoef'+IntToStr(i))).Enabled := True;
    TUpDown(FindComponent('UDCoef'+IntToStr(i))).Enabled := True;
    end;

    GetParameters;
    end;

    procedure TFrmGraph.Button2Click(Sender: TObject);
    begin
    { Form Close }
    Close;
    end;

    procedure TFrmGraph.Button3Click(Sender: TObject);
    begin
    MessageBox(
    Handle,
    ':: FxGraphView Demo v1.0.4 by XaoCody...'+#13+
    ':: July 06th, 2003 - Delphi 7'+#13+
    ':: ---------------------------------------- '+#13+
    ':: FxGraphView Version History ::'+#13+
    ':: v1.0.4 : Axis Grid and Value Disable/Enable Options'+#13+
    ':: : DoubleBuffer Correction'+#13+
    ':: v1.0.3 : GraphPan and Position Values'+#13+
    ':: v1.0.2 : Lossless Canvas, XApproach Combo'+#13+
    ':: v1.0.1 : FunctionName is available'+#13+
    ':: v1.0.0 : Generic'+#13+
    ':: ---------------------------------------- '+#13+
    ':: v1.0.5 will handle function creation...'+#13+
    ':: Check for updates...',
    'FxGraphView v1.0.4',
    MB_OK
    );
    end;
    procedure TFrmGraph.Edit2Change(Sender: TObject);
    begin
    Button1.Click;
    end;

    function TFrmGraph.FunctionName : string;
    var s1, s2, s3, s4 : string;
    begin
    ////////////////////////////////////////////////////////////////////////
    // Function Type f(x) = a * sin(b * x)
    ////////////////////////////////////////////////////////////////////////
    Result:='f(x) = ';
    if RadioButton1.Checked then s2 := 'sin';
    if RadioButton2.Checked then s2 := 'cos';

    if (RadioButton1.Checked) or (RadioButton2.Checked) then
    // Adjust format with coeffs as 'a * sin(b*x)' or 'a * cos(b*x)'
    begin
    case UDCoef1.Position of
    0: Result:= Result + '0';
    1: Result:= Result + s2;
    -1: Result:= Result + '-' + s2;
    else Result:= Result + Coef1.Text + ' * ' + s2;
    end;

    case UDCoef2.Position of
    0:
    begin
    if RadioButton1.Checked then Result:= 'f(x) = 0';
    if RadioButton2.Checked then Result:= 'f(x) = 1';
    end;
    1: if Result<> 'f(x) = 0' then Result:= Result + '(x)';
    -1: if Result<> 'f(x) = 0' then Result:= Result + '(-x)';
    else if Result<> 'f(x) = 0' then Result:= Result +'('+ Coef2.Text + 'x)';
    end;

    if (UDCoef1.Position = 0) and (UDCoef2.Position = 0) then Result := 'f(x) = 0';
    end;

    ////////////////////////////////////////////////////////////////////////
    // Function Type f(x) = a * x + b
    ////////////////////////////////////////////////////////////////////////
    if RadioButton3.Checked then
    begin
    Result:='f(x) = ';
    case UDCoef1.Position of
    0: Result := Result; //No change
    1: Result := Result + 'x';
    -1: Result := Result + '-x';
    else Result := Result + Coef1.Text + 'x';
    end;

    case UDCoef2.Position of
    0: Result := Result; //No change
    else
    begin
    if (UDCoef2.Position > 0) and (UDCoef1.Position <> 0) then Result:=Result + ' + ';
    Result := Result + ' ' + Coef2.Text;
    end;
    end;

    if (UDCoef2.Position = 0) and (UDCoef1.Position = 0) then Result:= Result + '0';
    end;

    ////////////////////////////////////////////////////////////////////////
    // Function Type f(x) = a * x^2 + b * x + c
    ////////////////////////////////////////////////////////////////////////
    if RadioButton4.Checked then
    begin
    case UDCoef1.Position of
    0 : s1 := '';
    1 : s1 := 'x^2 ';
    -1: s1 := '-x^2 ';
    else s1 := Coef1.Text + 'x^2 ';
    end;

    case UDCoef2.Position of
    0 : s2 := '';
    1 : s2 := 'x ';
    -1: s2 := '-x ';
    else s2 := ' ' + Coef2.Text + 'x ';
    end;

    case UDCoef3.Position of
    0 : s3 := '';
    else s3 := ' ' + Coef3.Text;
    end;

    //Write one by one
    Result:= s1;
    if s2 <> '' then
    begin
    if (UDCoef2.Position > 0) and (Result<>'') then s2:= '+' + s2;
    end;
    Result := Result + s2;

    if s3 <> '' then
    begin
    if (UDCoef3.Position > 0) and (Result<>'') then s3:= '+' + s3;
    end;
    Result := Result + s3;

    if Result = '' then Result:= 'f(x) = 0'
    else Result := 'f(x) = ' + Result;
    end;

    ////////////////////////////////////////////////////////////////////////
    // Function Type f(x) = a * x^3 + b * x^2 + cx + d
    ////////////////////////////////////////////////////////////////////////
    if RadioButton5.Checked then
    begin
    case UDCoef1.Position of
    0 : s1 := '';
    1 : s1 := 'x^3 ';
    -1: s1 := '-x^3 ';
    else s1 := Coef1.Text + 'x^3 ';
    end;

    case UDCoef2.Position of
    0 : s2 := '';
    1 : s2 := 'x^2 ';
    -1: s2 := '-x^2 ';
    else s2 := ' ' + Coef2.Text + 'x^2 ';
    end;

    case UDCoef3.Position of
    0 : s3 := '';
    1 : s3 := 'x ';
    -1: s3 := '-x ';
    else s3 := ' ' + Coef3.Text + 'x ';
    end;

    case UDCoef4.Position of
    0 : s4 := '';
    else s4 := ' ' + Coef4.Text;
    end;

    //Write one by one
    Result:= s1;
    if s2 <> '' then
    begin
    if (UDCoef2.Position > 0) and (Result<>'') then s2:= '+' + s2;
    end;
    Result := Result + s2;

    if s3 <> '' then
    begin
    if (UDCoef3.Position > 0) and (Result<>'') then s3:= '+' + s3;
    end;
    Result := Result + s3;

    if s4 <> '' then
    begin
    if (UDCoef4.Position > 0) and (Result<>'') then s4:= '+' + s4;
    end;
    Result := Result + s4;

    if Result = '' then Result:= 'f(x) = 0'
    else Result := 'f(x) = ' + Result;
    end;
    end;

    procedure TFrmGraph.Coef1Change(Sender: TObject);
    begin
    {When coefficients are changed then Get Function Name}
    StatusBar1.Panels[9].Text := FunctionName;
    end;

    procedure TFrmGraph.SaveActivePaint;
    var graphRect : TRect;
    begin
    if Assigned(FGraphBmp) then FreeAndNil(FGraphBmp);
    FGraphBmp := TBitmap.Create;
    FGraphBmp.Width := PaintBox1.Width;
    FGraphBmp.Height := PaintBox1.Height;
    graphRect.Left := 0;
    graphRect.Top := 0;
    graphRect.Right := FGraphBmp.Width;
    graphRect.Bottom := FGraphBmp.Height;
    FGraphBmp.Canvas.CopyRect(graphRect, PaintBox1.Canvas, PaintBox1.ClientRect);
    end;

    procedure TFrmGraph.PaintBox1Paint(Sender: TObject);
    begin
    if Assigned(FGraphBmp) then
    PaintBox1.Canvas.Draw(0,0, FGraphBmp);
    end;

    procedure TFrmGraph.DestroyActivePaint;
    begin
    if Assigned(FGraphBmp) then FreeAndNil(FGraphBmp);
    end;


    procedure TFrmGraph.FormDestroy(Sender: TObject);
    begin
    DestroyActivePaint;
    end;

    procedure TFrmGraph.FormActivate(Sender: TObject);
    begin
    FGraphBmp := nil;
    DoubleBuffered := True;
    end;

    procedure TFrmGraph.Edit4KeyPress(Sender: TObject; var Key: Char);
    begin
    if not (ord(key) in [48..57]) then
    Key := #0; {Return '0' if the pressed key is not numerical}
    end;

    procedure TFrmGraph.BkColorChange(Sender: TObject);
    begin
    Color := BkColor.Selected;
    Button1.Click;
    end;

    procedure TFrmGraph.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
    X, Y: Integer);
    var zeroX, zeroY : Integer;
    posX, posY : Extended;
    pW, pH : Integer;
    gridLineWidthX : Integer;
    gridLineWidthY : Integer;
    s : string;
    begin
    pW := PaintBox1.Width;
    pH := PaintBox1.Height;

    zeroX := pW div 2;
    zeroY := pH div 2;

    gridLineWidthX := zeroX div UpDown1.Position;
    gridLineWidthY := zeroY div UpDown2.Position;

    posX :=0; posY :=0;

    //Draw Graph Follower
    PaintBox1.Refresh;
    PaintBox1.Canvas.Pen.Style := psSolid;
    PaintBox1.Canvas.Pen.Width := 1;
    PaintBox1.Canvas.Polyline([Point(X, 0), Point(X, PaintBox1.Height)]);
    PaintBox1.Canvas.Polyline([Point(0, Y), Point(PaintBox1.Width, Y)]);

    //Define GraphX Positons
    if X <> zeroX then posX := (X - zeroX) / gridLineWidthX;
    if X = zeroX then posX := 0;

    //Define GraphX Positons
    if Y <> zeroY then posY := (zeroY - Y) / gridLineWidthY;
    if X = zeroY then posY := 0;

    StatusBar1.Panels[1].Text := IntToStr(X);
    StatusBar1.Panels[3].Text := IntToStr(Y);
    StatusBar1.Panels[5].Text := Format('%.2f', [posX]);
    StatusBar1.Panels[7].Text := Format('%.2f', [posY]);

    case DemoFXValue of
    1: s := Format('f( %.2f ) = %.2f', [posX, UDCoef1.Position * sin(UDCoef2.Position * posX)]);
    2: s := Format('f( %.2f ) = %.2f', [posX, UDCoef1.Position * cos(UDCoef2.Position * posX)]);
    3: s := Format('f( %.2f ) = %.2f', [posX, UDCoef1.Position * posX + UDCoef2.Position]);
    4: s := Format('f( %.2f ) = %.2f', [posX, UDCoef1.Position * PowerN(posX,2)
    + UDCoef2.Position * posX + UDCoef3.Position]);
    5: s := Format('f( %.2f ) = %.2f', [posX, UDCoef1.Position * PowerN(posX,3)
    + UDCoef2.Position * PowerN(posX,2) + UDCoef3.Position * posX + UDCoef4.Position]);
    end;

    StatusBar1.Panels[8].Text := s;
    end;

    function TFrmGraph.PowerN(base : Extended; expo : Integer) : Extended;
    var i:Integer;
    begin
    if expo < 0 then begin Result:=-1; exit; end;

    Result := 1;
    for i:=1 to expo do
    Result := Result * base;
    end;

    end.




  • Muazzam yenilik oyun Gates'e

    < Bu ileti DH mobil uygulamasından atıldı >
  • Windows phone kullandığım dönemde hesap makinasına ayda 1 güncelleme gelirdi. Ulan 2 satırlık uygulama ne hata yapıyorsunuzda ayda 1 hata düzeltmesi geliyor

    < Bu ileti mobil sürüm kullanılarak atıldı >
  • 
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.