All Questions
2,686 questions
0
votes
0
answers
42
views
How can I record both the screen and webcam using Canvas at 1080p and 30fps?
I tried this and it worked, but the video starts lagging after 30 seconds. No matter what I do, the video records smoothly for 30 seconds and then starts lagging. Am I missing something?
I'm not using ...
2
votes
1
answer
53
views
Zooming on Canvas doesn’t work when resizing the canvas and updating scrollbars positions
I’m trying to implement zoom functionality on a canvas element where:
The zoom should be centered on the mouse cursor.
The canvas should scale properly.
The scrollbars should update to reflect the ...
0
votes
1
answer
48
views
(Un)zooming a canvas is not precise
When I zoom a canvas, usually multiple times, then unzoom the same number of times, the canvas doesn't unzoom the same. Below are the results of 1 zoom in and 1 out. You see the image never goes back ...
0
votes
0
answers
25
views
How to fill a color in hand drawn shape or closed path in rough js?
I am using RoughJs ( docs ) for my whiteboard app. I have done programming the work of tools like - pencil button, undo button, redo button, clear canvas button, color picker, But struggling to ...
0
votes
0
answers
29
views
change zindex and opacity of objects on canvas
I've made a canvas where objects are created randomly along the x axis of the top of the canvas, and each object has is randomised between 3 different sizes to render.
Depending on the size the object ...
0
votes
0
answers
95
views
How to smooth out the line animation in an HTML5 canvas? [duplicate]
community!
I am working on a project using HTML5 Canvas and JavaScript/jQuery, where I have multiple animated routes between points on a grid. The animation should smoothly draw lines from point A to ...
0
votes
0
answers
89
views
SignaturePad in React: Signature appears magnified and cropped when switching to mobile simulation mode
Question:
I'm using the signature_pad library in a React JS application to capture user signatures. The signature pad works fine in desktop mode and on actual mobile devices or initial component mount ...
0
votes
1
answer
87
views
Getting rasterized text in html canvas
I have main canvas on which I draw another canvas which had a text written on it. When I saw the results, it appears that the text is rasterized and not smooth.
Here is the code I tried :-
const ...
0
votes
0
answers
30
views
Server reconciliation issue with mousemove system
Context
I’m having trouble figuring out exactly how to implement server reconciliation in my game, which uses JavaScript, Node.js, and WebSockets. I’m creating an Agar.io-type game where the player is ...
0
votes
2
answers
54
views
Is .strokeStyle of the canvas API a method which makes itself global?
I am curious on the curious behaviour of js, in particular with this method .strokeStyle which usually is used to change the color of a stroke on a HTML canvas. It seems to me quite peculiar, for ...
0
votes
0
answers
23
views
putImageData data doesn't adhere Clipping rule [duplicate]
I am trying to create a Circular QR code using Canvas API.
Here is the link to my codepen 👇
https://codepen.io/owner-photorush/pen/BagdWNm
So my logic is pretty much straight forward.
I take size ...
2
votes
3
answers
99
views
html canvas draw straight line
I want to use MS paint style line tool to draw straight line using UI on html canvas element using JS.
The issue is that line preview must be visible on canvas as mouse is being dragged after click at ...
1
vote
1
answer
69
views
Why does canvas.toDataURL() and canvas.toBlob() produce corrupt images on Firefox?
On Chrome and Safari, I am not having problem generating a snapshot image of a video. However, I've been for hours trying several different things on Firefox, but the image always comes corrupted, ...
0
votes
1
answer
62
views
Too much shadow when drawing on canvas in loop
I have been trying to make a shadow effect in canvas by first creating a rounded rectangle and adding a shadow to it, everything seems to be working fine if I do this once without a loop. However when ...
1
vote
1
answer
92
views
Draw dashed border/outline around nontransparent part of image on canvas
I'm drawing an image onto a canvas and trying to apply red dashed outline of approximately 2px but end up with solid red outline. The source image is a .png image with top and bottom texts as part of ...
0
votes
1
answer
50
views
how do you rotate specific image layers on a canvas?
I have a canvas that draws a background image and then draws several layers:
context.drawImage(background, 0, 0, width, height);
layers.forEach((layer) => {
context.drawImage(layer, 0, 0, width, ...
0
votes
1
answer
73
views
Wrong mouse position when drawing over a resized canvas
I am building a web app for my ML model in which i need to mark the area with the mouse pointer where there is occlusion in the image. The ML model then takes the marked image and reconstructs the ...
0
votes
2
answers
48
views
Trouble making a transparent radial gradient (JavaScript/HTML)
CONTEXT:
I am trying to make a light source using ray casting, that the player can use in a randomly generated maze. The rays cast from the mouse pointer. The radial gradient that I'm using changes ...
0
votes
3
answers
68
views
Transparent canvas with putImageData
I'm trying to render some flames however I cannot achieve a transparent canvas with putImageData(), resulting in a black canvas but well-drawn flames.
I tried "globalcompositeoperation" &...
3
votes
2
answers
454
views
Update canvas on mouse move
The basic idea comes from the map of a game. According to the my code review, the map is a full-page canvas. I have no problem with drawing images on canvas. My question is how to detect map houses ...
1
vote
1
answer
51
views
How to fill all the empty space in a canvas in javascript ? (recursive function)
I try to create a recursive function to fill all the empty space of a canvas until the edges or when there is already an other color filled.
function createFillingPoint() {
let x = points[0][0],
...
0
votes
1
answer
39
views
Issue with Plotting a Reciprocal Function on HTML5 Canvas
I'm currently developing a function plotting application using HTML Canvas and JavaScript. The application is designed to plot various mathematical functions entered by the user. It handles linear ...
0
votes
3
answers
176
views
html5 canvas spin wheel not stopping at winning color
i am trying to create a spinning wheel using canvas and html5. its working but my end goal is to try to point the arrow to the exact winning color. so for example if the winning color is the green one,...
1
vote
1
answer
72
views
How to Draw a Transparent Image Over the Rest of a Canvas
Edit: I found the answer here: How can I use `putImageData` with transparency?
In this code snippet, I have simplified a version of my problem
What I want:
I have a game (represented by the green ...
1
vote
1
answer
76
views
How to plot functions with asymptotic behavior like tan(x), ln(x), and log(x) in JavaScript?
I'm working on a project where I need to plot graphs of mathematical functions in JavaScript, specifically functions that exhibit asymptotic behavior or approach infinity at certain points, such as ...
0
votes
1
answer
41
views
Draw Lines on HTML Canvas Underlying Web Content
I'm working on a project to draw lines on an HTML canvas beneath webpage's content. My goal is to achieve a result similar to the screenshot attached. Here's what I've done so far:
let container = ...
0
votes
0
answers
32
views
Where is the bug in this Canvas implementation of Conway's Game of Life? [duplicate]
'use strict'
const canvas = document.querySelector('canvas')
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'black'
const RESOLUTION = 10
const RATE = 1000
function addCell([x, y]){
...
0
votes
0
answers
39
views
HTML Canvas Translate + Rotate problems?
I wrote a function that draws and rotates a rectangle in place:
let centerX = myCanvas.width / 2;
let centerY = myCanvas.height / 2;
function drawRectangle() {
angle += 10;
...
-1
votes
2
answers
63
views
set different color on click function in Canvas
I want to change color our button are Press then canvas inside text color change.
var canvas = document.querySelector('#my-canvas');
var context = canvas.getContext('2d');
context.font = '48px ...
0
votes
1
answer
437
views
Discussing potentially better alternatives to CSS blur filter or Context2D blur filter [closed]
I'd like to learn about potential better alternatives to CSS Blur filter and Context2D.filter.
I'm not looking for a definitive perfect method that could be applied to any case, but just potential ...
2
votes
1
answer
115
views
How do I use the Canvas to draw a smaller, but same shape inside another whilst maintaining a constant border thickness?
I want to to take any shape, create a smaller version of it, and then use a negative mask to create a new shape that is like an outline of the first object, but with a constant thickness border. To my ...
1
vote
0
answers
54
views
HTML5 Canvas connecting two drawn images via a line
I'm trying to come up with a proof-of-concept on how to use canvas to create different length items (in this case a bike stem).
My idea is to provide 2 svgs (fragments) of the bike stem, then use a ...
0
votes
0
answers
85
views
HTML Canvas not accepting bold font on mobile
I have a simple HTML5 canvas on the page
<canvas class="wapf-canvas"></canvas>
Whenever I set the font to bold, it works on desktop but not on mobile:
var ctx = document....
3
votes
2
answers
192
views
Obtaining the coordinate of a null value when using spanGaps with ChartJS?
I'm wondering if ChartJS exposes an API for plugins that allows us to obtain the coordinate of a null point that has been "Spanned" by ChartJS?
For example as illustrated in this question ...
0
votes
1
answer
90
views
How to make slices clickable and also to rotate text nicely
I'm creating a wheel of fortune. When a user starts, it rotates, and when it stops, a modal of won slice pops up. All is working well, but now I want to add that when the wheel is not rotating if the ...
0
votes
0
answers
51
views
how to reset the image bounding box after clipping the image in fabric js v 5.3.0
I am using Fabric JS 5.3.0
and after I clip an image the bounding box (width/height) image is still the original and not equal to the clipped image
What i have tried
i tried setting the image width ...
0
votes
0
answers
54
views
Canvas: fillRect x-coordinate jitter when drawn quickly
I am creating a waterfall-style spectrogram that moves vertically as live radio data is received. I am attempting to migrate to a more efficient method of drawing the color graph; by collecting ...
0
votes
0
answers
111
views
Memory leak with web worker + canvas
I am attempting to migrate some of the drawing logic for a waterfall spectrum graph to a web worker because it was causing jitter with other, less graphics-intense graphs on the page. In the new model,...
0
votes
0
answers
31
views
What to use in place of datasetStrokeWidth for the lastest chart.js?
This demo is attempting to convert this demo to the latest version of chart.js.
What should we use in place of datasetStrokeWidth? It controls the width of the line.
options: {
responsive: true,...
1
vote
1
answer
96
views
Implementing a gradient background in in the latest chart.js?
This question has an implementation and I'm trying to transfer it to this demo using the latest version of chart.js, however the gradient settings are not taking effect.
Any ideas?
This is the entire ...
3
votes
1
answer
371
views
Calculating point coordinates on a line in chartjs?
In this draggable ChartJS demo is it possible to derive a set of interpolated coordinates along one of the curves that ChartJS plots?
var options = {
type: 'line',
data: {
...
0
votes
0
answers
69
views
How to set scale of zoomed parent image to child image in case of overlap in paperjs
I facing the issue of fit the overlap the child image in parent zoomed image area. There is one parent layer of raster image . I am loading first parent image then zoom in specific area and capture ...
0
votes
0
answers
168
views
Detect pen pointerType and pen buttons (compatibility browser and OS)
I want to build a simple website that detects a pen (stylus) so that the user can handwrite on a canvas (see the code snippet below). I also want to detect the buttons that are pressed on the stylus ...
1
vote
2
answers
164
views
Draw a vertical arrow using canvas 2d
I am trying to draw a vertical arrow using canvas and javascript. i am able to draw one with arrow head upwards but finding difficulty in placing arrow head at the bottom.
The code i am trying
<!...
1
vote
1
answer
405
views
Fabric.js image manipulation using control handler, when an image is cropped and scaled, then next crop operation doesn't applied to previous state
In the given fabricjs code, I am developing a cropping and scaling function using image control handler. When image is scaled for first time and then cropped, in this case it is working fine. Then ...
4
votes
1
answer
122
views
Why must I add velocity to object.position.y + object.height?
There nothing wrong with my code really. I was watching a tutorial to help me learn to make games in canvas.
I’ve understood every single bit of it, but the one thing I don’t understand is why must I ...
2
votes
2
answers
208
views
Why is my JS-program behaving differently with/without a 'problem line'?
The problem line is in the handleLineEnd function.
I ripped off all the lines not necessary to show the problem.
Without the line: I can draw multiple rectangles on the ctx.
With the line: Each ...
0
votes
0
answers
70
views
Why does an arrow disappear at some angles in HTML Canvas when I use lineJoin = "round"?
I am facing a weird bug in HTML Canvas. I want to draw an arrow but it disappears when I add ctx.lineJoin = "round" for some coordinates. Here is the MCVE:
const canvas = document....
0
votes
1
answer
64
views
center image in canvas html
I'm trying to center an svg image in canvas, however the image goes to the right bottom corner, I couldn't understand what I'm doing wrong.
notice: the image is an svg image, I tried a png image it ...
-2
votes
1
answer
68
views
How to get an specific image on the canvas with a certain x,y position? [closed]
I wanted to get an image on the canvas on a certain x,y position and change it to a random position in a certain amount of time. I have the image URl.
I tried using drawImage function but I got into ...