FAQ Database Discussion Community


HTML canvas breaking when keyboard is shown at landscape orientation

javascript,android,css,html5,canvas
have tried all these questions and answers listed, and nothing works for me! How to center canvas in html5 Resize HTML5 canvas to fit window HTML5 Canvas 100% Width Height of Viewport? Make canvas fill the whole page Make Html5 Canvas and Its contained image responsive across browsers jQuery to...

How can I make a button who draws a line

javascript,html,button,canvas,htmlbutton
I want to create a button that draws a line (with canvas) in HTML. I already tried something with CSS ( with display:none ) but it didn't work. How can I make it?

Android canvas. contains(x, y) for an oval?

android,canvas
Creating android 2d game. ...The character has obstacles, where he must not go. Basicaly it is implemented like: RectF obstacle1 = new RectF(100, 150, 200, 300); Paint paint = new Paint(); barPaint.setColor(Color.argb(130, 255, 255, 255)); canvas.drawRect(obstacle1, paint); // stopping the character in case of getting to the obstacle if (obstakle1.contains(currentXCoordinate,...

Easeljs snap to grid

javascript,canvas,drag-and-drop,easeljs,createjs
I am building an app using HTML5 in which a grid is drawn. I have some shapes on it that you can move. What I'm trying to do is to snap objects to some points defined when you hover them while moving a shape. What I tried is to save...

Fill color for an arc drawed by canvas

html5,canvas
I am trying to fill color for an arc. But, I don't want to use ctx.lineWidth to do that. I try to draw it here. Please teach me how to fill color for it....

What is difference between fillRect(0,0,0,1) and clearRect()

javascript,canvas
Is there any difference between: ctx.fillStyle = "rgba(0, 0, 0, 1)"; ctx.fillRect(0, 0, 100, 100) and ctx.clearRect(0, 0, 100, 100) Any kind of difference in performance or resulting image or canvas data?...

Draw triangle by the intersect of 3 circles

