canvas

Automatically Moving Shape? Python 3.5 Tkinter

断了今生、忘了曾经 提交于 2020-01-07 05:13:17
问题 In python, I am currently making a 'game' using tkinter, but it has decided not to work. What I am trying to do is have one rectangle movable by the mouse, and the other rectangle that moves up and down continuously without the player doing anything. Here is my code: from tkinter import * import time root = Tk() root.title("Game") root.geometry("800x800") def motion(): canvas.delete(ALL) a = canvas.create_rectangle(event.x-50, event.y-50, event.x+50, event.y+50, fill='red') def motion2(): b =

16、canvas性能优化建议

本小妞迷上赌 提交于 2020-01-07 05:10:00
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 在离屏canvas上预渲染相似的图形或重复的对象 如果你发现你的在每一帧里有好多复杂的画图运算, 请考虑创建一个离屏canvas,将图像在这个画布上画一次(或者每当图像改变的时候画一次),然后在每帧上画出视线以外的这个画布 eg:创建离屏canvas var offCanvas = document.createElement("canvas"); offCanvas.width=400; offCanvas.height=400; var offContext = offCanvas.getContext("2d"); ....... 详细有道笔记链接>> 来源: oschina 链接: https://my.oschina.net/u/3698702/blog/1844958

Security error“ code: ”1000 on Firefox with Canvas.toDataURL

﹥>﹥吖頭↗ 提交于 2020-01-07 05:08:25
问题 I've got error like jQuery and Canvas.toDataURL Some user told that might run it on server but I run it on my server not local and still got this 'Security error" code: "1000' error. Security error" code: "1000 [Break On This Error] data: 'raw='+canvas.toDataURL("image/png", ""), 回答1: oh I've found solution just change toDataURL('image/png', '') to toDataURL() and it run correctly 来源: https://stackoverflow.com/questions/4984431/security-error-code-1000-on-firefox-with-canvas-todataurl

期末测试javaweb 考勤系统前端

只谈情不闲聊 提交于 2020-01-07 05:06:05
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <% Object message = request.getAttribute("message"); if(message!=null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%} %> <div align="center"> <h1 style="color: black;">员工信息录入</h1> <a href="chenggong.jsp">返回主页</a> <form action="servlet1?method=add" method="post" onsubmit="return check()"> <div class="a"> 工号<input type="text" id="id" name=

erase an object from canvas

…衆ロ難τιáo~ 提交于 2020-01-07 04:58:06
问题 I am trying to develop an application and i want the sprites to erase once they reach the end. I am using arraylist to handle my sprites on a canvas. I want the sprites to erase themselves from the canvas and from the arraylist once their x<0 (outside of the canvas) Please help me asap. Thanks This is my code so far for the erase command: for(Sprite sprite : rockSprites){ sprite.x -=10; if (Rect.intersects(sprite.dst, die)) { rockSprites.remove(this); currentAmountOfSprites--; try { Thread

How do I use if isType() for each object on a canvas with fabric js?

偶尔善良 提交于 2020-01-07 04:48:49
问题 I am trying to show certain attributes for each object on a canvas, but I am having a difficult time writing the code to do so. E.G. I want the code below to identify the difference between a shape, text, and image objects and show attributes based off the type. Attributes to console.log: for each object on canavas check to see if - Image then URL (source) and scale <= I am having a difficult time showing the source and name of the image. Text then font family, font size, color, scale Shape

HTML5 canvas style height vs attribute height

喜夏-厌秋 提交于 2020-01-07 04:35:10
问题 I am currently learning how to use HTML5 new elements and I stumbled upon a frustrating issue with all graphic functions such as fillRect() and drawImage(). I was setting the widgth and height with style="width: 75px;height: 10px;" instead of width="200" height="100" The result being that the graphics would not be the proper scale ever. My question is, why does it make a difference? There is something I obviously do not understand about it all. Thank you 回答1: I know that at least in JSF

Animate HTML5 Canvas - Event Listeners firing more than once?

℡╲_俬逩灬. 提交于 2020-01-07 04:32:05
问题 So I am incredibly new to javascript (and coding in general), and I have managed to make an incredibly basic HTML5 canvas in Animate CC. Only problem is, when I move back to the previous frame the buttons repeat themselves. The flow: Frame 1 - Console Message Button & Next Frame Button Frame 2 - Previous Frame Button When moving back to the previous frame, the buttons fire twice (i.e. the console log message fires twice). If I repeat the process and move to the next frame and back again for a

Tkinter moving balls program creating 4 balls instead of 2

强颜欢笑 提交于 2020-01-07 04:22:22
问题 I have created a program that made a ball move around a canvas and bounce of the edge of the canvas. This worked very well so I tried to add another ball but instead of creating 2 balls it created 4, 2 of the balls move and the other two stay still. This is the code: #imports from tkinter import * import random from random import randint #Creating random x and y for the balls to move along x = random.randint(1,10) y = random.randint(1,10) print(x, " Ball 1y") print(y, " Ball 1x") x0 = random

Javascript Canvas Get images pixel data

Deadly 提交于 2020-01-07 04:07:05
问题 I have a two part question about javascript canvas: Part 1: I have a .jpg in the same file as my html document. I was wondering if there was a simple way of getting a pixel's color in that file without having to use context.getImageData(). Part 2: (If part 1 is too complex to be useful.) If I directly copy the code from this site: W3 schools getImageData() into an html file on my desktop, and add an image named img_the_scream.jpg to my desktop, then run it I get this error: Unable to get