Sеktor
Ellips yoki aylana sеktorini hosil qilishda Pie uslubidan foydalaniladi. Pie
ning umumiy yozilish formati:
Ob`еk->Canvas->Pie(x1,y1,x2,y2,x3,y3,x4,y4)
bu yerda
ob`еkt – yoy chiziluvchi ob`еkt nomi;
x1,y1,x2,y2 – hosil bo`luvchi sеktorni davom ettirib hosil qilinuvchi ellips
(aylana)ga tashqi chizilgan to`g`ri to`rtburchakning mos koordinatalari;
x3,y3 – sеktorning boshlang`ich nuqtasi;
x4,y4 – sеktorning tugash nuqtasi.
Na’muna:Yuqoridagi qragik operatorlardan foydalanib, sodda tasvirlar hosil
qiling.
Dastur loyihasi uchun:
Forma oynasiga 1 ta Image, 5 ta Button (Shakl turini tanlash uchun) qo’yiladi. Har
bir shakl turining Click hodisasi uchun quyidagi proseduradan foydalanamiz:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Image1->Canvas->Pen->Color=clBlue; // Uychaning tomi
Image1->Canvas->Pen->Width=5;
Image1->Canvas->MoveTo(100,100);
Image1->Canvas->LineTo(200,20);
Image1->Canvas->LineTo(300,100);
Image1->Canvas->LineTo(100,100);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Image1->Canvas->Pen->Color=clRed; // asosiy tana qismi
Image1->Canvas->Pen->Width=5;
Image1->Canvas->Brush->Color=clYellow;
Image1->Canvas->Rectangle(115,100,285,300);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Image1->Canvas->Pen->Color=clRed; // Eshiklar
Image1->Canvas->Pen->Width=3;
Image1->Canvas->Brush->Color=clPurple;
Image1->Canvas->Rectangle(170,230,200,300);
Image1->Canvas->Rectangle(200,230,230,300);
Image1->Canvas->Pen->Width=10;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
Image1->Canvas->Font->Size=20; // Matn
Image1->Canvas->Font->Color=clGreen;
Image1->Canvas->Brush->Color=clSilver;
Image1->Canvas->TextOut(350,20,"Mening dasturim");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
Image1->Canvas->Pen->Color=clPurple; // Gulcha va bargi
Image1->Canvas->Pen->Width=5;
Image1->Canvas->Ellipse(400,200,450,250);
Image1->Canvas->Ellipse(450,200,500,250);
Image1->Canvas->Ellipse(425,160,475,210);
Image1->Canvas->Pen->Color=clGreen;
Image1->Canvas->Pen->Width=5;
Image1->Canvas->MoveTo(450,225);
Image1->Canvas->LineTo(450,300);
Image1->Canvas->Ellipse(420,265,450,275);
Image1->Canvas->Ellipse(450,265,480,275);
}
Natija olish uchun barcha buttonlar ketma-ket tanlanadi.
Nazorat savollari
1. Berilganlar massivi deganda nima tushunasiz?
2. Massivlar qanday e’lon qilinadi?
3. Massivlarning qanday turlari mavjud?
4. Ko’p o’lchovli massivlar haqida gapiring