我知道有很多这样的问题,但他们的答案都不适合我,或者只是我无法正确完成,无论如何,如果可能的话,请给我一个简单的代码!
我知道绿点的位置,我想根据这个位置构造一个矩形。
例子:

最重要的是如何截取该区域的屏幕截图?
我不知道如何更改此代码以适合我的情况。
private Bitmap Screenshot()
{
Bitmap bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(bmpScreenshot);
g.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size);
return bmpScreenshot;
}
Run Code Online (Sandbox Code Playgroud) 我还没有能够建立一个真正可靠的代码来将一个矩形放在另一个矩形中。
我想让“RectangleToCenter”的中心点与“SourceRectangle”的中心点匹配。不应该涉及缩放。
我目前的尝试是
Public Sub CenterRect(ByVal uMain As Rectangle, ByRef uRectToCenter As Rectangle)
Dim iAVHeightHalf As Integer = uMain.Height / 2 'src y center
Dim iAVWidthHalf As Integer = uMain.Width / 2 'src x center
Dim iStartDestX As Integer = uMain.Left + (uRectToCenter.Width / 2) - iAVWidthHalf
Dim iStartDestY As Integer = uMain.Top + (uRectToCenter.Height / 2) - iAVHeightHalf
Dim nNewStart As New Point(iStartDestX, iStartDestY)
uRectToCenter.Location = nNewStart
End Sub
Run Code Online (Sandbox Code Playgroud)
但对我来说它看起来并不干净。
在对多边形进行分割等操作之后,我想验证它是否是一个矩形。
我试过simplify然后数数是否coords是5...
>>> from shapely.geometry import Polygon
>>> from shapely.ops import split
>>>
>>> poly1 = Polygon([(0, 0), (0, 1), (0, 3), (2, 3), (2, 2), (2, 0), (0, 0)])
>>>
>>> poly_check=poly1.simplify(0)
>>> if len(poly_check.exterior.coords)==5:
>>> print 'Yes, it is a rectangle...'
>>> else:
>>> print 'No, it is not a rectangle...'
>>>
Yes, it is a rectangle...
Run Code Online (Sandbox Code Playgroud)
但如果起点位于边缘的中间,则该方法不起作用。
>>> #poly2 is actually a rectangle
>>> poly2 = Polygon([(0, 1), (0, 3), (2, 3), (2, …Run Code Online (Sandbox Code Playgroud) 我正在使用camera插件来获取相机源。每10秒,我生成4个值(x,y,w,h)并在屏幕上绘制一个矩形(只有边框,内部是透明的)(带有随机文本)。如果用户单击此框,它就会消失。
它看起来像这张图片。(x,y,w,h)并且文本是随机生成的。
camera使用插件可以做到这一点吗?或者是否有另一个包已经做到了这一点?
我正在尝试绘制一个矩形,它应该有宽度为5.0的黑色边框,我得到如下所示的矩形,
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextStrokePath(context);
CGContextSetRGBFillColor(context, 0.0, 1.0, 0.0, 0.5);
CGContextFillRect(context, rect);
Run Code Online (Sandbox Code Playgroud)

我可以使它清晰/透明(白色)背景而不是现在显示的绿色背景,[UIColor whiteColor].CGColor但它也应该有黑色边框.
如何将自定义边框设置为矩形?
这个让我难过.我不知道究竟是什么导致了这个问题,但我会尽量提供尽可能多的相关信息.如果您有任何疑问,请询问.
该advance()方法每0.0025秒调用一次,这也是值的elapsedTime.
private int speed = 1;
public void advance(float elapsedTime) {
rectangle.x = (int) (rectangle.x - speed * elapsedTime);
}
Run Code Online (Sandbox Code Playgroud)
即使我将速度设置为0.0000001,x坐标也会向左移动太快.但是,每当我尝试向右移动时:
public void advance(float elapsedTime) {
rectangle.x = (int) (rectangle.x + speed * elapsedTime);
}
Run Code Online (Sandbox Code Playgroud)
它根本不动.
有任何想法吗?我很难过!
所以,我正在尝试制作一个矩形网格,每个矩形网格越接近它就越透明.
使用一些基本的数学,我以为我已经得到它,但似乎我有一个奇怪的图形错误(可能?)显示在这里:
环的中间是鼠标所在的位置.
处理透明度的部分代码:
private function update(e:Event = null):void
{
for (var i:int = 0; i < buttons.length; i++) {
lightFact = getDistance(buttons[i])
lightBrightness = lightPower - (lightFact * 10)
buttons[i].alpha = lightBrightness
}
}
Run Code Online (Sandbox Code Playgroud)
getDistance只是从块到鼠标的距离.
如果重要的话,每个矩形都是一个影片剪辑.
我需要创建一个Rectangle用颜色填充的函数.该方法看起来像这样
public void fillRect(Rectangle rect, int color)
{
int red = color;
int green = color;
int blue = color;
g.setColor(new Color(red, green, blue));
g.fillRect(rect.getX(), rect.getY(), rect.getW(), rect.getH());
}
Run Code Online (Sandbox Code Playgroud)
我想使用整数作为参数,例如200100150
,这将导致200红色的值(仅三个第一个数字).
是否可以做这个宽度java?
我想画一个仅以 R 为底的矩形:
矩形:宽度 = 2.5 厘米,高度 = 1 厘米
期望的输出:
原则上这是可能的drawBox,但我正在寻找一个基本的 R 解决方案:
library(draw)
drawBox(x =1.5, y = 4, width = 2.5, height = 1)
Run Code Online (Sandbox Code Playgroud) rectangles ×9
graphics ×2
java ×2
.net ×1
2d ×1
bitmap ×1
border ×1
bounding-box ×1
c# ×1
camera ×1
cgcontextref ×1
drawing ×1
drawrect ×1
flutter ×1
graphics2d ×1
integer ×1
iphone ×1
polygon ×1
python ×1
r ×1
render ×1
screenshot ×1
shapely ×1
vb.net ×1