Three.js detect webgl support and fallback to regular canvas

Yes, it’s possible. You can use CanvasRenderer instead of WebGLRenderer. About WebGL detection: 1) Read this WebGL wiki article: http://www.khronos.org/webgl/wiki/FAQ if (!window.WebGLRenderingContext) { // the browser doesn’t even know what WebGL is window.location = “http://get.webgl.org”; } else { var canvas = document.getElementById(“myCanvas”); var context = canvas.getContext(“webgl”); if (!context) { // browser supports WebGL but initialization … Read more

Set Font Awesome icons as cursor – is this possible?

Got it! Create a canvas Draw the fa icon on it Change it into a base-64 image url Apply the image on the cursor css style And I made a demo: http://jsfiddle.net/rqq8B/2/ // http://stackoverflow.com/questions/13761472/how-to-render-glyphs-from-fontawesome-on-a-canvas-element // http://stackoverflow.com/questions/13932291/css-cursor-using-data-uri $(function() { var canvas = document.createElement(“canvas”); canvas.width = 24; canvas.height = 24; //document.body.appendChild(canvas); var ctx = canvas.getContext(“2d”); ctx.fillStyle = … Read more

Pdf file size too big created using jspdf

You need to compress the images in the PDF’s that you are generating. Try using Deflate.js and adler32cs.js and use the compress parameter in both jsPDF and addImage functions that you are using. For eg : var doc = new jsPDF(‘p’, ‘pt’,’a4′,true); make sure you set the last parameter as ‘true’ refer to : https://github.com/MrRio/jsPDF/blob/ddbfc0f0250ca908f8061a72fa057116b7613e78/jspdf.js#L146 … Read more

Dynamically generated favicon

EDIT: Got it working with var canvas = document.createElement(‘canvas’); canvas.width = 16;canvas.height = 16; var ctx = canvas.getContext(‘2d’); var img = new Image(); img.src=”https://stackoverflow.com/favicon.ico”; img.onload = function() { ctx.drawImage(img, 0, 0); ctx.fillStyle = “#F00″; ctx.fillRect(10, 7, 6, 8); ctx.fillStyle=”#FFFFFF”; ctx.font=”bold 10px sans-serif”; ctx.fillText(‘2’, 10, 14); var link = document.createElement(‘link’); link.type=”image/x-icon”; link.rel=”shortcut icon”; link.href = canvas.toDataURL(“image/x-icon”); … Read more

canvas getContext(“2d”) returns null

For others who hit this page while searching for getContext returning null, it can happen if you have already requested a different type of context. For example: var canvas = …; var ctx2d = canvas.getContext(‘2d’); var ctx3d = canvas.getContext(‘webgl’); // will always be null The same is equally true if you reverse the order of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)