canvas

Getting the fill color or any other property of a item drawn in a canvas in tkinter(Python)

為{幸葍}努か 提交于 2021-02-16 20:52:21
问题 I want to get the fill color or any other property of a item drawn in a canvas in tkinter. def createWidgets(self): self.canvas_1= tk.Canvas(self, bg='#FAFAFA',selectforeground='#BBDEFB'); i=self.canvas_1.create_rectangle((self.canvas_1.winfo_reqwidth()/2)+100, (self.canvas_1.winfo_reqheight()/2)+50, (self.canvas_1.winfo_reqwidth()/2)+150, (self.canvas_1.winfo_reqheight()/2)+100, fill='#FF4081',width=0) self.canvas_1.grid(); color= #want to access the fill color of item i using some getter

Pinch/pucker an image in canvas

女生的网名这么多〃 提交于 2021-02-16 13:39:25
问题 How can I pinch/pucker some area of an image in canvas? I've made a solar system animation some time ago, and I started rewriting it. Now, I want to add gravity effect to masses. To make the effect visible, I turned the background into a grid and I'll be modifying it. Desired effect is something like this (made in PS) context.background("rgb(120,130,145)"); context.grid(25, "rgba(255,255,255,.1)"); var sun = { fill : "rgb(220,210,120)", radius : 30, boundingBox : 30*2 + 3*2, position : { x :

Clean text from canvas shapes

假装没事ソ 提交于 2021-02-11 14:40:48
问题 How I clean text from canvas shape ? this my code: <div id="ways" style="width:1000px;margin:0 auto;height:100%;"> <canvas id="canvas" width="1000" height="1000"></canvas> and fiddle 回答1: Just refactor the code a bit - Extract the lines which draws the circle into a single function which takes one of those circle objects as an argument: function drawCircle(circle) { context.beginPath(); context.arc(circle.x, circle.y, circle.radius, 0, 2 * Math.PI, false); context.fillStyle = 'green'; context

Security considerations when using canvas in conjunction with file uploading

谁说胖子不能爱 提交于 2021-02-11 13:56:54
问题 I'm working on a image editor/uploader based around Pixastic where I grab image data out of an <input> tag, put it into a canvas, and after manipulating it, encode the data in base 64 and post it to my app with javascript, where it will be saved as a new image file. If it were a standard file upload, I would give the file a new (safe) name, test to make sure it was really an image file and copy it to strip any potentially malicious/personal EXIF data before making it available to users. My

Canvas Javascript FloodFill algorithm left white pixels without color

☆樱花仙子☆ 提交于 2021-02-11 13:55:16
问题 I have been working on a drawing app like paint. I am in the part of the floodfill and I am using and algorithm that I found on internet, however, it left some white pixels near the line of the figure without color, detecting what happens, I found that those pixels are not white, but its a color very close. I tried putting the alpha value of those pixels on 1, in case that those were like a transparent color, but it doesn't works. There is an example of the problem: There is my code, it's a

Tkinter, canvas, create_text and zooming

*爱你&永不变心* 提交于 2021-02-11 13:19:13
问题 Is it normal that Tkinter's Canvas' create_text 's font size doesn't change when I change the Canvas' scale with canvas.scale ? I thought that, as it is a high level GUI management system, I wouldn't have to resize manually the text done with create_text after a zooming. Isn't this strange, or am I wrong ? 回答1: It's normal, even if not entirely what you want. The scale method just changes the coordinate lists, but text items only have one of those so they just get (optionally) translated.

How to control rendering quality using JAVA

偶尔善良 提交于 2021-02-11 12:40:59
问题 I have simple drawing canvas like this: public class DrawingCanvas extends JPanel private BufferedImage image; @Override public void paintComponent(Graphics g) { super.paintComponent(g); image = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = (Graphics2D) image.getGraphics(); // draw some items.... g2.dispose(); g.drawImage(image, 0, 0, null); } } I want to ask you, if I can set some render quality? For example Antialiasing.. I want use BEST

Viewport from bigger image with html5 canvas

时间秒杀一切 提交于 2021-02-11 08:30:54
问题 I'm trying to use a smaller canvas as a viewport for another much bigger canvas. I really like the approach used in this the solution on a similar question. He basically uses CanvasRenderingContext2D.drawImage() to "crop" the buffer/offset canvas and then displays that portion of the image on the smaller canvas (viewport). I'm trying to implement a simpler version of the given solution in this fiddle: https://jsfiddle.net/avvac0x8/2/. But as you can see the viewport is not entirely in sync

How to add a texture to a Konva.Image() object in Konvajs?

荒凉一梦 提交于 2021-02-11 06:17:46
问题 I have followed the answer in this post; fill image with texture pattern, and it is working perfectly. Is there a way to do the same with KonvaJS? 回答1: AFAIK, KonvaJS does not yet support the compositing required to create your texture overlay. But a Konva.Image can take a native html5 canvas element as its image source, so just do your overlay on an html5 canvas element and then feed it to Konva: var textureImage = new Konva.Image({ image:myCanvasElement }) Example annotated code and a Demo:

How to add a texture to a Konva.Image() object in Konvajs?

余生颓废 提交于 2021-02-11 06:17:45
问题 I have followed the answer in this post; fill image with texture pattern, and it is working perfectly. Is there a way to do the same with KonvaJS? 回答1: AFAIK, KonvaJS does not yet support the compositing required to create your texture overlay. But a Konva.Image can take a native html5 canvas element as its image source, so just do your overlay on an html5 canvas element and then feed it to Konva: var textureImage = new Konva.Image({ image:myCanvasElement }) Example annotated code and a Demo: