Skip to main content

Posts

Showing posts from July, 2017

Learning Javascript Part IV

oi Learning Javascript Part IV So t ill now we know what are arrays in javascript . In this pot we are going to talk about Objects. OOP Concepts are really very vast section to explore,So we are just going to have a introduction of them. Objects in JavaScript Objects are just like arrays, but they use strings instead of numbers to access the different elements. These strings used are called keys or properties , and the elements they point to are called values. But unlike the arrays which stores multiple values the objects usually represent single thing's multiple characteristics. Creating Objects in Javascript There are two ways to create objects in javascript.          var myObject = new Object();                      OR            ...

INTRODUCTION TO HTML 5 CANVAS (PART II)

INTRODUCTION TO HTML 5 CANVAS (PART II)  In the last post we saw how canvas tag is used and done some very basic things with it. This time we’ll be doing some more interesting stuff. Last time we drawn a rectangle and a line to our canvas. Having Fun with Loops We can draw multiple object on our canvas at a time. This can be done with help of loops or the setInterval () function. We can change the coordinates of object and redraw it with the new coordinates . Here are some examples, We can also change x and y at the same time  to draw an inclined pattern, Try these out, also try to make different patterns of your own wish. Making Things Move Okay so we can draw things on canvas, but that would be boring if they would just sit there and don’t do anything. To make things move on our canvas we can change the coordinates of them and redraw them with the new coordinates while clearing the canvas with each iteration . Let’s understand it with an ex...

INTRODUCTION TO HTML5 CANVAS

INTRODUCTION TO HTML5 CANVAS   HTML5 Canvas all ows us to draw various shapes and images and much more including animations in a web page that can be manipulated with JavaScript. This is actually a bitmapped area so it is very different from Flash and SVG  i.e. it redraws the whole screen on every frame as per the JavaScript calls.  This gives the programmer a very good low level - control over what’s being displayed. The html 5 API is very easy and fun to learn even for a newbie. The <canvas> tag is used to create a html 5 canvas. This element have an API supporting client side scripts for drawings. This element have properties width and height which can be manipulated(see the screenshot below). Here you can see we gave an id to this element. This id ‘can’ will be going to used in our script. Now let’s add an script tag. If you don’t know JavaScript basics then see my JavaScript tutorials(Don’t worry you still be able understand what’s going ...

Learning Javascript Part III

Learning Javascript Part III Hey guys, welcome to part three of our learning javascript series. I recommend you to go to read Part I and Part II of this series. Last time we learned about variables and operators this time we will learn about Arrays. Arrays in Javascript Earlier we saw how we can store values in variables in javascript so that we can use them later on. But what if we have a lot values say 5000, then creating 5000 variables for these 5000 values will be a ridicules idea. So what's the solution for this problem? Well we can use an Array store these values. So what exactly is an array. Well for all those definition loving guys here's one, "An array is a data structure used for storing a collection of values." And for those who are still confused , An array is a collection of homogeneous data. Its declaration looks like this; The above array is called empty array as there is nothing in it. So how we use arrays. Lets take a ...

Learning Javascript Part II

Learning Javascript Part II Writing computer programs is all about controlling information. Information is called data in programming that we store in our PC programs. For instance, your pet's name is a bit of information, as is its breed and it will be called data. In JavaScript, there are three basic types of data: numbers, strings, and Booleans. Numbers are used for representing integer values like this: 5; Strings are used to represent any kind of text. For example your pet'sname can be represented like this:  "My pet's name is kitty"; I know i am bad at giving examples but hope it gave you a idea about strings. Next is Booleans. Booleans are values that can be true or false like you can assign the value true to sentence  "My pet's name is kitty". There are distinctive approaches to work with every data type. For instance, you can multiple numbers with each other, however you can't do it with two strings  ha...