canvas

Tkinter 'bind' with 'canvas' and threading ValueError

删除回忆录丶 提交于 2019-12-25 07:32:07
问题 At first, I thought this was an issue that could be solved in this post that I found. However, I have tried to implement the after method but it seems to not work. (More info on how I believe my question is different and not a duplicate is a little further down below.) The error is formed when trying to bind button-1 to the function callback , which is running from a different thread than everything else. The code in question is here def callback(event): print(event) #This function normally

Unable to get correct data from canvas getImageData

我的梦境 提交于 2019-12-25 07:32:03
问题 This is in continuation to question How to get pixel data from canvas which contains the screenshot generated by a chrome extension? and the source code is available here https://github.com/whizzzkid/ColorHelper-Chrome/ The issue I am facing here is, the color I was expecting it to output is not correct and seems to be rather random values. Any help on this will be appreciated. active = false; imgData = canvas = canvasContext = pixelData = ""; chrome.extension.onMessage.addListener(function

Save HTML DIV as an image with save as pop up [closed]

半腔热情 提交于 2019-12-25 07:28:09
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I want to make a web app which makes comics. It's very basic and I don't know Canvas very well. The user can upload 2 images and they appear in two divs. Then these divs are in one whole div along with other

Drawing with sugar

一个人想着一个人 提交于 2019-12-25 07:17:16
问题 I want to create a drawing in sugar thing, much the same as you would throw some sugar on a table and using your fingers to "erase" the sugar particles to form an image. Does anyone know of a js type tool I can use to make this happen? I suppose I can take a photo of a desk, and a photo of desk with some sugar on it, and then just erase the top layer, but I'm worried that this won't give a real effect. I'm currently thinking of having a photo of desk, and then using JS to generate a lot of

Drawing with sugar

笑着哭i 提交于 2019-12-25 07:16:03
问题 I want to create a drawing in sugar thing, much the same as you would throw some sugar on a table and using your fingers to "erase" the sugar particles to form an image. Does anyone know of a js type tool I can use to make this happen? I suppose I can take a photo of a desk, and a photo of desk with some sugar on it, and then just erase the top layer, but I'm worried that this won't give a real effect. I'm currently thinking of having a photo of desk, and then using JS to generate a lot of

Why is my image not showing on the canvas?

风格不统一 提交于 2019-12-25 07:06:40
问题 I am trying to show an image on a canvas at the top corner and the draw function is not working properly. What have I done wrong. The above image is what I want to show on the screen. <html> <head> <title></title> </head> <body> <p><canvas id="canvas" style="border:1px solid black;" width="450" height="310"></canvas> </body> <script> var c=document.getElementById("canvas"); var ctx=c.getContext("2d"); draw(); function draw(){ var img = new Image(); img.src = "t.gif"; ctx.drawImage(img,0,0); }

Javascript: Is it possible to set different font sizes for different texts in a 2D canvas?

有些话、适合烂在心里 提交于 2019-12-25 06:59:26
问题 Afaik, you can only set the font for the WHOLE canvas. var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); ctx.font = "30px Arial" I would like lets say, text1 to be "30px Arial" and text2 to be "10px Arial". Is this possible? 回答1: Yes, its is possible: //first text ctx.font = "30px Arial"; ctx.fillText("Hello World",10,50); //second text ctx.font = "20px Arial"; ctx.fillText("Bell World",50,100); 来源: https://stackoverflow.com/questions/36801391/javascript-is-it

Collision Detection with javascript on the html canvas element without using jquery

落爺英雄遲暮 提交于 2019-12-25 06:55:29
问题 I have something I can not wrap my head around, I have been trying for a couple of hours. I am making a simple game. I have most of the code done, but I cannot make collision detection work, now matter how hard I try JS function collision() { //Tank1 if (bulcords2.x < tankcords.x + 31 && bulcords2.x + 5 > tankcords.x && bulcords2.y < tankcords.y + 31 && 1 + bulcords2.y > tankcords.y) { } } 回答1: To determine a collision in one dimension, say X, consider this example x X ........bbb............

Chart.js how to add a line in the canvas for bar chart

让人想犯罪 __ 提交于 2019-12-25 06:55:24
问题 With a Chart.js - Bar Chart how to add a straight line for achievements such as if over 75/100 is a pass - so need a line in the 75 count. or a thick line on the grid... 4px solid etc... http://drawingwithnumbers.artisart.org/wp-content/uploads/2013/03/v8-simple-measures.png Like the green stripped line (Target 0.7) on the right hand side...of this image... So if I use this fiddle as an example... would need a straight line at values 75000 http://jsfiddle.net/rnX2Z/1/ Was trying to add this

Change origin of canvas drawn image

寵の児 提交于 2019-12-25 06:46:39
问题 So I resizing a image using canvas. WHat happens is that is always resizes from the same point with is (0, 0) . I want it to change it's pivot/origin according to which anchor is selected to resize. Which means if _ is selected: Bottom-Left -> Top-Right Bottom-Center -> Top-Center Bottom-Right -> Top-Left Top-Left -> Bottom-Right Top-Center -> Bottom-Center Top-Right -> Bottom-RIght Left -> Right RIght -> Left Here's what's happening now: http://jsfiddle.net/mareebsiddiqui/2Gtq9/3 Here's my