The first half of the junior year, and met this proficient (funny) Delphi teacher, people are very good actually.
About his resolution of The Spit Groove Ah, the praise of Delphi Ah, are very humorous. In addition, I appreciate his maintenance of his notebook "Dell i7 920XM Workstation estimate".
Well, then he's going to class, basically knocking on the Code (practice). He decided to use C + + Builder 4 "later on, in order to cater to our professional not having studied Pascal's condition.
It's a little old. " I did spend a lot of time before I found the relevant reference material.
First of all, all the paintings are based on the canvas "canvas" above, we operate Canvas->pixels[x][y], where x, y, is the coordinates, the unit is PX.
In addition, because the direct operation of the canvas in the display will result in a repeat refresh, inefficient, we can build Tbitmap "in memory", Tbitmap on the map, and then use
Copyrect Copy to the canvas you want to display to "new, be careful to specify tbitmap dimensions."
For example, a blue square is depicted on the window:
for (int x = 0;x < 100;x++) for (int y = 0;y < 100;y++) Form1->canvas->pixels[x][y] = Clblue;
A simple line drawing function is given below.
void DrawLine (Tcanvas *c, int x1, int y1, int x2, int y2), void __fastcall Tform1::button1click (tobject *sender) { bmp = new Graphics::tbitmap (); Bmp->width = 202; Bmp->height = 202; Randomize (); SetTime (); for (int i = 0; i < i++) { DrawLine (bmp,1,1,201,10.6 * I-RANDOM (2)); DrawLine (bmp,1,1,10.6 * I-RANDOM (2), 201); } Form1->canvas->copyrect (Rect (0,0,201,201), Bmp->canvas,rect (1,1,201,201));} void DrawLine (Tcanvas *c,int x1, int y1, int x2, int y2) { float k = 0; if (x2! = x1) k = (y2-y1) * 1.0/(X2-X1); Draw if (K > 1) for (int i = 1; I <= y2; i++) c->pixels[(int) ((i-y1)/k)-x1][i] = clblack;< C18/>else for (int i = 1; I <= x2; i++) c->pixels[i][(int) ((i-x1) * k) + y1] = Clblue;}
[BCB] C + + Builder drawing line--based on pixel