Quantcast
Channel: Code Theory
Browsing all 229 articles
Browse latest View live

Image Zoom Magnifying Glass Effect with CSS3 and jQuery

Ever wanted to add a magnifying glass effect to your product images for an awesome zoom-in and a great user experience ? You’ll be surprised to know that using CSS3 and jQuery, it’s really easy to...

View Article


HTML5 Canvas Particles Fountain Explosion with Gravity

One of my previous posts talked about implementing gravity in our canvas experiments. Eventually, we made a realistic bouncing ball. We’ll kind of extend that experiment to make a quick fountain...

View Article


Basics of Implementing Gravity with HTML5 Canvas

When creating some canvas experiments like a particle emission system or a game, gravity can be a key feature to implement. Figuring out how to implement gravity on an object in terms of coding can be...

View Article

Controlling the Frame Rate with requestAnimationFrame

Limiting the frame rate while using requestAnimationFrame can be a common want especially when coding Games where you want your animations and mechanics to not exceed a particular mark of frames per...

View Article

HTML5 Canvas and Friction

So you started moving an object on your canvas by manipulating vx and vy, i.e., velocity on the x and y axis. But then, you just realized that in real world scenarios the speed of an object reduces...

View Article


Optimizing HTML5 Canvas to Improve your Game Performance

So I coded a game this month for the github game compo called “Pappu Pakia“. This is my first HTML5 Game with beautiful graphics by Kushagra. When I was finished with the coding part, it was pretty...

View Article

Different Tools for Our Sketching Application

It is important for our painting application to have different tools like: Line tool to draw straight lines. Rectangle tool to draw rectangles. Circle tool to draw circles. Eraser tool for erasing...

View Article

Moving/Scrolling/Sliding Background in HTML5 Canvas

Sometimes your game or canvas experiment might have one or more layers of animating backgrounds that are set in motion for the player’s movement or some other reason (like creating a parallax effect?)....

View Article


Rendering Animations with Moving Objects on Canvas

Moving objects on HTML5 Canvas is really easy. I should have written on this topic before writing on gravity but it’s never too late! Let’s get started with the basics. Canvas Coordinate System I’ll...

View Article


Canvas Text Gradients for Backgrounds and Strokes

Text gradients are super easy to achieve with HTML5 Canvas. Process Here’s the process: Step 1 Create your CanvasGradient object with createLinearGradient. Step 2 Add your Gradient Color Stops. Step 3...

View Article

Canvas Rotating and Scaling Images Around a Particular Point

Transforming objects in your HTML5 Game or Experiment requires a bit of understanding regarding how they work. The behaviour and end result is not as intuitive as CSS3 transform functions like rotate()...

View Article

Fixing Node Mysql “Error: Cannot enqueue Handshake after invoking quit.”

TL;DR You need to establish a new connection by calling the createConnection method after every disconnection. I was using the popular Mysql module for Node.js which is node-mysql and everytime, after...

View Article

Parsing CSS In Javascript

Recently I have been working on a project where a user can change some values inside a UI widget via form elements like input fields, range, etc. that would in turn change CSS code inside a CodeMirror...

View Article


Time Based Animations in HTML5 Games: Why and How to Implement them

So you got into Web Based Animations or Games (using that HTML5 thingie) and chances are high that you’re relying on setInterval, setTimeout or even better – requestAnimationFrame to reflow and repaint...

View Article

Remote Mobile Web Application Debugging with Weinre

Weinre (WEb INspector REmote) – pronounced as ‘winery’ – is an excellent tool that reuses the code from the webkit web inspector to allow remote webpage debugging (basically what firebug or chrome dev...

View Article


Scaling Your HTML5 Canvas to Fit Different ViewPorts (or Resolutions)

I am going to share a neat little trick that was learnt while working on an HTML5 game recently. The game is pretty much like our HTML5 Doodle Jump. We had to make sure that the game scales down very...

View Article

Games Physics: Basics and Implementation of Predictive (or Continuous)...

Few days ago, I wrote a post about why time based animations are better than frame based animations. However, in animations done as a function of time, some serious problems could arise. One of them is...

View Article


Using CoffeeScript over JavaScript in your Node.js Application or Module

If you’ve wanted to code your next Node.js app in CoffeeScript then it ain’t that hard. Since coffeescript is just a little language that compiles down to javascript it is pretty much compatible with...

View Article

JavaScript Control Input Field Caret Position or Move to End in Textboxes and...

Long title, but then I felt like specifying parts of what I’ll be covering in this post. Anyway, so I’ll start by a not-so-common issue that some of us have encountered, which is, how to move the input...

View Article

MongoDB Pretty Print Result Objects in Mongo Interactive Shell

This is just a mongodb quick tip in regards to printing the result sets with proper formatting in the mongo interactive shell. Usually when you select documents in a collection using find() in the...

View Article
Browsing all 229 articles
Browse latest View live