Questions tagged [canvas]

Canvas is a drawing element introduced to web development with HTML5.

Filter by
Sorted by
Tagged with
1
vote
0answers
95 views

Improving the code, events in individual functions (refactoring)

code It is necessary from this piece of code ...
9
votes
2answers
134 views

Optimize a tile rendering algorithm for Swing Canvas

I have an algorithm that I use to render a text GUI using Swing's Canvas, it looks like this in practice: My goal is to reach 60 frames per second for a full HD ...
1
vote
0answers
24 views

Custom canvas star creator. With code to produce drawing

Simple star designer for HTML canvas. Allows you to change every variable about how to draw the star. This can be used to create squares, triangle, circles, hexagons, etc. But isn't an efficient way ...
3
votes
1answer
90 views

JS + CANVAS Projectile Motion

Basically you've got a canvas, and you can click it to launch a ball in a certain angle and speed, everything is working fine, except for the arrow tip of the vector thing. I can't get it to draw ...
10
votes
1answer
172 views

Battle City (Tank) replica

I'm learning JS and Canvas. A friend of mine gave me the task to create a Battle City replica. I've already managed to make the map and the player to move. Nothing fancy just some squares with a color,...
3
votes
1answer
67 views

Learning javascript by developing a simple game

I am learning javascript and have developed a car game using : HTML Canvas javascript The repository link is : https://github.com/lazycoder-007/car_race_html_javascript_game The code is given ...
2
votes
0answers
103 views

Canvas Drawing / Bucket Filing Kotlin

I have completed a solution for the below problem and uploaded it in Git Repo. I would be grateful if somebody can review in term of code quality, design and Kotlin language usage. Repo You're ...
1
vote
0answers
38 views

Moving square on a canvas

here's my code for moving a square on a canvas. Basicly I'm creating this thinking of some simple simulations or maybe a simple game. Would love some feedback how to optimize the code. ...
2
votes
0answers
36 views

HTML game engine within angular

I currently have a very very basic js script that runs something 30 times per second. This is later to be used in a game engine. But now I'm not quite sure how I can best do that. This little script ...
6
votes
3answers
335 views

Performance in particles.js library

Hey I'm trying to optimise particles.js library from Vincent Garrau in order to get 60fps @ 500 particles ~. I've already refactored the code to use a quad tree instead but it does not seem to be ...
3
votes
1answer
310 views

Chess game in JavaScript

I have created a chess game in JavaScript. Right now you can only play against another human. ...
2
votes
1answer
174 views

d3.js canvas performance

I've just rewritten this code (a simple gravitational restricted n-body simulation) to display using canvas, rather than SVG. The reason being that I'd like to be able to run it with many thousands of ...
2
votes
1answer
321 views

Plotting a parabola using Tkinter

I'm a beginner, and I have just written this basic code that simply plots a parabola in a graph. Is it possible to make my code more efficient? The process works by the creating lists of X and Y then ...
4
votes
2answers
445 views

Edge detection in a canvas

I have one function in my code to detect edges in a canvas but it's the slowest part of my code and is used everywhere. If I could just optimise this, my whole program would speed up considerably. ...
6
votes
2answers
1k views

Improving particle performance in P5.js

