标签: rect

Python的rect类发生了什么?

在Google搜索上,我发现了这篇文章:

http://docs.python.org/release/1.4/lib/node201.html

其中显示了使用rect类的示例,执行union/intersection /检查点是否在rect内.在Python 2.7中导入rect失败.这个班是在另一个包吗?

python rect

5
推荐指数
1
解决办法
3313
查看次数

更改选择突出显示的高度

有没有办法改变文本选择突出显示的高度而不改变line-height包含它的元素的高度?

谢谢。

javascript css range rect selection

5
推荐指数
1
解决办法
834
查看次数

是否可以在svg矩形中设置负宽度?

我想基于鼠标移动移动矩形.请参考以下链接.

http://atomicrobotdesign.com/blog_media/draw/draw1.html

在mousedown事件中获取矩形起始位置并开始拖动它将在鼠标移动事件中创建矩形.但是当我移动到先前的值(即移动到小于鼠标按下值时,它将返回负值),因此宽度变为负值.

上面的链接是画布矩形.但我创建了具有相同逻辑的svg矩形.

不支持矩形的负宽度?或者如何根据鼠标移动移动矩形?

什么出错了?

我的代码片段.

ChartMouseDown:function(e){

//       e = this.normalizeMouseEvent(e);


      var mousedownCords=this.calMousePosition(e);
      this.mouseDownX=mousedownCords.X;
      this.mouseDownY=mousedownCords.Y;

      this.chartMouseDownPoint= this.GetValuebyPoint(Math.abs(this.mouseDownX-this.model.m_AreaBounds.X),Math.abs(this.mouseDownY-(this.model.m_AreaBounds.Y + this.model.m_AreaBounds.Height)));
      this.zoomingX=true;

    },



