标签: rect

Windows GDI中的Delphi TextRect

Delphi TextRectGDI中是否有类似的东西?我看了看DrawText, DrawTextEx,但我找不到我需要的东西.我需要绘制一个进度条的百分比文本,该文本分为两个颜色部分,例如文本的左侧部分是黑色,右侧是白色.所以通常在所有进度条中.

在此输入图像描述

谢谢你的回答!

delphi text gdi rect drawtext

3
推荐指数
1
解决办法
2040
查看次数

鼠标"点击"时的Pygame动作.rect?

我一直在编写一个测试函数来学习pygame.rect上的鼠标"click"动作将如何产生响应.

至今:

def test():
    pygame.init()
    screen = pygame.display.set_mode((770,430))
    pygame.mouse.set_visible(1)
    background = pygame.Surface(screen.get_size())
    background = background.convert()
    background.fill((250,250,250))
    screen.blit(background, (0,0))
    pygame.display.flip()

    ## set-up screen in these lines above ##

    button = pygame.image.load('Pictures/cards/stand.png').convert_alpha()
    screen.blit(button,(300,200))
    pygame.display.flip()

    ## does button need to be 'pygame.sprite.Sprite for this? ##
    ## I use 'get_rect() ##
    button = button.get_rect()

    ## loop to check for mouse action and its position ##
    while True:
        for event in pygame.event.get():
            if event.type == pygame.mouse.get_pressed():
                ## if mouse is pressed get position of cursor …
Run Code Online (Sandbox Code Playgroud)

python pygame rect mouseevent

3
推荐指数
1
解决办法
3万
查看次数

在Rect对象上创建WPF工具提示

我正在使用一个开源图表库,在图表上创建标记.(动态数据显示)我正在创建的标记是使用Rect对象创建的.我注意到System.Windows.Shapes中的所有Shapes都有一个ToolTip属性,但System.Windows.Rect没有.我希望弹出一个工具提示,告诉用户当鼠标悬停在标记上时标记的价格值.当鼠标进入rect占据的区域时,我正在考虑创建并弹出一个工具提示,但我不知道有多少可能考虑到矩形将被图表缩放/平移.还有其他建议吗?

这是我正在创建的标记的代码(来自Felice Pollano博客)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Shapes;
using System.Windows.Controls;
using System.Text;
using System.Windows;
using System.Windows.Media;

namespace Microsoft.Research.DynamicDataDisplay.PointMarkers
{
public class CandleStickPointMarker:ShapePointMarker,ITransformAware
{
    public double CandlestickWidth
    {
        get { return (double)GetValue(CandlestickWidthProperty); }
        set { SetValue(CandlestickWidthProperty, value); }
    }
    public static readonly DependencyProperty CandlestickWidthProperty =
        DependencyProperty.Register("CandlestickWidth", typeof(double), typeof(CandleStickPointMarker), new UIPropertyMetadata(4.0));
    public double CandlestickStrokeWidth
    {
        get { return (double)GetValue(CandlestickStrokeWidthProperty); }
        set { SetValue(CandlestickStrokeWidthProperty, value); }
    }

    public static readonly DependencyProperty CandlestickStrokeWidthProperty =
        DependencyProperty.Register("CandlestickStrokeWidth", typeof(double), typeof(CandleStickPointMarker), new UIPropertyMetadata(1.0));
    public Brush …
Run Code Online (Sandbox Code Playgroud)

c# wpf tooltip rect dynamic-data-display

3
推荐指数
1
解决办法
3637
查看次数

android rectF警告

我在画布上画了一个椭圆形:

RectF f = new RectF(-r, -r, r, r);
canvas.drawOval(f , mPaint);  
Run Code Online (Sandbox Code Playgroud)

为什么我在RectF上看到警告?

在绘制/布局操作期间避免对象分配(预分配和重用)

android rect draw

3
推荐指数
1
解决办法
4094
查看次数

KineticJS:右键点击火力点击

我正在使用Kineticjs,我正在定义这样的rect事件

this.rect.on('click tap', function(){
foo();
});
Run Code Online (Sandbox Code Playgroud)

当我左键单击时,也会在右键单击时触发该事件.如何通过右键单击来避免触发此事件?(我无法在页面中禁用右键单击,因为如果我右键单击rect,我想打开上下文菜单)

谢谢

jquery events right-click rect kineticjs

3
推荐指数
1
解决办法
1758
查看次数

cgcontext旋转矩形

伙计们!我需要将一些图像绘制到CGContext.这是相关的代码:

CGContextSaveGState(UIGraphicsGetCurrentContext());

CGContextRef ctx = UIGraphicsGetCurrentContext();

CGRect rect = r;

CGContextRotateCTM(ctx, DEGREES_TO_RADIANS(350));
[image drawInRect:r];


CGContextRestoreGState(UIGraphicsGetCurrentContext());
Run Code Online (Sandbox Code Playgroud)

实际上,矩形是旋转并显示在一个不是我的目的的区域.我只想旋转图像并显示在同一位置.有任何想法吗 ?????

core-graphics rotation rect cgcontext ios

3
推荐指数
1
解决办法
6671
查看次数

Android Rect无法正常工作

我一直在努力研究一个简单的代码两天了.我尝试了所有的改动,但似乎没有任何改变.我试图绘制不同颜色的垂直矩形.在第一个中,我只使用一个Rect变量并移动坐标.这是代码的相关部分.

