December 24, 2016

Explaining How to Make a simple Game in Canvas Using HTML5 "Math Space"

November 29, 2016

Canvas - HTML5


(Combining Drawing Shape, Line, and Text on Canvas)


Elements HTML5 <canvas> is used to draw graphics, on the fly, via scripting (usually JavaScript).
The <canvas> is only a container for graphics. You must use a script to actually draw the graphics.
Canvas has several methods for drawing lines, boxes, circles, characters and adding images.

Support browser

Google Chrome, Firefox, Internet Explorer, Opera, Safari
Chrome, Firefox, Internet Explorer 9+, Opera and Safari support for the <canvas>.
Note: Internet Explorer 8 is the latest version, not support for <canvas> element.

Make Canvas

Canvas is the square are made using the tag <canvas>, by default canvas is not particularly border and fill it.
example :
<canvas id="myCanvas" width="200" height="100" >

Note: Always specify the id attribute (which will be called in the script), and the width and height attributes to specify the size of the canvas.
Tips: You can have multiple elements <canvas> on the HTML page.
To add a border, use the style attribute:
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;">

Canvas is defined using the <canvas>, which must have a length and width. In addition, to ensure that the browser will display correctly, then the HTML5 doctype must also be included. As a first step, create a .html file with the following contents.

For example, that I made good use.




To do an output, then click

<li><a href="javascript:square()">Square</a></li>
<li><a href="javascript:line()">Line</a></li>
<li><a href="javascript:circle()">Circle</a></li>
<li><a href="javascript:text()">Text</a></li>


The output is

<body >
 <p><b>JavaScript Canvas</b></p>
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;">

</canvas>

<li><a href="javascript:square()">Square</a></li>
<li><a href="javascript:line()">Line</a></li>
<li><a href="javascript:circle()">Circle</a></li>
<li><a href="javascript:text()">Text</a></li>

</body>


function square(){
    var cv1 = document.getElementById('myCanvas');
    var ctx = cv1.getContext('2d');
    ctx.fillStyle="#000000";
    ctx.fillRect(10,10,90,40);
    console.log(ctx);
}



To draw a line, you can use the method moveTo (x, y) to determine the starting point of the depiction, followed by lineTo (x, y) to draw a route. Need both those methods are still not displaying the actual line, but only sketch only. To add a line, the method needs to be called stroke (). Here's an example of drawing a grid on the canvas.

function line(){
    var cv1 = document.getElementById('myCanvas');
    var ctx = cv1.getContext('2d');
    ctx.moveTo(100,50);
    ctx.lineTo(200,100);
    ctx.stroke();
}



function circle(){
    var cv1 = document.getElementById('myCanvas');
    var ctx = cv1.getContext('2d');
    ctx.beginPath();
    ctx.arc(100,50,40,0,2*Math.PI);
    ctx.stroke();
}



function text(){
    var cv1 = document.getElementById('myCanvas');
    var ctx = cv1.getContext('2d');
    ctx.font='20px, arial';
    ctx.fillStyle="#ffffff";
    ctx.fillText('square',20,20);
    ctx.strokeText('circle',50,70);
}


JavaScript Canvas
  • Square
  • Line
  • Circle
  • Text
  • September 14, 2016

    C Loops and Decision Explained with Examples


    C Loops and Decision Explained with Examples


    Hello friends, now I want to share a little bit about what I had learned yesterday about Programming Concepts.



    So, in the matter last week, I discuss the Conversion, Decision, Function, Array, Looping.

    but, here I'll repeat a little discussion about the looping and decision .



    • Looping

    In programming languages, looping is a process that is done repeatedly until the specified limits,

    and there are three ways to do looping in c ++, using

    • For
    • While
    • Do-While

    So friends lets make a simple program uses looping in c ++

    • For



    • While



    • Do-While




    So, the difference between the FOR, WHILE, and DO-WHILE:



    • For:


    To repeat the process a known amount.

    • While:


    To repeat the process as yet unknown amount.
    at the first check will be performed if the condition is true then the loop will continue

    • Do-while:


    To repeat a process that is not yet known amount.
    Instruction is executed first, and then check the condition
    if they are true then the loop will continue


    Explanation

    Repetition will be conducted from 0-10, meaning there 11x repetition.
    Meaning of variable x = 0 is the initial value of x is 0.
    Meaning x <= 10 is the maximum repetition is done is up to 10.
    Meaning x ++ is the added value of each repetition is already in execution,
    Her example if we had put the value at x [0], it will immediately go to x [1]
    and so on up to x [10].


    -------------------------------------------------------------------------------------------

    • Decision

    So friends lets make a simple program uses looping in c ++

    • If-Else





               Explanation


    If - Else = "if true, the commands will be done according to the order, and if it does not qualify to true then the command will be routed using else"



    • Switch-Case



          Explanation


    Decision-making that involves a lot of ways settlement.

    -------------------------------------------------------------------------------------------


    Finished friends, this is a simple program  in c ++, I'm sorry if it is less clear in his explanation because I am still a beginner and learning stage.





    September 08, 2016

    Installing Dev C++ on Windows 8.1

    Installing Dev C++ On Windows 8.1

    Before we begin the explanation about how to install the dev c ++ in Windows 8.1, it is better if we know about the differences between the interpreter / compiler / editor and IDE.

    Interpreter is a translation system source code programmer results that can be understood by computers.
    Compiler is a system that combines all the source code and examine the results programmer that can be understood by computers.
    Editor is an application for writing, editing, assembling a variety of source code programmer.
    IDE (integrated Development Environtment) is a joint program between Editor and Compiler.

    So, editor and compiler is a combination of the IDE, the results of source code written in the editor will need a compiler to check the results of the code to be understood by a computer and printed the results of the program.

    Now we will start to install Dev C ++ on Windows 8.1, before installing course, we must have the application by downloading on google.
    .
    .
    .
    once downloaded then inserted into a folder that is not mixed with other downloadable applications
    :D



    Open the file that has been downloaded by clicking 2 times on the file and wait until 100%.



    so it appears the language selection menu. Select the appropriate installation language and can be understood yes.



    and will perform "License Agreement" read, and then click "I Agree".


    then will perform "choose component", a checklist and then click on "next".



    then select where to save the program, select the appropriate location (and usually in Disk C) and click install.



    If successful, the installation process will take place.



    and wait until the installation is complete.


    and finally!!!! completed application installed.

    .
    .
    .
    After successfully installing the Dev C ++ then we will make a simple program, simply because it is still a beginner. : D

    First of all clicks his Dev C ++ on the desktop or in the start menu to open the application and create a program.



    then select File -> New -> Source File.



    then write the source code.



    After writing the source code, Compile the program by clicking Execute -> compile or click F9, then save with the .cpp, for example task.cpp.









    Run the program by clicking Execute -> Run or click F10



    and input the number and then click enter.












    Yuhuuuuuuuuuuuuuuuuuuuuu !!! congratulation friends managed and successfully create a simple program in C ++.