canvas

For loop inside another for loop crashes in Javascript

余生颓废 提交于 2019-12-24 18:27:07
问题 I want to randomly generate a color for each pixel in the canvas however my loop seems to crash the browser and I cannot figure out why? I have tried reducing the loop to a static number (X = 10 x Y=100) and it seems to work. However it takes a few seconds for the result to be shown on the screen (despite my tests showing a run time of 10ms) I am new to javascript/html so this could be an obvious solution, however any help is greatly appreciated. //"use strict"; // SELECT THE CANVAS ELEMENT

Really Weird Emulator Error?! glTexImage2D - Bitmap/Canvas Error?

南楼画角 提交于 2019-12-24 18:26:09
问题 hope you are having a good Monday! I am extremely stuck. Never seen this error before, and there is not much to be found on google. I am trying to complete this tutorial on youtube, link > https://www.youtube.com/watch?v=GPzTSpZwFoU&list=PLWweaDaGRHjvQlpLV0yZDmRKVBdy6rSlg&index=3. I am experiencing the stranges emulator error, and would love an expert opinion. The code Class Background.java package com.example.smiey.game; import android.graphics.Bitmap; import android.graphics.Canvas; public

Image drawn on canvas not displayed in Google Chrome

╄→尐↘猪︶ㄣ 提交于 2019-12-24 18:16:45
问题 The following code with the 3 canvases works flawlessly with the latest IE and Mozilla FireFox. The third canvas (#drawingSurface3) fails on Google Chrome without any errors in the developer console. Even the lines are not drawn. <!doctype html> <html> <head> <title>Drawing lines in Canvas</title> <style> canvas { border: 1px solid #ccc; } </style> </head> <body> <canvas id="drawingSurface" width="300" height="300"> <p>Your browser does not support the canvas element.</p> </canvas> <br />

canvas案例——画时钟

徘徊边缘 提交于 2019-12-24 17:49:57
基本思路,先画一个200半径的圆 ctx.arc(250,250,200,0,2*Math.PI); 然后再画时分刻度,可以先利用translate变化坐标到圆的中心点,然后再通过rotate旋转 1 //画12个时刻度线 2 for(var i=0;i<12;i++){ 3 ctx.save(); 4 ctx.translate(250,250); 5 ctx.rotate(i*Math.PI/6); 6 ctx.moveTo(0,-180); 7 ctx.lineTo(0,-195); 8 ctx.stroke(); 9 ctx.restore(); 10 } 11 //画60个分刻度线 12 for(var i=0;i<60;i++){ 13 //经过时刻度跳过 14 if(i%5!=0){ 15 ctx.save(); 16 ctx.translate(250,250); 17 ctx.rotate(i*Math.PI/30); 18 ctx.beginPath(); 19 ctx.strokeStyle="#555"; 20 ctx.moveTo(0,-190); 21 ctx.lineTo(0,-195); 22 ctx.closePath(); 23 ctx.stroke(); 24 ctx.restore(); 25 } 26 } 需要注意

leaflet+canvg+html2canvas = MyImage.png

给你一囗甜甜゛ 提交于 2019-12-24 16:39:50
问题 Good day my dear friends. I want to create png file from lealfet map. I use html2canvas library, and leaflet map tiles and other elemets converts to png greatfully, but not svg-elements(offsets). I know, that there is some code to redraw all svg elements to canvas( var canvas = L.canvas(); var map = new L.Map('map', {layers: [osm], preferCanvas: true}); but this is bad way for me, because, when I change extend all svg element flickers... So...How can I using CANVG convert leaflet svg polygons

Replacing an image in KineticJS

笑着哭i 提交于 2019-12-24 16:09:11
问题 I'm trying to build a web app using KineticJS, I basically have a function which runs on load which adds an image to a canvas (stage in KineticJS). Each time the function runs though, it is adding the image again underneath the existing one, where as I need it to replace the one that is currently on the stage. I know it's something to do with me creating a new image object each time the function is loaded, but I'm confused as to why it's positioning is different (underneath). I have simulated

PIL Tkinter Canvas EPS to PNG conversion output file contains issues

元气小坏坏 提交于 2019-12-24 15:56:19
问题 So I have created the following save function for my turtle graphics program to allow the user to save the canvas as a .png file with its own file name: def savefirst(): cnv = getscreen().getcanvas() ps = cnv.postscript(colormode = 'color') hen = filedialog.asksaveasfilename() print(hen) im = Image.open(io.BytesIO(ps.encode('utf-8'))) im = im.resize((2560, 1600), Image.ANTIALIAS) quality_val = 95 sharp = ImageEnhance.Sharpness(im) sharp.enhance(2.0).save(hen + '.png', 'PNG') However, if the

Fabric Canvas changing position when Openseadragon image is rotated

六眼飞鱼酱① 提交于 2019-12-24 15:49:41
问题 I am using Fabric.js Canvas on top of OpenSeadragon(osd). I am trying to create a compass/rotater widget on top of the osd image, which will rotate the osd image. It should zoom and pan with the osd image, but should not rotate with the osd image. Things are getting tidy when i use viewer.viewport.setRotation(angle); Osd Image rotates, but the location of the Fabric canvas objects also change with it, even though i have set the objects to be in the center of the image. Here is the codePen

How can I make a rectangle be on top of all other rectangles in javascript canvas?

情到浓时终转凉″ 提交于 2019-12-24 15:33:30
问题 I have a rectangle which includes the menu. I need this rectangle to be on top of all other objects in the game. Bear in mind, no css, just javascript canvas programming. How can I do that? If you need any code about the rectangle: ctx.fillRect(0,0,width,100); That is all you need to know I guess. 回答1: The canvas itself has no in-built layering. But you have multiple options: Add a second canvas to your HTML document, and use CSS positioning to place it above the other canvas object. Draw

animation is not smooth canvas

狂风中的少年 提交于 2019-12-24 15:32:12
问题 i have made this example http://jsfiddle.net/mikulgohil/yc6Lb/ but the issue is that animation is not smooth can you help me to make it smooth 回答1: To make animations smooth you need to use requestAnimationFrame() API. http://paulirish.com/2011/requestanimationframe-for-smart-animating/ 来源: https://stackoverflow.com/questions/7857741/animation-is-not-smooth-canvas