canvas

Performance drops when trying to reset whole scene with Three.js

只愿长相守 提交于 2020-01-24 08:22:08
问题 In my current project Im using Threejs for buildin a level with meshes. All the graphical stuff with camera, scene, projector, renderer and so on is done in one object. For test purposes I want to reset the whole scene with different parameters, for example different level sizes. Because I want measure time of an algorithm I want a "full" reset. So my current approach is deleting the div-box containing the scene/canvas and deleting the whole object which has the threejs code. After this I

Performance drops when trying to reset whole scene with Three.js

对着背影说爱祢 提交于 2020-01-24 08:20:22
问题 In my current project Im using Threejs for buildin a level with meshes. All the graphical stuff with camera, scene, projector, renderer and so on is done in one object. For test purposes I want to reset the whole scene with different parameters, for example different level sizes. Because I want measure time of an algorithm I want a "full" reset. So my current approach is deleting the div-box containing the scene/canvas and deleting the whole object which has the threejs code. After this I

Canvas strokeStyle not reliably changing?

丶灬走出姿态 提交于 2020-01-24 08:18:10
问题 Here's my code. For some reason it draws the lines in mostly grey. It would appear that some of the lines are being drawn with two stroke styles on top of each other, even though my draw calls don't actually overlap. Some of the lines are white with inner grey. My white lines are thicker than my grey ones so obviously it's drawing two lines. Are canvas draw calls asynchronous or something? Any idea why? for (var i=0; i<minor_lanes.length; i++) { connect(minor_lanes[i], "#333", 3); } for (var

javascript 未来新方法的介绍

Deadly 提交于 2020-01-24 05:05:41
JavaScript1.6数组方法的扩展 var tmp = [1, 2, 3, 4, 5, 3]; console.log('indexOf:找出数组中某一对象的下标,如果没有则为-1'); console.log(tmp.indexOf(3) == 2); console.log(tmp.indexOf(8) == -1); console.log('lastIndexOf:找出数组中某一对象最后一次出现的下标'); console.log(tmp.lastIndexOf(3) == 5); console.log('forEach:对数组的每个元素调用函数'); tmp.forEach(alert); console.log('every:只当所有对象都返回true则为true'); console.log(tmp.every(function (num) { return num<6; })); console.log('some:只要其中一个对象返回true则为true'); console.log(tmp.some(function (num) { return num>6; })); console.log('filter:只保留满足某一具体条件的对象来过滤数组,返回满足条件的数组'); console.log(tmp.filter(function (num) {

Drawing with Transparent Paint on Android

这一生的挚爱 提交于 2020-01-24 04:37:21
问题 When I use Paint with Color.TRANSPARENT on a normal 2D canvas in Android, I don't get any results and my intention was to get rid of some of the contents on the canvas. I mean the contents that I want to dispose of don't disappear. This is the code for my Paint : mPointFillPaint = new Paint(); mPointFillPaint.setColor(Color.TRANSPARENT); mPointFillPaint.setAntiAlias(true); mPointFillPaint.setStyle(Paint.Style.FILL); mPointFillPaint.setStrokeJoin(Paint.Join.MITER); 回答1: The following Paint

Can I Turn Off Hardware Accelerated Canvas From Javascript?

。_饼干妹妹 提交于 2020-01-24 04:15:15
问题 Chrome 18 seems to have a pretty big problem with Ext 4 charts. Is there any way I can disable the hardware accelerated canvas? (I'm pretty sure that's what the bug is from) or will I have to wait for someone to release a patch? 回答1: Command line switch: --disable-accelerated-2d-canvas Added that at the end of my Chrome shortcut target and checked chrome://gpu/ Canvas: Software only. Hardware acceleration disabled. 回答2: This temporary fix may be helpful: http://www.sencha.com/forum/showthread

微信小程序自定义环形进度条

*爱你&永不变心* 提交于 2020-01-24 03:26:48
做微信小程序的朋友大都接触过或自己动手写过自定义组件,最近我一直都在忙微信小程序的项目,这里我分享一个项目中自己写的一个环形进度条。 废话不多说,先上效果图: 是不是你想要的效果呢?下面说一下这么个东东是咋整出来的吧! 先看下项目结构 ProgressView文件夹里面就是环形进度条的主要代码了! 先说下思路。整这么个东东,毫无疑问肯定得用到画布,画的东西也不复杂,画一个底环,上面覆盖一个当前进度的弧形就行了,至于中间的文字用css定位居中就好了。思路有了,那么,盘它~ 创建自定义组件 先看看布局代码: ProgressView.wxml <view class="canvasView"> <canvas canvas-id="circleBar" style="width:{{width}}rpx;height:{{height}}rpx;"> </canvas> <text hidden="{{!showText}}" style="font-size:{{textSize}}rpx;color:{{textColor}}">{{percentage}}%</text> </view> ProgressView.wxss .canvasView{ display: flex; align-items: center; justify-content: center;

Error android.graphics.Canvas.throwIfRecycled when overlaying bitmaps

梦想与她 提交于 2020-01-24 03:05:14
问题 Im trying to overlay images on a canvas using the following method: private Bitmap overlay(Bitmap bmp1, Bitmap bmp2) { bmOverlay = Bitmap.createBitmap(70, 70, Bitmap.Config.RGB_565); canvas = new Canvas(bmOverlay); canvas.drawBitmap(bmp1, 0, 0, null); //line 179 canvas.drawBitmap(bmp2, 0, 0, null); return bmOverlay; } However, my app keeps crashing and the log reads: java.lang.NullPointerException at android.graphics.Canvas.throwIfRecycled(Canvas.java:954) at android.graphics.Canvas

three.js学习

我只是一个虾纸丫 提交于 2020-01-24 02:08:24
一个新的领域。 demo1: <!DOCTYPE html> <html> <head> <title></title> <style>canvas { width: 100%; height: 100% }</style> <script src="js/three.js"></script> </head> <body> <script> var scene = new THREE.Scene();//场景 var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);//相机 var renderer = new THREE.WebGLRenderer();//渲染器 renderer.setSize(window.innerWidth, window.innerHeight);//渲染器宽高 document.body.appendChild(renderer.domElement);//将渲染器加入文档中 var geometry = new THREE.CubeGeometry(1,1,1);//创建物体 var material = new THREE.MeshBasicMaterial({color: 0xffff00});//创建物体

How to convert coordinates on Bitmap to real coordiates on Image View displayed on screen

大兔子大兔子 提交于 2020-01-24 01:08:31
问题 I have an Image View which displays an image (e.g 2000x1000 pixels) and I have a coordinate (X,Y) on that image (not the image view). The canvas of my Image View is 600x800 for example. How can I convert the point (X,Y) to screen coordinate so that I can draw a path with them on the OnDraw(...) method of Image View. Any help is appreciated! Thank you. Update: If I use matrix to draw the path between coordinates, it works but the path and objects i draw become really small. Here is the code i