canvas

How to change image in canvas?[python tkinter]

那年仲夏 提交于 2019-12-25 16:58:08
问题 As below, I want to show an image in canvas using tkinter, and when a click the button, an other photo should be shown. But I failed. The first image shows well, but the image didn't change when I click the button C = Tkinter.Canvas(top, bg="#fff", height=500, width=600) // show image1 in canvas first and it works itk = ImageTk.PhotoImage(img1) C.create_image(300, 250, image=itk) C.pack() def changeImage(): // I want to show image2 in canvas, but I fails print 'change image in canvas' itk2 =

Remove canvas widgets in Tkinter

左心房为你撑大大i 提交于 2019-12-25 16:46:23
问题 from Tkinter import * import random root = Tk() width = 700 height = 600 canvas = Canvas(root, width = width, height = height, bg = "light blue") canvas.pack() pipes = [] class NewPipe: def __init__(self, pipe_pos, pipe_hole): self.pipe_pos = list(pipe_pos) def update(self): self.pipe_pos[0] -= 3 self.pipe_pos[2] -= 3 def draw(self): canvas.create_rectangle(self.pipe_pos, fill = "green") def get_pos(self): return self.pipe_pos def generate_pipe(): pipe_hole = random.randrange(0, height) pipe

HTML5 Canvas Image Moving Flickering

我与影子孤独终老i 提交于 2019-12-25 16:29:12
问题 In canvas, there is a image, which moves on events of arrow keys. But it flickers in firefox and works fine on chrome and ie. I don't want a solution like to clear only the portion of canvas, because I have other things added in canvas too. Below is my code: var velY = 0, velX = 0, speed = 2, friction = 0.90, keys = [], canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"), playerDirection="img/player/player_back.png"; function update() { if (keys[38]) { if (velY > -speed)

How to know what control the mouse has clicked in a canvas?

别说谁变了你拦得住时间么 提交于 2019-12-25 16:02:30
问题 I am creating a C# WPF application and looking for a way to do the following: I have a canvas with different user controls in it and a button. When I click on the button the cursor change to a hand (Canvas.Cursor = Cursors.Hand) Then if I click on one of the controls I get a message box showing the name of the control clicked (the name is a public property of the control). If I click somewhere else i the cursor resets and I should click on the button again before I can get the name again. I

How to know what control the mouse has clicked in a canvas?

落花浮王杯 提交于 2019-12-25 16:01:45
问题 I am creating a C# WPF application and looking for a way to do the following: I have a canvas with different user controls in it and a button. When I click on the button the cursor change to a hand (Canvas.Cursor = Cursors.Hand) Then if I click on one of the controls I get a message box showing the name of the control clicked (the name is a public property of the control). If I click somewhere else i the cursor resets and I should click on the button again before I can get the name again. I

canvas drawImage from multiple canvas to one canvas slow in chrome

旧街凉风 提交于 2019-12-25 15:59:10
问题 I want to draw a big map with +10k objects in canvas. The objects are basically many circles (maybe up to 10 different colors, all same size) and few individually shaped polygons. I also need to pan and zoom the map. I focused on just drawing the circles for now and tried many different implementations according to the recommendations made here. Having one off-screen canvas at full resolution as buffer and using drawImage to crop out the current viewport and draw it on my on-screen canvas,

Draw with a Canvas over an Image in Android/Java

邮差的信 提交于 2019-12-25 15:15:34
问题 I try to draw on a Canvas, where the background is an loaded Image in Android. It works just fine without the backgroundimage: background = (ImageView)view.findViewById(R.id.Background); Bitmap bitmap = Bitmap.createBitmap(canvasSize,canvasSize,Bitmap.Config.ARGB_8888); canvas = new Canvas(bitmap); background.setImageBitmap(bitmap); Im passing that canvas to another class and draw on it. That works fine. But when I do this: background = (ImageView)view.findViewById(R.id.Background); Bitmap

使用canvas 画钟表

狂风中的少年 提交于 2019-12-25 14:52:47
学习了一些关于canvas的知识后,自己捣鼓了一个时钟表。可能代码还可以更加优化,但是也还能实现 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>钟表</title> <style> /* canvas { border: 1px solid #000; } */ ul { list-style: none; } </style> </head> <body> <canvas id="mycanvas" width="800" height="600">您的浏览器不支持,请更换浏览器</canvas> <script> var mycanvas = document.getElementById('mycanvas') //获取上下文 var ctx = mycanvas.getContext('2d') //转换中心点 ctx.translate(mycanvas.width / 2, mycanvas.height / 2) //函数自调用

Prevent users from submitting their own image with ajax?

你说的曾经没有我的故事 提交于 2019-12-25 14:42:03
问题 I've been working on this way for people to draw stuff on canvas and upload it to the server. It works fine except for people being able to insert their own images (my friend tested it) Here's what it does: Person clicks "submit" their canvas is saved into base64 and is sent using $.post() php file in the $.post() runs and saves the file to a file in the server Is there any way from preventing the user to be able to submit their own images, I already check image dimensions and so on but they

Rotate and save image for JavaScript

人走茶凉 提交于 2019-12-25 14:29:06
问题 I am writing a webapp which loads the image and display on canvas (more exact, I am writing a Tizen app which uses HTML5/JavaScript). I can load the image properly: function loadImage(file) { var img = new Image(); img.src = file; return img; } Everything works fine until I started to get images which display in wrong orientation. I figure out how to get the EXIF and orientation, and I was wondering how do I change the above function to return a proper image? function loadImage(file) { var