我需要创建一个矩形对象,然后使用paint()将其绘制到applet.我试过了
Rectangle r = new Rectangle(arg,arg1,arg2,arg3);
Run Code Online (Sandbox Code Playgroud)
然后尝试使用将其绘制到applet
g.draw(r);
Run Code Online (Sandbox Code Playgroud)
它没用.有没有办法在java中这样做?我已经将谷歌搜索到其生命的一寸之内以获得答案,但我一直无法找到答案.请帮忙!
我这里有一行代码,它使用opencv的python绑定:
cv2.rectangle(img, (box[1], box[0]), (box[3], box[2]), (255,0,0), 4)
Run Code Online (Sandbox Code Playgroud)
这会在img厚度图像上绘制一个红色矩形4.
但有没有办法可以将矩形线条风格化?不是太多.只是点缀,或虚线,这是真的.
我需要使用角度移动一个矩形.实际上我想改变移动矩形的方向,当它到达我在if语句中的代码中给出的位置时!
我只需要找到如何在60,30,60,120,150,270度移动矩形的方法!
假设如果
circle.Y>=this.Height-80
Run Code Online (Sandbox Code Playgroud)
看到这个:

我真的需要使用角度来改变矩形运动的方向!所以在某个位置到达我可以根据我自己选择的角度改变矩形方向!这样:
if(circle.Y>=this.Height-80)
move in the direction of 90 degrees
if(circle.X>=this.Width-80)
move in the direction of 60 degree
Run Code Online (Sandbox Code Playgroud)
正如你在屏幕截图中看到的那样!
我一直在尝试的是:
public partial class Form1 : Form
{
Rectangle circle;
double dx = 2;
double dy = 2;
public Form1()
{
InitializeComponent();
circle = new Rectangle(10, 10, 40, 40);
}
private void Form1_Load(object sender, EventArgs e)
{
this.Refresh();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
g.FillEllipse(new SolidBrush(Color.Red), circle);
} …Run Code Online (Sandbox Code Playgroud) 我已经到了在pygame中绘制一个矩形但是我需要能够将"Hello"这样的文本输入到该矩形中.我怎样才能做到这一点?(如果你能解释一下,那将非常感激.谢谢你)
这是我的代码:
import pygame
import sys
from pygame.locals import *
white = (255,255,255)
black = (0,0,0)
class Pane(object):
def __init__(self):
pygame.init()
pygame.display.set_caption('Box Test')
self.screen = pygame.display.set_mode((600,400), 0, 32)
self.screen.fill((white))
pygame.display.update()
def addRect(self):
self.rect = pygame.draw.rect(self.screen, (black), (175, 75, 200, 100), 2)
pygame.display.update()
def addText(self):
#This is where I want to get the text from
if __name__ == '__main__':
Pan3 = Pane()
Pan3.addRect()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit(); sys.exit();
Run Code Online (Sandbox Code Playgroud)
感谢您的时间.
我画了一个矩形,睡了几毫秒 - 然后我想清除矩形,但我无法弄清楚如何.(矩形坐在图形上,所以我不能简单地用另一个矩形覆盖它)
graphics.DrawRectangle(p, innerRectangle)
System.Threading.Thread.Sleep(75)
Next I want to clear the rectange...
Run Code Online (Sandbox Code Playgroud) 我有中心坐标,旋转角度,宽度和高度。有了这个,我想使用旋转角度在原始图像上绘制一个旋转的框。Python2.7 中是否有任何方法可以实现我的要求?
它应该看起来像这个图像作为红色框。我不想提取轮廓,因为我已经有了你想要的任何坐标。
我在这里添加我的代码来完成这个问题。我使用旋转矩阵找到四个角点然后画线。
def draw_rectangle(image, centre, theta, width, height):
theta = np.radians(theta)
c, s = np.cos(theta), np.sin(theta)
R = np.matrix('{} {}; {} {}'.format(c, -s, s, c))
# print(R)
print centre[0]
p1 = [ + width / 2, + height / 2]
p2 = [- width / 2, + height / 2]
p3 = [ - width / 2, - height / 2]
p4 = [ + width / 2, - height / 2]
p1_new = np.dot(p1, R)+ …Run Code Online (Sandbox Code Playgroud) 我是初中高中java学生,我必须做一个简单的盒子和胡须的事情.我无法将我在JPanel上绘制的内容显示在JFrame上.图纸没有显示出来.谁能帮助我?
public class BoxPlot extends JFrame {
public final int MIN;
public final double Q1;
public final double MEDIAN;
public final double Q3;
public final int MAX;
public BoxPlot(int[] data){
this.setLayout(new GridBagLayout());
this.MIN = Statistics.min(data);
this.Q1 = Statistics.lowerQuartile(data);
this.MEDIAN = Statistics.median(data);
this.Q3 = Statistics.upperQuartile(data);
this.MAX = Statistics.max(data);
this.addBox(data);
this.addSummary();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(800, 600);
this.setResizable(true);
this.setVisible(true);
}
// Adds a panel with the boxplot
private void addBox(int[] data) {
Box box = new Box(data);
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0; …Run Code Online (Sandbox Code Playgroud) 我试图在Javascript中绘制一个矩形(实际上是一个选择框),以选择选择中的SVG元素.我试图修复点击和拖动矩形的代码:http://jsfiddle.net/7uNfW/26/
但有一些问题,我无法弄清楚function handleMouseDown(e)和function handleMouseUp(e)
另外,我需要了解如何在框中选择SVG元素.
任何帮助,将不胜感激.
这是关于鼠标单击[Python]上的绘制矩形.我尝试了第一个解决方案,它完美无缺.有人可以告诉我,如果我想看到正在绘制的矩形并且一旦释放鼠标按钮就修复了矩形该怎么办,因为我只能在释放按钮时看到绘制的矩形.
任何形式的帮助将不胜感激.
另外一个绘图问题MFC/GDI大师那里...... :-)
我正在使用MFC,我正在使用CDC对象进行绘图.这很好.
但是现在我想绘制一个带圆角的矩形,这条线宽几个像素.但我不希望任何填充发生!有一种方法CDC :: RoundRect - 我只是设置了我想要的笔,并用这支笔得到一个漂亮的圆角矩形.但CDC :: RoundRect也用当前画笔填充矩形.
有没有办法画线,没有填充?我还没找到任何其他方法?或者我可以创建某种"空刷",它不会改变矩形中间的内容吗?
我非常感谢你的一些好建议!
/来自瑞典的安德斯