ChartMouseMove: function (evt) {

    if( this.zoomingX)
    {

    var mouseMoveX,mouseMoveY;

     var mouseMoveCords=this.calMousePosition(evt);
      mouseMoveX=mouseMoveCords.X;
      mouseMoveY=mouseMoveCords.Y;
      $(this.ZoomAreaRect).remove();
      var width =  Math.abs(mouseMoveX - this.mouseDownX);
      var height = mouseMoveY - this.mouseDownY;
      var x;
      if(mouseMoveX > this.mouseDownX)
      x= this.mouseDownX;
      else
      x= mouseMoveX;

       this.ZoomAreaRect = document.createElementNS("http://www.w3.org/2000/svg", "rect");

        $(this.ZoomAreaRect).attr({
            'id': 'ZoomArea', 'x': x, 'y': this.model.m_AreaBounds.Y, 'width': width, 'height': this.model.m_AreaBounds.Height,
            'fill': 'gray', 'stroke-width': 1, 'stroke':'gray'
        });

       $(this.ZoomAreaRect).appendTo(this.SvgObject); …
Run Code Online (Sandbox Code Playgroud)

svg rect jquery-svg

5
推荐指数
1
解决办法
4539
查看次数

Pygame 在碰撞检测时停止移动

我本质上是想用 pygame 制作一个“实体”对象。目标是在玩家接触时将其击退。我目前正在使用的(但无法正常工作)如下:

keys_pressed = pygame.key.get_pressed()
if 1 in keys_pressed:
    if keys_pressed[K_w]:
        self.player_l[1] += -2
        if self.player_r.colliderect(self.tower_r): self.player_l[1] -= -2
    if keys_pressed[K_a]:
        self.player_l[0] += -2
        if self.player_r.colliderect(self.tower_r): self.player_l[0] -= -2
    if keys_pressed[K_s]:
        self.player_l[1] += 2
        if self.player_r.colliderect(self.tower_r): self.player_l[1] -= 2
    if keys_pressed[K_d]:
        self.player_l[0] += 2
        if self.player_r.colliderect(self.tower_r): self.player_l[0] -= 2
Run Code Online (Sandbox Code Playgroud)

这样做的问题是,玩家被“卡”在塔楼矩形内,尽管返回到碰撞开始之前所在的位置,但玩家矩形将始终被拉回到塔楼中,并且碰撞将继续进行。扳机。最初接触塔矩形后,玩家将无法向任何方向移动。

python pygame rect

5
推荐指数
1
解决办法
4699
查看次数

DPI识别和Rect

我遇到了一个小问题,我似乎无法找到答案.我有一个应用程序,它获取某些进程并获取它的窗口大小.唯一的问题是需要一定百分比的实际屏幕尺寸(用户看到).

我想制作一个应用程序的屏幕截图,但是如果我使用窗口的Rect我得到的屏幕比它小,因为resolotion是125%.这意味着我输出的原始分辨率(1280 * 800)小于我的屏幕分辨率(1600 * 1000)你可以理解这个小的打嗝让我的程序不可靠.我的问题是如何解决这个问题?

我创建了一个我设置DPIAware为true 的清单.我还在调试中禁用了Visual Studio主机.但它没有帮助.我仍然得到相同的值和相同的问题.这是我的实际屏幕截图的代码片段:

RECT Rect = new RECT();
System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName("Process");
ShowWindow(p[0].MainWindowHandle, 9);
SetForegroundWindow(p[0].MainWindowHandle);

if (GetWindowRect(p[0].MainWindowHandle, ref Rect))
{
    var bmp = new Bitmap(Rect.Width, Rect.Height);
    var graphics = Graphics.FromImage(bmp);
    graphics.CopyFromScreen(Rect.Left, Rect.Top, 0, 0, new Size(Rect.Width, Rect.Height), CopyPixelOperation.SourceCopy);
    bmp.Save(@"C:\Screenshots\temp1.png");
}
Run Code Online (Sandbox Code Playgroud)

这给了我一个屏幕截图1280 * 800,不足以涵盖整个过程,这是1600 * 1000.一切都因为屏幕坐标不对而关闭.如果我将所有内容乘以1,25就可以了,但这不是解决方案,因为我不知道其他PC上的DPI设置是什么.

编辑3:

我将在其中发布包含RECT的完整代码.

RECT Rect = new RECT();
System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName("LoLPatcherUx");
ShowWindow(p[0].MainWindowHandle, 9);
SetForegroundWindow(p[0].MainWindowHandle);

if (GetWindowRect(p[0].MainWindowHandle, ref Rect))
{ …
Run Code Online (Sandbox Code Playgroud)

c# screenshot bitmap rect dpi-aware

5
推荐指数
1
解决办法
1877
查看次数

pygame rect碰撞小于图像

如何在pygame中定义小于图像的矩形碰撞检测?我想要像第二个图像那样的碰撞模式,但是当我尝试在方法 rect 中设置宽度和高度时,我有一个剪切图像。

在此处输入图片说明

当我尝试使用图像大小进行设置时,碰撞检测显示为红色

    self.rect = pygame.rect.Rect(location, self.image.get_size())
Run Code Online (Sandbox Code Playgroud)

如果我使用宽度和高度设置大小,我只有第三张图片

    self.rect = pygame.rect.Rect(location, (32, 150))
Run Code Online (Sandbox Code Playgroud)

我真的不喜欢使用像素完美碰撞,因为它是最慢的碰撞检测,所以有人知道如何使用 Rect 实现第二种图像碰撞方法?谢谢。

python pygame image rect collision

5
推荐指数
1
解决办法
2123
查看次数

带圆角的 Pygame 按钮,border_radius 参数不起作用

我目前正在学习pygame。在编写带圆角的矩形时,我遇到了一个问题。

pygame.draw.rect() 绘制一个矩形 rect(surface, color, rect) -> Rect rect(surface, color, rect, width=0, border_radius=0, border_radius=-1, border_top_left_radius=-1, border_top_right_radius=- 1, border_bottom_left_radius=-1) -> 矩形 在给定的表面上绘制一个矩形。

border_radius (int) -- (可选)用于绘制圆角矩形。支持的范围是[0, min(height, width) / 2],其中0代表没有圆角的矩形。

这是pygame官方文档的描述。

username_rect = pg.rect.Rect(screenwidth/2 - 1/8*screenwidth, screenheight*1/5, 1/4*screenwidth, username_title_render.get_height() + 10)
pg.draw.rect(screen, (0,0,0), username_rect,border_radius = 15)
Run Code Online (Sandbox Code Playgroud)

这里是主要部分。但随后我收到此错误消息:

TypeError: 'border_radius' is an invalid keyword argument for this function
Run Code Online (Sandbox Code Playgroud)

我已经尝试添加“width=2”参数,但随后它说参数太多。不幸的是,获取其他数字也无济于事。我目前使用 pygame 版本 2.0.0.dev6 (SDL 2.0.10,python 3.8.1)

如果您能帮助我,我将非常高兴,非常感谢!

python pygame rect rounded-corners

5
推荐指数
1
解决办法
8302
查看次数

为什么 Rect.contains(right,bottom) 返回 false?

我正在调试我的触摸代码的一个问题,我偶然发现了这个Rect类的奇怪行为。

Rect rect = new Rect(0,0,10,10);
rect.contains(0,0)   // true
rect.contains(10,10) // false
rect.contains(9,9)   // true
Run Code Online (Sandbox Code Playgroud)

为什么会这样??!

为什么右边界和下边界是互斥的,而左边界和上边界是互斥的?我觉得这不合逻辑,也没有文件说明这一点。

android rect

4
推荐指数
1
解决办法
1526
查看次数

使用 python 3.4 获取 pygame 中的曲面中心

我在使用 pygame 获取曲面中心时遇到问题。当尝试将曲面放置在其他曲面上时,它默认位于曲面的左上角。

为了证明我的意思,我写了一个简短的程序。

import pygame

WHITE = (255, 255, 255)

pygame.init()
#creating a test screen
screen = pygame.display.set_mode((500, 500), pygame.RESIZABLE)
#creating the canvas
game_canvas = screen.copy()
game_canvas.fill(WHITE)
#drawing the canvas onto screen with coords 50, 50 (tho its using the upper left of game_canvas)
screen.blit(pygame.transform.scale(game_canvas, (200, 200)), (50, 50))
pygame.display.flip()


#you can ignore this part.. just making the program not freeze on you if you try to run it
import sys

clock = pygame.time.Clock()
while True:
    delta_time = clock.tick(60) …
Run Code Online (Sandbox Code Playgroud)

python pygame center rect

4
推荐指数
1
解决办法
9127
查看次数

OpenCV Rect x 和 y 表示(列,行)或(行,列)

我想用 0 值替换图像 (Mat) 的矩形部分。我的图像有 1000 行和 1500 列。我想在 (890,1340) 处遮盖宽度为 150、高度为 100 的补丁。为此,我使用以下代码片段:

cv::Rect patch;
patch.y = 890;
patch.x = 1340;
patch.height = 100;
patch.width = 150;
image(patch) = 0;
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

OpenCV 错误:输入参数的大小不匹配(该操作既不是“数组操作数组”(其中数组具有相同的大小和相同的通道数),也不是“数组操作标量”,也不是“标量操作数组”) cv::arithm_op,文件 C:\build\master_winpack-build-win64-vc14\opencv\modules\core\src\arithm.cpp,第 659 行

我已经更改了 Rect patch 的 x 和 y 坐标,但仍然出现相同的错误。我在互联网上搜索,但我仍然对 Rect 参数感到困惑。

Rect x,y 是否代表(列,行)或(行,列)?

c++ opencv rect mat

4
推荐指数
1
解决办法
3084
查看次数