//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DodajClick(TObject *Sender)
{
Image1->Height =300;
Image1->Width =300;
Image2->Height =300;
Image2->Width =300;
Image1->Canvas->MoveTo((Image1->Width/2),0);
Image1->Canvas->LineTo((Image1->Width/2),(Image1->Height));
Image1->Canvas->MoveTo(0,(Image1->Height/2));
Image1->Canvas->LineTo((Image1->Width),(Image1->Height/2));
TPoint points[4];
int x1 = StrToInt(X1->Text)+150;
int y1 = -StrToInt(Y1->Text)+150;
int x2 = StrToInt(X2->Text)+150;
int y2 = -StrToInt(Y2->Text)+150;
int x3 = StrToInt(X3->Text)+150;
int y3 = -StrToInt(Y3->Text)+150;
int x4 = StrToInt(X4->Text)+150;
int y4 = -StrToInt(Y4->Text)+150;
points[0].x = x1;
points[1].x = x2;
points[2].x = x3;
points[3].x = x4;
points[0].y = y1;
points[1].y = y2;
points[2].y = y3;
points[3].y = y4;
int x_min = points[0].x;
int x_max = points[0].x;
int y_min = points[0].y;
int y_max = points[0].y;
for(int i = 0; i < 4; i++){
x_min = x_min > points[i].x ? points[i].x : x_min;
x_max = x_max < points[i].x ? points[i].x : x_max;
y_min = y_min > points[i].y ? points[i].y : y_min;
y_max = y_max < points[i].y ? points[i].y : y_max;
}
for(int i =0 ; i < 4; i++) {
int x = points[i].x;
int y = points[i].y;
int r = 1;
Image1->Canvas->Pixels[x][y]=clBlack;
}
float sx = (Image2->Width - 0.0f ) / ( x_max - x_min );
float sy = (Image2->Height - 0.0f ) / ( y_max - y_min );
sx = sx < sy ? sx : sy;
sy = sx < sy ? sx : sy;
for(int i =0 ; i < 4; i++) {
int x = (points[i].x - x_min) * sx;
int y = (points[i].y - y_min) * sy;
int r = 3;
int rx = r * sx;
int ry = r * sy;
Image2->Canvas->Ellipse(x - rx, y - ry, x + rx, y + ry);
}
}
//---------------------------------------------------------------------------
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}