javascript,canvas,draw
I want to draw a triangle base on the intersection points of 3 circles. Is there any function or any method with JavaScript to solve this? Or I need to perform some math calculation to get exact position of the intersection point and draw the triangle myself. function drawMap(){ var...

http://sigmajs.org/ les mis tutorial - why are my canvases 0 height?

javascript,html5,canvas,sigma.js
I'm working through the http://sigmajs.org/ les miserable tutorial. I'm curious, when I run a local server and view my index.html page, why are the canvases generated by sigmas.js 0 height? https://github.com/micahstubbs/les-mis-tut/blob/master/02/index.html...

Canvas fillRect has wrong X coordinate

javascript,jquery,html,canvas
I am attempting to create a javascript function which will color the pixels of a canvas underneath the cursor. When it runs, colored pixels appear on the left edge of the browser, though they are in the correct vertical position. Here are my functions: function writecolor(event) { var canvas =...

Android Bitmap on Canvas from External File

android,canvas,bitmap,drawable
I use the following code to get a bitmap from the resources folder put it into a drawable and paint it to the canvas Drawable f = getResources().getDrawable(R.drawable.harris1); f.setBounds(a,120,a+200,270); f.draw(canvas); I want to be able to get the bitmap from my pictures directory on my device and paint it on...

JavaFX 8 Canvas Fonts always Bold

canvas,fonts,javafx-8
I am using a JavaFX canvas (currently using Java 8u40) to render some graphics and text. I am having a problem getting the fonts to render correctly in the canvas. It appears the font is always being drawn bold. I have an example to show the problem. First of all...

Finding non transparent filled areas in images on javascript canvas

javascript,image,canvas
I've an image with some filled circles, rectangles etc. I want to find x1,x2, y1, y2 areas of filled areas. Javascript Method to detect area of a PNG that is not transparent Accepted answers works fine but i need to find each areas separately. As in the image below, i...

Fabric.js copy paste of selected group

javascript,canvas,fabricjs
Say I have multiple objects selected on a fabric.js canvas and can get this group of objects using getActiveGroup. Can anyone provide an example of how to copy and paste the group into a new group, where: (a) each object in the copied group retains its relative position to the...

How to display button over a Ad Mediator in windows phone 8?

c#,xaml,button,windows-phone-8,canvas
I use in the application Ad Mediator. I need to add a button(see example) I tried to use the Canvas and Canvas.Zindex. But then does not display advertising. Please tell me how to do it....

HTML Canvas Width

javascript,jquery,html,css,canvas
I have a problem with the initial width of the canvas. What I have is a canvas element with a image background that's set to cover and than within the jquery the canvas width is set to the window.InnerWidth, the height is the width / 3. (this is to keep...

HTML, Canvas Path2D alternative.

canvas,drawing,mobile-safari
I draw some graphics on my website using Path2d. Nothing complicated, just two triangles. But MobileSafari fails to create Path2D() object. Is there any workaround for it ? or any library to do that ? Thanks....

Canvas borders c# ( Windows Phone 7)

c#,windows-phone-7,canvas
I am using Storyboard to move my Images in Canvas. I am wondering if there is an option, when Image is moving to bottom and get into bottom border and Image will not move more down but also not stay. The point is how to make that Image will just...

Controlling canvas object with range slider

javascript,canvas,slider
Attempting to place a circular object on a canvas, and alter the position of the object dependent on range slider inputs (x, y). Currently the object is not placed on canvas, rather than the var cx/cy being a number value they are being returned as [object HTMLInputElement]. Why? JS code:...

Creating a click event in Javascript Canvas

javascript,canvas
I'm having trouble creating a click event for my Javascript canvas game. So far I have been following a tutorial, however the way you interact with the game is through mouse hover. I would like to change it so that instead of hovering over objects in the canvas to interact,...

Displaying tooltips on mouse hover on shapes/position(coordinates) on canvas

html5,canvas,tooltip
I'm trying to display a corresponding tooltip when mouse hovers on certain places on canvas. For example, when the mouse position on the canvas is at the coordinate (100,100), display tooltip1. When mouse position's at (200,200), display tooltip2, etc., I've already added event listeners to detect mouse movement and get...

How to map tapped event for a single object in a canvas control in XAML?

c#,xaml,canvas,foreach
I am working on a windows phone RT XAML c# project. I have a canvas filled with several dynamically added balls(ellipse) as ContentControl. I want that, when a ball is tapped, only that particular ball should animate. I have used storyboard animation in the animating function animateBall() and the animation...

Change a straight line into a curved line when length is overtaken

javascript,html,canvas
I want to display several legs into a rectangular form in canvas. Based on an array which groups the miles of my legs, I've made the algo to represent them proportionately on a canvas given. var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); var width = c.width; var somme =...

Create a picture frame type border

html,css,canvas,svg,css-shapes
I am trying to create a page that is contained in what can be visualized as a picture frame type border/frame as shown here: So far I've found three ways to do it none of which truly fit my needs, I need this frame to be responsive so that it...

Saving an html object to firebase

javascript,canvas,ember.js,firebase,emberfire
I'm working in ember.js my project has an image cropping mechanic. This returns to me by default a canvas object and some data necessary to redraw the cropped image. But when I try to save the canvas object to firebase it saves it as something like [htmlObject Canvas] or something...

Javascript Canvas clear/ redraw

javascript,canvas,html5-canvas
I've tried googling the answer to this but i'm just going around in circles.... If I clear the rect (using clearRect) then the image doesn't redraw after. However, if I don't clear the images just stack. What I want it to clear the current image and then draw with new...

How to move a canvas element up and down for a certain amount of time with javascript

javascript,canvas
I'm trying to make 6 guitars strings move when they are clicked on. I tried doing a simple animation by moving the string 2.5 px up and 2.5 px down for 3 seconds. but I don't really know how to do that. This is what I've tried: function onLoad(){ snaren();...

How can I make different shapes of a canvas draggable and particular area of it droppable in the same canvas

javascript,canvas,drag-and-drop
I want to create a Canvas in which there will be two areas (Left and right), Left panel will contain some shapes which will be draggable(static as well) and on the right side I would be able to drop them, but I am facing following problem, I am not able...

Using destination-over to save background and actual sketch

javascript,jquery,canvas,sketchjs
I've read this and a few other questions, and it is clear I need to use destination-over to save the background and the sketch by display the new image over the old one. I'm using Sketch.JS with my code as such: var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); $('#myCanvas').sketch({...

Html5 canvas animation. How to reset rectangle when it hits the end

javascript,html5,canvas
Hey Im experimenting with some html5 animation and so far I have a square that "falls" whenever I press the button. I was wondering how i could have it go back to the top when it hits the bottom and fall again. My current code is: <html> <head> </head> <body>...

How to make multiple balls drop on click?

javascript,canvas,javascript-events,html5-canvas
I have a ball that drops from cursor location, and redrops when the cursor is moved to another location. I am trying get a new ball to drop every time I click the mouse. I tried: canvas.addEventListener('click', function(event) { ball.draw(); }); But it doesn't seem to do anything. Is there...

JavaFX: How to use the GraphicsContext method appendSVGPath(String svgpath)

canvas,svg,javafx,graphicscontext
I'm working on a project that makes use of SVG's. Currently the program has the SVG's stored as SVGPath objects in an FXML file. The file is then loaded into a Group which is then added to the screen. In the FXML file, there are approximately 300 such SVGPaths. Which...

How does the browser process image sources?

javascript,canvas
[UPDATE] I found two links useful to me: http://mrcoles.com/blog/canvas-composite-operations-demo-animation/ http://tutorials.jenkov.com/html5-canvas/composition.html Recently when I learn canvas, I find there is more than one way to specify the image src: You can give a image-URI, like : www.XYZ.com/abc.png You can give a data-URI, like: data:image/svg+xml;base64,'+ hexcode; You can give a data-URI from...

Is it possible to make the lines move diagonally in tkinter?

python,python-3.x,canvas,tkinter
In this program below, i can move the lines left and right, up and down. However is it possible to make the lines move diagonally, e.g. when up arrow and right arrow presses the program makes a diagonal line moving NE from tkinter import * canvas_height = 400 canvas_width =...

After drawing Stroke on Canvas, adding a stroke to another object changes all the strokes

javascript,html5,canvas
Working on a sort of mapping portal. Been using the tutorial: A Gentle Introduction to Making HTML5 Canvas Interactive by @SimonSarris It's been going well, yet I have encountered a Path Stroke issue. I have been trying to find where beginPath() needs to be added to ensure that when I...

HTML5 Canvas Base64 Error [closed]

javascript,html,canvas,base64
Any idea why this code is not working? :\ Demo -> https://jsfiddle.net/vgmFN/89/ <script> var imgObj1 = new Image(); var img = new Image();var a1=0; var can = document.getElementById('canvas1'); var ctx = can.getContext('2d'); imgObj1.onload = function() { ctx.drawImage(imgObj1,1,1);a1 = 1; } imgObj1.src = 'favicon.ico'; if (a1 == 1) { console.log(can.toDataURL()) img.src...

Highchart Polar chart multiple background colors to SVG

javascript,jquery,canvas,svg,highcharts
I'm trying to create a Quinn model with the highchart library. With all the samples from highchart and multiple pane segment colors , I could create something thats semi working. But the problem I'm getting is if I try to write the SVG to a canvas (creating a fixed image),...

JavaScript objects: 'addEventListener is not a function'

javascript,html,object,canvas,mapping
I create an array of JavaScript objects called elements and loop through it in order to draw every one on a canvas as well as hooking up a few event handlers to it. However, I get an error stating that 'Uncaught TypeError: elements[i].addEventListener is not a function' Here is the...

Rotating charts in Chart JS

javascript,canvas,charts,rotation
I have a requirement for a chart that looks as such: I found Chart JS' Polar Area Chart, but it's not rotated as I needed. And since Chart JS doesn't seem to have a rotate property, I tried just rotating the canvas with CSS #myChart { -webkit-transform: rotate(-25.2deg); transform: rotate(-25.2deg);...

How to scale an image down to fit inside a canvas, without distorting the image?

html5,canvas,fabricjs
I have a fabric js canvas that I allow users to add external images to. Often times the user adds images that are too large to fit the canvas and it's a little difficult for them to re-size them correctly. I'd like to automatically scale the larger images down so...

Spawning multiple Balls in array js

javascript,canvas
Have not really used array's before and i think i am making a mistake here This code spawns the first ball with random color/vx etc, but no other ones, I'm not sure which part is incorrect. Error comes up in ball.x += ball.vx in the animFrame() function. Help? var canvas;...

Calculating a concentric arc in canvas

javascript,canvas,bezier,quadratic
I'm trying to calculate a 2 concentric arcs (cubic bezier) from a given arc (quadratic bezier). I figured I could calculate control points for the cubic at 1/3 and 2/3 but it doesn't quite match up. var u = 1 / 3; // fraction of curve where Px1 and Py1...

Redraw text over clearRect HTML5 Canvas

jquery,html5,canvas
I'm trying to draw text (HTML5 canvas) depending on what option is selected in a select element. It works correctly until there's 2 set of text that appears at the same place. It seems like the clearRect function is the issue. The text won't be redrawn over that cleared space....

How to load TIFF image with fabric.js?

javascript,canvas,fabricjs
From what I can tell, fabric.js can only load either JPG or PNG files. It fails when I try to load a TIFF file. Any idea? fabric.Image.fromURL('my_image.tif', function(oImg) { canvas.add(oImg); }); ...

slowly animate a simple line

javascript,animation,canvas
My problem is that the line draw is instantaneous. What I want is it to draw the line very slowly, almost 3-5 seconds before it finishes at dy. For some reason I cannot get the setTimeout() to work. I have tried large and small values. I just have a basic...

Drawing a tournament bracket in android?

android,canvas,layout
I have an app that will take a list of players and set them up so that you can go through and create a bracket dynamically. The number of players will change and the names as well. Instead of showing a whole bracket, my point will be to go in...

Circle div in CSS doesn't show in canvas properly

javascript,css,canvas,html2canvas
I'm using html2canvas 0.5.0 alpha1 and I added some circles to the div that I want to send to the canvas with this CSS: .circle {height: 20px; width: 20px; border-radius: 20px; position: absolute; top: -8px;} http://www.awesomescreenshot.com/image/297705/8c3f811182dc5a909c9c1cbd270dabd2 looks like this on chrome/safari, the circle doesn't render well. Works well on Firefox...

Canvas element does not resize when using ReactJS and PaperJS together

javascript,html,canvas,reactjs,paperjs
I have found that canvas elements correctly resize on window resize when they are inside react components. They also resize correctly when used with PaperJS. However, they do not resize when used with PaperJS and ReactJS together. Is this an incompatibility between PaperJS and ReactJS or am I instantiating PaperJS...

Add metadata (Exif) to base64

javascript,canvas,upload,exif
I'm trying to reduce images in client side before uploading them to preserve users' bandwidth and storage space in server side, while keeping informations about the original shot. Current process flow : fileReader -> canvas (drawImage) -> base64 -> XMLHttpRequest (to get progress) -> php server One drawback of this...

Continuous gradient along a HTML5 canvas path

javascript,html5,canvas
I am trying to draw a continous gradient along a path of points, where each point has a it's own color, using the HTML5 canvas API. See http://bl.ocks.org/rveciana/10743959 for inspiration, where that effect is achieved with D3. There doesn't seem to be a way to add multiple linear gradients for...

Cannot change line width in HTML 5 canvas

javascript,jquery,canvas
I build a very simple app to draw rectangles in an image by clicking an Add button. However, no matter what properties for stroke in canvas I changed, the properties remain the same. In that example, context.lineWidth has been set to 1. But the rectangle, drawn after clicking the Add...

Equivalent of canvas quadraticCurveTo in SVG

javascript,jquery,canvas,svg,bezier-curve
I am working on a plugin to allow "natural looking" signatures to be drawn using mouse or touch. When confirmed by the user, the result will be a stored SVG that can then be displayed in place of the "Click to sign" button. The attached JSFiddle http://jsfiddle.net/TrueBlueAussie/67haj4nt/3/ shows a testbed...

HTML 5 Canvas addHitRegion not working on iOS (undefined is not a function)

javascript,ios,html5,canvas
I'm building out a clickable canvas overlaying an image for my website. On the desktop, everything is working fine. I'm looping through a set of coordinates and drawing various clickable shapes. On iOS, however, my loop draws the first shape and then apparently hits an error on the last line...

Sun Arc Path in Javascript

javascript,math,canvas
So I am trying to draw a sun in a arc path (Pref a circle path) to simulate a sunrise / sunset and I am running into issues. Canvas Width = 800; Canvas Height = 100; if(getTime() - sunTime > 100){ angle++; sunTime = getTime(); } sun.x = 400 *...

Context.Arc not drawing on specified coordinates

javascript,asp.net,html5,canvas
I'm trying to draw a circle when ever the user clicks and moves the mouse inside the canvas. If I use random coordinates on the .arc() draws but if I use the mouse's coordinates it doesn't draw If I try this: JS: <script> var clicked = false; var x =...

Randomly appearing text in html page

javascript,html5,css3,canvas,html5-canvas
I have been putting a lot of effort into researching for a solution, but come up empty. I am trying to make 10 words of different font-sizes slide in from different directions, on a canvas within my document. I have some code (jsFiddle), but haven't managed to get too far...

Text in canvas to show in timed sequences using jQuery?

javascript,jquery,html,css,canvas
Fiddle: https://jsfiddle.net/6e6nwkpv/ I want to make the hidden canvas show, and the footer hidden when I click the button 'No.' But somehow they end up both disappearing. Bonus: how does one make java words on html canvas appear(and disappear) in a time sequence? <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> <body> <div id="canvas"...

Canvas - Rotate line

javascript,html5,canvas
I am new to Canvas and I need to do some things I cannot find answer on google ... Suppose I have a line w/ starting & ending points. I need to rotate this line around the starting point. Here is the jsfiddle : http://jsfiddle.net/0cc6h833/1/ var cd; var ctx2; var...

Draw arc on canvas from two x,y points and a center x,y point

javascript,canvas,html5-canvas,automatic-ref-counting,trigonometry
i'm trying to draw a arc from two points (X, Y cords). But i can't figure out how to do it so that i can specify the start angle and end angle I got the center point(p2), radius = r. the start point(p1) and the end point(p3). like shown below...

Java - Show multiple canvases in container

java,canvas,containers
I am pretty new to Java. I want to show multiple Canvas objects in one Container object. I don't want to use Swing components. Here is my code: //===============================================================================================| package main; //===============================================================================================| import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent;...

How to create infinite raphael canvas

javascript,canvas,raphael
I created a raphael canvas. There are some draggable circle and rectangle on it. A problem is when I dragged the object to the bottom, the object appeared "half circle" or "half rectangle" and the canvas cannot be extended as the drag movement. How can I create the "infinite" canvas...

Aligning StackPanel to top-center in Canvas

c#,wpf,xaml,canvas
I'm trying to create an application which is supposed to measure quick reaction performance of it's user. The application starts up in full-screen mode and resizes it's elements accordingly to the screen resolution. The project was strongly inspired by training_aim_csgo2 map. It's mostly done, but here is the problem: I...

a border where you can not go through (canvas game)

javascript,css,html5,canvas
I have to make a game for school :) I'am a beginner in Javascript (and English) and I have a question about a canvas. I made a spaceship in my canvas, and I can fly around with it with my arrowkeys. The problem is that my spaceship can fly trough...

I want to make a viewport for a canvas game

javascript,html5,canvas,viewport
So I have a game(that is more of a map) that loads a bunch of tiles and places them together. The tiles load just fine, but I'd like to move the viewport. I've looked into this subject, and I have a function that checks the keyboard. If 'd' is being...

Image array won't draw to canvas

javascript,canvas,setinterval
I'm learning JavaScript. It would be great if someone could explain where did I do a mistake. I have an array with picture links and put them into the function, which should draw an image in canvas for every picture with link. function draw(imgs){ var step = 0; // I...

Determine shape drawn on canvas from stored coordinates in an array

javascript,html5,canvas
I have startX,startY,endX,endY mousecoordinates using which I draw 3 shapes(a line,ellipse and a rectangle) on canvas.Now I store these coordinates(startX,startY,endX,endY) in a array(for each shape drawn) and draw it again on cleared canvas.Now,the problem is how do I determine from these coordinates stored in the array wheather the shape previously...

How can I implement a zoom function in a 2D canvas?

javascript,canvas,html5-canvas
I'm trying to create a library for procedural textures in JavaScript and for some reason I can't really wrap my head around why my zooming function wont work. I tried lots of things but I always get funky results instead of what I originally wanted to achieve. Basically, if I...

Snake Game with Mobile Button Controls

javascript,jquery,jquery-mobile,canvas,html5-canvas
In this Snake game, I need the buttons to control the snake just like the arrow keys do. This will allow the game to be played on a mobile device. You can see i have code in there for the buttons, but they are not working properly and not controlling...

Stopping a Canvas Animation setInterval

javascript,ajax,canvas,web-worker
I have the following set up working very nicely... it's just that I can't stop it! POST ANSWER EDIT: The issue was related to my organization of the draw functions, not related to the webWorker or the ajax call The process: 1 User clicks on button which calls a web...

DrawImage is not drawing in a canvas

javascript,html5,canvas,drawimage
Basically what I have been trying to do, is make a loop that will cycle through a tonne(only 36 atm) of tiles, and place them in order. While that part works, it doesn't actually load the images and display the images. Using console.log, I've narrowed the problem down to when...

which is more performant,

javascript,html5,video,canvas
I am developing a page with a full width / full height intro video (100vw / 100vh), looks "full screen" until you scroll down. Currently I am using HTML5 <video> to accomplish this, but I've noticed the page can get a little choppy, particularly while scrolling. The video is about...

Resize function canvas loaded on shrinked browser and expanded

javascript,jquery,html,css,canvas
I'm a javascript beginner but I managed to make a simple function that creates an animated canvas. var w = c.width = window.innerWidth, h = c.height = window.innerHeight, ctx = c.getContext('2d'), spawnProb = 1, numberOfMoves = [8, 16], //[min, max] distance = [50, 200], attenuator = 900, timeBetweenMoves = [6,...

Detect mouse clicks on circles on HTML5 canvas

javascript,html5,canvas,click,mouseevent
I'm new to canvas and I'm trying to listen to mouse clicks on the circles that I previously drew on canvas. I'm trying to change the colour of the circles (maybe to green) when I click on them. var canvas = document.getElementById('myCanvas'); var context = canvas.getContext('2d'); var radius = 15;...

How to get the value for one function to another?

javascript,canvas
I'm learning Javascript, I read about scope and variables but can't get information about how to send variables between the functions. Please can someone to explain how to be with this situation and it would be great to recommend something to read about it. I want to draw a picture...

html5 canvas circle palette

javascript,html5,canvas,color-palette
i have source with circle palette, problem is palette have static size 250px x 250px, i need smaller 200px x 200px. At first sight code looks like messy, but don't need analyze converter functions like: HSB2RGB, RGB2HSB and etc. function HSB2RGB(j, d, c) { var e, g, l, h, k,...

How do I merge two images into one?

javascript,html,canvas,svg,d3.js
What I am doing is converting a chart (HTML for chart legend + SVG for chart body) generated by D3.js into a image, right now I am using both html2canvas and manually convert SVG into image data, the reason is because the html2canvas can only handle the html part and...

Javascript Canvas, can't draw multiple images

javascript,canvas
For a school project, I need to make a kind of "Invader" game. Actually, I got some issue with picture drawing. It works for 1 picture, but not for multiple. Also if I try to draw only rectangles, instead of pictures, it doesn't work. So I guess something is wrong...

How can i make my HTML canvas dots move more naturally?

javascript,html,canvas
Link to my code pen here I would like opinions on how i could make the canvas dots move in a more fluid, liquid like way. I've tried limiting the direction for a certain number of renders (draw()), which has improved it a little! But it still lacks fluidity, coming...

Safari on Mobile blocks window.open [closed]

javascript,jquery,html,css,canvas
I have a mobile page where the user creates there own smartphone backgrounds using textarea. I use html2canvas to translate the textarea into a canvas and windwow.open + canvas.toDataURL to open the PNG in a new tab for the user to save. It works fine with Chrome but as far...

AngularJS - ReferenceError: $ is not defined

javascript,angularjs,canvas,reference
I'm getting the following error when I try to do this var fbcanvas = $('#fbcanvas'); This is the error I got ReferenceError: $ is not defined This is my JS code var feedbackModule = angular.module('feedbackModule', [ 'ui.bootstrap', 'dialogs' ]); feedbackModule.controller('feedbackDialog', function($scope, $rootScope, $timeout, $dialogs) { $scope.confirmed = 'You have yet...

fabric.js resize canvas to fit screen

javascript,android,cordova,canvas,fabricjs
I'm currently developping an application on mobile device (android and iPhone) with ionic and cordova. I would like to edit a picture. I use fabric.js library to do that. Fabric.js converts an image and other items into canvas. Then I add some image on the canvas (stickers) and export it...

Create a cone with shadows

javascript,canvas,html5-canvas
I would like to create a circle with a special shadow effect. Like this one: . It should look like a cone in wood or metal. I tried to do something with the radial gradiant in canvas but i can't creat that special Effekt. I donĀ“t know how to create...

How to alter a degree value into an actual x/y position change?

javascript,canvas,radians
Im drawing a circle on html canvas, the circle is meant to indicate a "ship". I have the current position (x, y) of the "Ship" object and randomly determine a degree (0 to 360) and an amount value. I then want to alter the ship's current position by the degree...

Pass an image to a canvas with dataurl

html5,canvas,data-url
I am trying to make an image being passed to a canvas from a weburl. The code has been taken from this [question][1] which is accepted but for some reason it does not work on me on firefox or chrome. Any ideas? EDIT: Here you are: var myCanvas = document.getElementById('my_canvas_id');...

I'm trying to call a method in a constructer every second for 15 seconds but setInterval doesn't seem to work

javascript,canvas
The code - also available here: var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.fillStyle = "#000000" ; ctx.fillRect(0,0,600,600); ctx.fillStyle ="#ffffff"; var entities = []; var x; var y; function ship(x, y) { entities.push(entities.length-1); this.name = entities.length-1; this.draw = function(){ ctx.fillRect(x,y,30,30); }; this.update = function(){ x+=10; this.draw(); }; } var...

How do I clearRect in my JS canvas?

javascript,html5,canvas,html5-canvas
I may be having a Homer moment here but I am trying to clear the canvas at every iteration to show the square rotating but the clearRect doesn't seem to work. Can anyone see what I am doing wrong? var canvas = document.getElementById('myCanvas'); var ctx = canvas.getContext('2d'); var angle =...

Converting Text view to bitmap returns null

java,android,canvas,bitmap,textview
I am trying to make an image of dynamically added views in my activity. Can you please tell me what I am doing wrong, the bitmap returns null for some reason. Thanks, protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_share); TextView tv = new TextView(this); tv.setText("sadasdsadssad"); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(...

Facebook Canvas login - session not created?

php,facebook,canvas
So I'm re-writing our old Facebook app (from 2011), bring it up to snuff. It's a straight Canvas app - I just want it to run in the iFrame, it doesn't need any special permissions. I am trying to work from the sample in the PHP SDK docs, and I...

Animating the drawing of a line in the canvas with fabric.js

javascript,canvas,fabricjs
I can draw a line in the canvas using: var myLine = new fabric.Polyline([{x:200,y:200},{x:200,y:200}]) var canvas = new fabric.Canvas('c'); canvas.add(myLine); However, I want to animate the drawing. I tried: myLine.animate("points","[{x:200,y:200},{x:10,y:10}]",{onChange: canvas.renderAll.bind(canvas)}) But it's not working, and I couldn't see any way to animate the drawing of the line using fabric.js...

How can I make multiple overlaying canvases go fullscreen together and stay overlayed?

javascript,canvas,html5-canvas,fullscreen
I want to make all overlapped HTML5 canvases full-screen when a button is clicked and I want them to stay overlapped when in full-screen mode. For example I have 3 overlapped canvases. This example came from this site: HTML <section> <div id="canvasesdiv" style="position:relative;width:400px;height:300px"> <canvas id="layer1" style="z-index: 1;position:absolute;left:0px;top:0px;" height="300px" width="400"> This...

rotating a square in javascript

javascript,canvas,rotation,geometry
I am trying to rotate a square about its center in javascript. Although in this case I am using canvas to draw the square, I need to have a functional method of rotating the square for use elsewhere so just rotating the canvas is not acceptable. This is what I...

Canvas image not loading correctly in Firefox unless cached

javascript,canvas
I am using a bitmap font in HTML canvas, however when you first load the page in Firefox (or if cache is disabled, for example in DevTools), the font does not appear. Here is the page: --snip-- First, the font image itself is loaded:. var font = new Image(); font.src...

Why WebGL slower than Canvas?

javascript,html5,canvas,webgl
I am just started to play around with canvas and webgl, read some article, etc.. and as per my knowledge, WebGL should be much more faster than canvas, but in these following tests it is remarkably slower: http://jsperf.com/canvas-drawimage-vs-webgl-drawarrays http://jsperf.com/three-js-canvas-vs-webgl/2 I run them in Chrome and Firefox, in both browser the...

Drawing rectangles on android canvas

android,canvas
I want to draw 5 squares of different side lengths but adjacent to each other. I want to draw the squares like this: http://s30.postimg.org/ajrtfabj5/squares.png Assuming that the biggest square is of side length 5, side length of square smaller than 5 is 3, smaller than 3 is 2 and the...

How do I calculate logrithmic labels for a VU meter scale?

javascript,html5,audio,canvas,html5-canvas
I writing a meter widget using canvas and need to calculate the label values for the scale. No problem except when I'm trying to re-create the scale for a VU meter. I understand it's logrithmic, but the values aren't powers of 10 on that type of meter. The function I...

How to select particular area in canvas? [closed]

javascript,jquery,html5,canvas
I am new to canvas, I have an image myimg.jpg, I have converted this image into canvas and i am trying to apply some pattern image for heel. I am not able to do it. Here is my screenshot: How can I get it done. <div id="myId"> <canvas id="canvaswrapper" width="660"...

HTML5 canvas slow native function getImageData() on Mac OS

javascript,html5,canvas,getimagedata
I have problem with one native HTML5 canvas function getImageData() on Mac OS. I run test for this function in jsperf with a similar power processors and result is: Ubuntu 14.04 - chrome/opera: 300k operations/sec Window 7/8/8.1 - chrome/opera/ie/mozilla: around 250k operations/sec Mac OS - safari/chrome/opera: around 1k operations/sec use...

How to make a Javafx Image Crop App

java,image,canvas,graphics,javafx
I am building an application for my colleagues to crop image. I use FXML with Scene Builder to build the GUI. The user click a button to choose a image from his computer. Then, the image is shown in the GUI. User can zoom and move in the pane. At...

How to calculate X Y coordinates of image when window resize?

javascript,html,canvas
I am writing a code for putting small image on HTML canvas. Also generate click event on that image. Image have height(50), width(50), X-Y coordinates(250, 150) and canvas also have height(480), width(720). So when I click on image then getting alert("You clicked on image"). But generating alert on wrong place...

How to know whether the mousedown event is occured on where we want in canvas?

javascript,canvas,html5-canvas
Here I have a code sample related to moving an element on canvas. To move a circle to an other position on canvas, the below code is checking whether the mousedown event got triggered on the circle element itself or not so that further dragging can be initiated using mousemove....

HTML5: Center text within rectangle

javascript,html5,canvas
I want to show the id of the rectangle in the center of it. Here is my model: var rects = [ [a, 20, w, h, 'Day of the week'], [a, 130, w, h, 'Final'], [a, 240, w, h, 'Direction'], [a, 350, w, h, 'GoSS'], [a, 460, w, h, 'Cyber'],...