 Rect myRect1=new Rect();
 Random colorMe=new Random();
for(int j=0;j<5;j++){
    myRect1.set(myCanvas.getWidth()/5*j, 0, myCanvas.getWidth()/5*j, myCanvas.getHeight());
    paint.setColor(Color.rgb(colorMe.nextInt(255), colorMe.nextInt(255), colorMe.nextInt(255)));
    myCanvas.drawRect(myRect1, paint);
}
Run Code Online (Sandbox Code Playgroud)

我试过的其他改动是通过阵列.这是代码.

 Rect[] myRect=new Rect[5];
 Random colorMe=new Random();
for(int j=0;j<5;j++){
    myRect[j].set(myCanvas.getWidth()/5*j, 0, myCanvas.getWidth()/5*j, myCanvas.getHeight());
    paint.setColor(Color.rgb(colorMe.nextInt(255), colorMe.nextInt(255), colorMe.nextInt(255)));
    myCanvas.drawRect(myRect[j], paint);
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决实际存在的问题吗?

arrays android rect

2
推荐指数
1
解决办法
1725
查看次数

将System.Windows.Rect投射到System.Windows.Point

我想在C#中转换此C ++代码:

RECT rcCurrent; ::GetWindowRect ( hwndChild, &rcCurrent ); ::MapWindowPoints ( NULL, hWnd, reinterpret_cast<LPPOINT>(&rcCurrent), 2);

但是我不知道如何转换:

reinterpret_cast<LPPOINT>(&rcCurrent)

如何将System.Windows.Rect强制转换为System.Windows.Point?

c# c++ winapi point rect

2
推荐指数
1
解决办法
1576
查看次数

如何在 SDL2 中的不透明矩形之上绘制透明或半透明矩形?

这是我绘制SDL_Rect对象的代码rectrect2

#include <iostream>
#include <SDL2/SDL.h>

int main(){
    SDL_Window *window=     SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN);
    if(window == 0)
        std::cout << SDL_GetError() << std::endl;

    SDL_Renderer *renderer= SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
    if(renderer == NULL)
        std::cout << SDL_GetError() << std::endl;

    SDL_Rect rect;
    rect.x=     100;
    rect.y=     100;
    rect.w=     100;
    rect.h=     100;

    SDL_Rect rect2;
    rect2.x=    150;
    rect2.y=    150;
    rect2.w=    100;
    rect2.h=    100;

    while(true){
        Uint8 r,g,b,a;

        r=  32;
        g=  32;
        b=  32;
        a=  255;
        if(SDL_SetRenderDrawColor(renderer, r, g, b, a) …
Run Code Online (Sandbox Code Playgroud)

c++ sdl render rect sdl-2

2
推荐指数
1
解决办法
3278
查看次数

如何在 pygame 中移动球而不是在屏幕上留下痕迹?

我正在构建一款乒乓球游戏,试图提高编程水平,但我在移动球时遇到了困难。当调用 move_right 方法时,椭圆会向右拉伸而不是向右移动。我尝试将 ball 变量放入 init 方法中,但这只会使其根本不移动,即使变量应该因 move_right 方法而改变。我还尝试将 x 和 y 位置设置为 Ball 类中的参数,但这也只是拉伸了它。我不明白为什么当我运行以下代码时,球我试图向右移动而不是向右移动。有人可以解释为什么会发生这种情况吗?我已经尝试了我能想到的一切,但我无法让它做我想做的事。

import pygame,sys
import random


class Ball:
    def __init__(self):
        self.size = 30
        self.color = light_grey
        self.x_pos = width/2 -15
        self.y_pos = height/2 -15
        self.speed = 1
        #self.ball = pygame.Rect(self.x_pos, self.y_pos,self.size,self.size)
   

    def draw_ball(self):
        ball = pygame.Rect(self.x_pos, self.y_pos,self.size,self.size)
        pygame.draw.ellipse(screen,self.color,ball)

    def move_right(self):
        self.x_pos += self.speed

class Player:
    def __init__(self,x_pos,y_pos,width,height):
        self.x_pos = x_pos
        self.y_pos = y_pos
        self.width = width
        self.height = height
        self.color = light_grey

    def draw_player(self):
        player = pygame.Rect(self.x_pos,self.y_pos,self.width,self.height) …
Run Code Online (Sandbox Code Playgroud)

python pygame rect pygame-surface

2
推荐指数
1
解决办法
568
查看次数