Код: Выделить всё
if (CheckCollisionPointRec(mousePosition,canvas))
//checks if mouse position is within canvas
{
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
//check if left mouse button is pressed down
{
float relativeX = mousePosition.x - canvasX;
float relativeY = mousePosition.y - canvasY;
//Checks the relative positions of the x and y axis of the mouse to the canvas's x and y coordinates.
// Draw a pixel at the mouse position within the canvas
DrawPixel((int)relativeX, (int)relativeY, BLACK); // won't draw. Hence.
}
}
Подробнее здесь: https://stackoverflow.com/questions/781 ... pixel-to-d