Tuesday , 16 July 2019
Home / Programming (page 2)

# Programming

Gradients allow you to create fills with multiple colors. Not only that, it takes care of transitioning from 1 color to the next. There are 2 kinds of gradients which are linear and radial. We’ll learn how to do both in this tutorial. Linear Gradients Clear your script and add this bit of code. [crayon-5d2d14568bc20918189230/] Alright a couple of things …

Shadows are a great way to make your 2D drawings pop out. They’re very easy to set up and you’re given a couple properties to get you started. Clear your script and add this bit of code. [crayon-5d2d14568e6ce155328133/] In the above example we use the 4 main shadow properties and draw a green rectangle onto the canvas. Let’s focus on …

## Drawing Images – Advanced JavaScript Tutorial

If you would like to add your own images into the canvas, then you only have to write a couple lines of code to do so. There are a couple of ways of drawing images onto the canvas, but we’ll be using 1 way which is the image object. Please feel free to download the images I use in this …

## Transformations – Advanced JavaScript Tutorial

Transformations allow you to add cool effects to your drawings. This tutorial will cover that and we’ll fix the problem with fuzzy drawings. Fixing Fuzzy Drawings Previously, we set the width and height of the canvas using CSS. This is the wrong way to do things as it can actually stretch our drawings and make it appear fuzzy and blurry. …

## Text API – Advanced JavaScript Tutorial

In this tutorial, we’ll take a look at how to add text to our canvas. It’s actually quite simple. You’re given many options to set up how the text appears. Let’s update our script to this. [crayon-5d2d145690188945685818/] There are 2 methods to add text to the canvas. They are the fillText() and strokeText() methods. Both of these methods have the …

## Path API – Advanced JavaScript Tutorial

The path API allows you draw custom shapes with paths.  You can create some really complex shapes and drawings with this API as it comes with powerful methods. Lines Clear your script and add this bit of code. [crayon-5d2d145690a2b224829213/] So, we first set up the stroke color and set it’s with to 2 pixels. Now, we can start drawing some …

## Canvas – Advanced JavaScript Tutorial

Since the introduction of HTML5, the <canvas> tag has grown a great amount of popularity. The <canvas> element allows you to draw graphics onto the document with JavaScript. To get started, let’s update our document to this. [crayon-5d2d145691957890224882/] The very first thing we must do is create <canvas> tags. This is where all our graphics will be placed. You MUST …

## Text Fields – Advanced JavaScript Tutorial

In this tutorial, we’ll focus on text fields in our forms. There a couple of events, properties and methods to make working with forms easier. Selecting Text Let’s update our document to this. [crayon-5d2d145692372020173661/] Alright, let’s clear out our script and add this bit of code. [crayon-5d2d145692382531138772/] In our third line, we use a method called select(). This method will …