#include <Windows.h>
void DrawTextWithAngle(HDC hdc, const wchar_t* text, int x, int y, double angle)
{ // Crear una matriz de transformación para rotar el texto
XFORM xform;
xform.eM11 = (FLOAT)cos(angle);
xform.eM12 = (FLOAT)sin(angle);
xform.eM21 = (FLOAT)-sin(angle);
xform.eM22 = (FLOAT)cos(angle);
xform.eDx = 0.0f;
xform.eDy = 0.0f;
// Establecer la matriz de transformación en el contexto de dispositivo
SetGraphicsMode(hdc, GM_ADVANCED);
SetWorldTransform(hdc, &xform);
// Dibujar el texto inclinado
TextOut(hdc, x, y, text, lstrlen(text));
// Restaurar la matriz de transformación original
SetGraphicsMode(hdc, GM_COMPATIBLE);
SetWorldTransform(hdc, NULL);
}
int main()
{ // Obtener el contexto de dispositivo de la ventana o lienzo donde deseas dibujar
HDC hdc = GetDC(NULL);
// Dibujar el texto con un ángulo de inclinación de 45 grados
DrawTextWithAngle(hdc, L"¡Hola mundo!", 100, 100, 45 * 3.14159 / 180.0);
// Liberar el contexto de dispositivo
ReleaseDC(NULL, hdc);
return 0;
}