I have modified a particle system to create an effect similar to the one that I want. However, with any substantial amount of particles it performs very slowly on my laptop (around 1.7 fps at the ...
2
votes
1answer
52 views

React component to animate planets on a canvas

I wrote some JavaScript to generate some graphics on a canvas, on a regular HTML page. I now want the same code to run in a component that is part of a React app. I've done this: ...
5
votes
1answer
68 views

JS Simple game in canvas

I'm trying to learn javascript (especially the OOP part) and made this simple game. I'm looking for advice and ways to improve my code. Did I handle OOP well enough? What's the best way to create a ...
6
votes
1answer
116 views

Tetris Game Javascript

I am creating Tetris in javascript. I have finished the basic mechanics. I would appreciate some feedback on how I could improve it. Down, left, and right arrow keys move the piece while the up arrow ...
6
votes
1answer
2k views

15 Puzzle Game JavaScript

I have created a program that lets you play the fifteen puzzle game. You have to get the blocks into ascending order by moving them into the one open space. I would like some feedback on the code and ...
1
vote
1answer
72 views

Upload image without src attribute

We gave an option for user to Upload the image Image is uploading fine, but its not adding any img src tag for that uploaded image.... Is this is acceptable to upload image without using any img tag ?...
3
votes
1answer
57 views

Monte Carlo pi animation

I have created a program that calculates pi using a Monte Carlo method. It also animates the process and displays the value as it is updated to show how it gets closer and closer to the actual value ...
2
votes
1answer
109 views

Mandelbrot Set generator

I want to reduce the big time it needed for my mandelbrot set generator to work. I'm working this for already a week. I tried to reduce the canvas size from 400 by 400 to 200 by 200 and the speed ...
3
votes
1answer
32 views

Recamán Sequence Animation

I wrote a program that animates the Recamán sequence. It is in uses HTML canvas and JavaScript. I was hoping for some feedback on how it could be improved. ...
3
votes
2answers
2k views

JavaScript flood fill

I tried to implement a very simple color flood fill to experiment a bit with Javascript. All comments about the code are welcome but I am especially interested in performance as it seems to be a bit ...
2
votes
0answers
197 views

Simple jumping game: continue with jquery or switch to html5 canvas?

I'm coding for fun with the secret ambition of making a fun little game for mobile. So I started out building this little jumping game with Javascript and jQuery. The game relies heavy on css ...
4
votes
1answer
152 views

Sierpinski’s Gasket Triangle in JavaScript

I wrote the Sierpinski’s Gasket Triangle in JavaScript, but I feel the code can be better, especially from L32 to L47. Could you make it more organized? ...
8
votes
2answers
551 views

Two player snake game

I created a 2 player Snake game from my original one player version. I am looking for some feedback on how I made it. I think I could use improvement when handling input (...
1
vote
2answers
107 views

Wireframe animation on canvas is slow

I'm recently working on a project that involves animation in the background. It works well on desktop but performance drops drastically on mobile. I'm using Paper.js to import a svg and animate it. ...
4
votes
1answer
110 views

JavaScript canvas Snake game

This is my 3rd JavaScript canvas game. It's basically just snake right now but I am planning on adding some more aspects to it soon. I was wondering if I could get some feedback especially on how I'm ...
1
vote
2answers
45 views

A function that generates arrays of video thumbnails using canvas

I have just finished my first version of a function that returns an array of video screenshots created with canvas. What I am looking for are ways to improve this speed by as much as possible. I want ...
5
votes
1answer
596 views

Rendering explosion of bouncing balls on a canvas

I'm making a particle engine that can spawn new explosions while keeping particles from previous ones active (until they despawn). The code works well on its own but within the game, two or more ...
0
votes
1answer
562 views

Breaking up a simple Paint application into smaller classes

(Sorry this is a repeat post, I hadn't logged in on my initial question and am unable to respond) I currently have a working code for a simple paint application but it is all in one file and very ...
2
votes
2answers
2k views

Javascript: Canvas drawing - storing mouse coordinates

I have a small JS application that allows a user, after clicking on a canvas, to draw a picture. Once the user clicks the mouse, the user is allowed to drag the mouse wherever they want within the ...
9
votes
1answer
287 views

Sierpinski triangle html canvas Implementation

I wrote my Sierpinski Triangle fractal animation using HTML canvas with JavaScript: JsFiddle What do you think about it? How I can optimize it, if you see a need for that? Code: ...
6
votes
3answers
848 views

My re-written snake game in Javascript

This a snake game I wrote about 1 month ago. It's working well. Looking for any suggestions for my code, I want my coding improved. jsfiddle link http://jsfiddle.net/geswhvdc/ ...
3
votes
0answers
25 views

Loading NRRDs, images and names of parts and segments

I am creating a program to show NRRDs which are a format of medical images. In addition it loads a gallery of thumbnails, where each thumbnail has a link to change the selected NRRD. Plus there is a ...
11
votes
1answer
236 views

Snake on a Plane

My code uses a canvas element to create a live snake game on a plane! ...
2
votes
3answers
641 views

Display Thousands/Millions of different background images

Kindly help me check this code, I want to be able to make it load thousands/millions of different pictures as HTML background without crashing or slowing down the browser. The images can be created ...
6
votes
1answer
86 views

Pong Game in JS

I am new to game development and took on the task to create a Pong replica due to my curiosity and interest in the field. I decided to write it in JavaScript because the game is not too labor ...
0
votes
1answer
337 views

Improving canvas pre-rendering [closed]

I define my canvas as you normally would, but I also include a bunch of different makeshift canvases: ...
2
votes
0answers
203 views

Inventory and stats for a game with Tkinter

It's an inventory UI and also displays the player's stats. I have been programming for a year or more and I want to improve my code. ...
6
votes
1answer
1k views

JavaScript Graphing Calculator

I have a pretty functional JavaScript based graphing calculator. Functions like \$\space tan(x)\$, \$\space\frac{1}{tan(x)}\space\$ and \$\space x^{high\space number}\space\$ look weird, however ...
4
votes
2answers
193 views

Lorentz Attractor visualization using functional programming

I have been working on this Lorenz Attractor visualization for the past day. I am currently also trying to change my coding style into a more functional programming one. I find it quite hard, to be ...
2
votes
0answers
63 views

App showing a welcome page with an animal's picture

I have an app which shows a welcome page with an animal's picture. Also, we can navigate to a second view, where there are two canvas, and a collapsable panel which hosts controls' inputs. The aim of ...
1
vote
1answer
66 views

Display class containing a Canvas in a JFrame

I've been using this class for so long, I never thought about how terribly big and how bad it looks. Looking back on it, this class looks so out-of-date, and nothing explains itself; I want to get it ...
1
vote
1answer
2k views

Read an image file into a canvas and display click coordinates

I am a beginner in JavaScript, which I have started studying since Summer last year. My code's purpose is read a file from file explorer, and put that image in a canvas. Also there is code to allow ...
2
votes
2answers
452 views

Drawing a castle and towers with acm.graphics

The following code is my solution of exercise 10 of chapter 5 of The Art and Science of Java. So here, using acm program and graphics, I need to draw a castle with two side towers and other three ...
7
votes
1answer
121 views

First Javascript program - Snakes game on HTML canvas

I'm relatively new to programming but my most familiar languages are Java, C# and Haskell and this is my first javascript program. All the concepts used in here were just the first thing that came to ...
10
votes
2answers
737 views

Implement a Tetris game in JavaScript using HTML5 Canvas

I just wrote a Tetris game and I'd like to ask experienced people for a code review, especially in terms of code efficiency and bad coding habits, and if the code is easy to reason about. Here is the ...
2
votes
1answer
704 views

A simple JavaScript and HTML5 Canvas drawing component

This is my first time writing a Vanilla JS plugin. I have tried to make a simple HTML5 canvas drawing script. I have tried to handle both touch and mouse events on the canvas. Kindly help me point ...