如何捕捉矩形? [英] How do I rectangle capture ?

查看:164
本文介绍了如何捕捉矩形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要拖动鼠标来拖动要捕获的区域.


I want to drag and mouse to drag an area I want to capture.


How do I drag the region to capture can be done?

推荐答案

为什么不做类似的事情(用伪代码)

Why not do something like (in pseudocode)

// In some sort of update loop
Rectangle dragRectangle;

if(Mouse.LeftButton.IsDown() && !oldMouseState.LeftButton.IsDown())
{
    dragRectangle.X = oldMousePosition.X;
    dragRectangle.Y = oldMousePosition.Y;
    dragRectangle.Width = oldMousePosition.X - Mouse.Position.X;
    dragRectangle.Height = oldMousePosition.Y - Mouse.Position.Y;
}



这样会给您一个矩形,该矩形的左上角原点应该在单击鼠标的位置,而宽度将是此更新在鼠标的任何位置?



That would give you a rectangle who''s left corner origin should be at the position the mouse was clicked and the width would be wherever the mouse was this update?


这篇关于如何捕捉矩形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