canvas

any more optimisation I can do for this function?

旧城冷巷雨未停 提交于 2019-12-24 09:38:59
问题 I have a simple box blur function in a graphics library (for JavaScript/canvas, using ImageData) I'm writing. I've done a few optimisations to avoid piles of redundant code such as looping through [0..3] for the channels instead of copying the code, and having each surrounding pixel implemented with a single, uncopied line of code, averaging values at the end. Those were optimisations to cut down on redundant lines of code. Are there any further optimisations I can do of that kind, or, better

How do I have a picture act as a game character on top of a canvas?

人走茶凉 提交于 2019-12-24 09:38:36
问题 I have a maze game in JAVA I'm doing for a class, the maze is made on a canvas in an applet, I wanted to have another picture provided to me (of a statue like thing) act as a game character and be able to be moved around the maze by the arrow keys, so how do I place an object on a canvas that can move around and be controlled, etc.? At the moment, the only way I could get my statue on the maze was by just copying the pixels of the picture onto the maze, so it's just part of the background now

Change RectF values after Matrix scalling

那年仲夏 提交于 2019-12-24 09:06:31
问题 When I draw following line my RectF and Matrix values are, Matrix{[1.0, 0.0, 254.76411][0.0, 1.0, 388.6726][0.0, 0.0, 1.0]} RectF(0.0, 0.0, 297.0, 379.0) When I re scale like following pic, the values are, Matrix{[3.0136142, 0.0, 48.238903][0.0, 3.0136142, 177.33151][0.0, 0.0, 1.0]} RectF(0.0, 0.0, 297.0, 379.0) Here I want change the right and bottom values of RectF based on Matrix, so it will look like following instead of looks like zoomed/blurred. I know its possible, but I don't know how

Refresh SurfaceView-->Canvas on OnClickListener Android

折月煮酒 提交于 2019-12-24 08:49:10
问题 I would like each time I press one of the buttons the rectangles on the screen to change position. Or the entire SurfaceView to refresh. The app seems to run but the rectangles do not change position with the counter. Thank you very much. Hare is the xml code: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <SurfaceView android:id="@+id/surface"

Reconstruct original 16-bit Raw pixel data from the HTML5 canvas

非 Y 不嫁゛ 提交于 2019-12-24 08:48:36
问题 If a 16-bit single channel (Gray-scale) raw pixel data losslessly encoded into Image format(e.g.PNG, Webp , Jpeg-2000 or JPEG-XR) and Image rendered to HTML5 canvas, then is there any way to retrieve original 16-bit Raw pixel data from the canvas? 回答1: No. When drawn to a canvas the image is uncompressed, and all the pixels data are pre-multiplied and converted to 24-bit data + an 8-bit alpha channel (RGBA). In this process the image looses everything from the original, even for same color

Android: how to draw .svg file's elements separetly?

你说的曾经没有我的故事 提交于 2019-12-24 08:45:50
问题 I have .svg a file with some elements in it. Is there any way to draw them step by step on the canvas? I'm using com.caverock:androidsvg library, but it seems like there is no way to extract individual element. 回答1: Here is my test example video. I copied one Path from 250 (the white outline in the middle of the image, that does not pan or scroll). It was the first Path in the SVG document, and the first element in the List of Path' s "I have .svg file with some elements in it. Is there any

Why am I getting this NullPointerException?

僤鯓⒐⒋嵵緔 提交于 2019-12-24 08:38:36
问题 I can't figure this out. After initializing a Canvas with new Canvas(), referencing it results in a NullPointerException. The doc tells me this can occur when the Canvas is not "enabled", but I don't know what it means to be enabled. I tried to debug it by including while(! cvs.isEnabled()); but the program just hung. What are the conditions that could result in a Canvas not being enabled, and how do I fix them? Exception in thread "main" java.lang.NullPointerException at matt.io

Canvas Fade Out Particles

人盡茶涼 提交于 2019-12-24 08:36:46
问题 I'm a canvas beginner, sorry if this is a trivial question. How can I make the fireworks in my work fade out once they've exploded? https://jsfiddle.net/ccwhryvv/ var SCREEN_WIDTH = window.innerWidth, SCREEN_HEIGHT = window.innerHeight, mousePos = { x: 400, y: 300 }, // create canvas canvas = document.createElement('canvas'), context = canvas.getContext('2d'), particles = [], rockets = [], MAX_PARTICLES = 400, colorCode = 0; // init $(document).ready(function() { $('#content')[0].appendChild

Error in crossfading images using <canvas>

感情迁移 提交于 2019-12-24 08:25:36
问题 I'm trying to crossfade images using the canvas drawImage() method. I'm using jQuery to fadeIn() and fadeOut() the canvas. Here's the code: $("#c").fadeOut(800,function() { //aw and ah are calculated here ctx = canvas.getContext('2d'); ctx.drawImage(img1, 0, 0, aw, ah); $("#c").fadeIn(400); }); c is the id of the canvas. The problem is - if img1 has been viewed already, the fadeOut happens after the image has changed, i.e. first the image changes, and then the canvas fades out and back in. Am

Load a graph from a generated url

倖福魔咒の 提交于 2019-12-24 08:07:43
问题 I want to build an online html/css/javascript playground. When the code draws a graph, I want to be able to generate a url, with which users could load this graph in a browser. At the moment, in the playground, I have a button that links to the function generateUrl : $scope.generateUrl = function () { urls.create({ // allCode is a string like "<html><body><canvas ...>...</canvas><script>...</script></html>" content: $scope.allCode }).success(function (url) { alert(url._id) }); }; Then, I want