🖇
Size: a a a
🖇
🖇
SB
🖇
В
В
В
В
ር
ር
ር
Б[

R2
int cx = r.X + r.Width / 2, cy = r.Y + r.Height / 2; // вычисляем центр прямоугольника
e->Graphics->TranslateTransform(cx, cy); // устанавливаем в него начало координат
e->Graphics->RotateTransform(20); // делаем поворот вокруг него
e->Graphics->TranslateTransform(-cx, -cy); // возвращаем начало координат обратно
e->Graphics->DrawRectangle(Pens::Red, r); // рисуем прямоугольник
e->Graphics->ResetTransform(); // для сравнения сбрасываем матрицу преобразования
e->Graphics->DrawRectangle(Pens::Blue, r); // и рисуем ещё один, уже без поворота
/* МОЙ КОД */
private: void ratate(Graphics^ g, Image ^img, int corn, int x, int y)
{
int cx = img->Width / 2 + x - 1;
int cy = img->Height / 2 + y - 1;
g->Clear(Color::White);
g->TranslateTransform(cx, cy);
g->RotateTransform(corn);
g->TranslateTransform(-cx, -cy);
g->DrawImageUnscaled(img, x, y);
g->ResetTransform();
}
P
P
P
P
R2
R2