Skip to main content

All Questions

Tagged with
1 vote
2 answers
86 views

Initialize a two-dimensional array with the values shown in the table below

Initialize a two-dimensional array with the values shown in the table below 1 0 0 0 1 0 0 0 1 0 0 4 0 0 0 4 0 0 0 4 0 0 9 0 0 0 9 0 0 0 0 0 0 ...
Dennis-The14th-Web's user avatar
1 vote
1 answer
168 views

Javascript matrix check neighbor state to find edges

i am making a virtual Hama beads tool online. (its a kids toy where you put plastic beads on a matrix and iron them to make them stick together and form a solid shape)like this one below (real hama) ...
Alix Turcq's user avatar
0 votes
3 answers
952 views

Get bounding rect from path2D or context2D

I want to calculate the bounding rect of a shape after I scale or rotate it. First of all, I want to get the width and height. const ctx = document.body.appendChild(document.createElement('canvas'...
Meysam Ghorbani's user avatar
0 votes
1 answer
144 views

path2D rotation badworking

I want to rotate objects using path2D but it doesn't rotate to size. While it works fine using ctx.rotate(). const ctx = document.body.appendChild(document.createElement('canvas')).getContext('2d')...
Meysam Ghorbani's user avatar
2 votes
1 answer
152 views

How can I change the size of the canvas gradient? [duplicate]

I want to scale the gradient without changing its container. For example, apply scale or rotate on the created gradient object. const ctx = document.body.appendChild(document.createElement('canvas'...
Meysam Ghorbani's user avatar
0 votes
1 answer
81 views

Gradient notworking after use path2D [duplicate]

I have a shape whose fillStyle is displayed by ctx.createLinearGradient. I used to use ctx.beginPath and ctx.transform, and it worked fine. But I want to do it with path2D, everything works fine but ...
Meysam Ghorbani's user avatar
3 votes
1 answer
106 views

How to create a 2D array in Javascript

I'm trying to create a 2D array with javascript that I can ultimately put inside a nested loop to extract X/Y information. What am I doing wrong here? function createMatrix(){ let colcount = 0; ...
moshacoder's user avatar
0 votes
2 answers
182 views

8x8 div matrix onclick effectivization

I would like to have an 8x8 matrix where I can click on each square and the color will change, for use in a project. I have made a 2d array and the entire 8x8 "board" but now I want to change to ...
Maiki's user avatar
  • 1
0 votes
0 answers
69 views

In SVG is it possible to push/pop matrix transforms?

I am using SVG for an drawing app. I have a background in 3D graphics and one thing I see missing is the ability to push and pop matrix transforms. How is this essential task handled in SVG?
dugla's user avatar
  • 12.9k
0 votes
4 answers
3k views

Shifting rows and columns in 2D arrays - Javascript

I have a situation as such: var array = [ [1,2,3], [4,5,6], [7,8,9] ] And I am trying to create a function that shifts either a row or a column so the result would be: shiftRow(array, 1) [ ...
Cory Grinstead's user avatar
0 votes
0 answers
484 views

Matrix/2D Array Hourglass Array Elements Giving Undefined

Facing an issue with array elements. In the case below, the problem set is as follows: Actually, there are many hourglasses in the array above. An hourglass looks like so: 1 1 1 1 ...
realsimonburns's user avatar
4 votes
1 answer
274 views

Documentation of HTML canvas 2D transformations using SVGMatrix

I'm looking at using an HTML canvas element for a simple game, but have had trouble finding complete documentation of certain features regarding the 2D drawing context. Usually I would look at MDN, ...
Adam Goodwin's user avatar
  • 4,041
1 vote
1 answer
694 views

Moving a sprite in 2D matrix array - JavaScript

I have created a 2D array which contains a 10 x 10 maze. The problem I am having now is how I will move the sprite on the maze jpg (when it's actually working on the table). How would I move the ...
Daisy Ward's user avatar
3 votes
1 answer
984 views

how to rotate a shape using rotation matrix?

i'm trying to rotate a square in canvas by javascript using rotation matrix. here is my code. function square() { this.cord=[[0,0],[-25,25],[25,25],[25,-25],[-25,-25]]; } var a=new ...
user avatar
1 vote
0 answers
414 views

Visibility of Vector3 - 3D to 2D projection

I already asked this question over there: https://github.com/mrdoob/three.js/issues/2070#issuecomment-6372113 But I did not really get it right now. Here is my problem again: i am using this function ...
chsymann's user avatar
  • 1,670