Back in the day if you wanted to learn something new, you would go to school for it, but today not only are the educational institutions…
seen from China
seen from China

seen from Italy

seen from Italy

seen from Italy

seen from China

seen from United States
seen from Yemen

seen from Indonesia
seen from Thailand
seen from Malaysia

seen from Italy

seen from Germany

seen from Japan
seen from China
seen from United States
seen from China
seen from United States

seen from United States

seen from Malaysia
Back in the day if you wanted to learn something new, you would go to school for it, but today not only are the educational institutions…

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Course Description : - JavaScript is the world's most popular language and is widely used in almost all web projects. JQuery has also become hugely popular within few years of its launch. These two technologies are must for any web developer and in order to help you master them in a practical…
New Post has been published on http://www.attuts.com/get-and-remove-colour-from-the-image-html5/
Get and Remove colour from the image- HTML5
Canvas has opened countless possibilities for Javascript Developers, it boon not only develop cool animation and games stuff but also a variety of way to develop other stuff, which is not possible in image tag. Today we are going to explore, one of the capability of canvas which makes it more robust HTML5 technology. You may have seen some site where you upload a product photo with white background and it turns white into transparent pixel, you see product with transparent pixel and some time you need to show or provide transparent image in “png” format. Yes, you are right, we are going to remove color from the static image.
Before we start, let’s have a look what we are going to build. Try “Edit Me ” button at bottom and switch it into editable mode, click on pixel you want to remove from the image, finish edit button to transfer editable image back to image tag.
This tutorial is comprised following concepts
How to get color from the image on click
How to remove color on basis of RGB Values from the image.
Let’s set up a program where on click of edit button we replace image with canvas and on press of “finish edit” we transfer our canvas output to image and remove canvas.
First set up a structure. In this structure we are going to draw image into canvas HTML5 and transfer canvas data to image.
HTML Code:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>@tuts tutorial</title> </head> <body> <div class="container"> <img src="http://www.attuts.com/wp-content/uploads/2015/01/attus.jpg" alt="source: fashionara.com" width="500" height="494" id="imgEle" /> <div id="tag">Image</div> </div> <div> <button id="btn">Edit Me</button> </div> </body> </html>
Css Code:
#btn { height:40px; color:white; background:green; width:500px; } .container { position:relative; width:500px; height:494px; } #tag { position:absolute; right:0px; top:20px; background:black; color:white; padding:10px; min-width:80px; text-align:center; }
Javascript Code:
var imgObj = document.getElementById('imgEle'); var canvasObj; var toggleButton = false // toggling bottom button action $("#btn").click( function (e) { if (!toggleButton) { toggleButton = true; imgObj = document.getElementById('imgEle'); $(imgObj).remove(); $(".container").append($("<canvas id='canEle' width='500' height='494'></canvas>")); canvasObj = document.getElementById("canEle"); var ctx = canvasObj.getContext("2d"); ctx.drawImage(imgObj, 0, 0); // drawing image into canvas $("#btn").text('finish Editing'); $("#tag").text("Canvas"); } else { toggleButton = false; $(".container").append($('<img width="500" height="494" id="imgEle" />')); document.getElementById("imgEle").src = canvasObj.toDataURL('image/png'); // transfer canvas data to img $(canvasObj).remove(); $("#btn").text('Edit Me'); $("#tag").text("Image"); } });
Full Code:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>attuts.com</title> <script src="http://code.jquery.com/jquery-latest.min.js" ></script> <script> var imgObj; var canvasObj; var toggleButton = false // toggling bottom button action $(document).ready(function(e) { $("#btn").click( function (e) { if (!toggleButton) { toggleButton = true; imgObj = document.getElementById('imgEle'); $(imgObj).remove(); $(".container").append($("<canvas id='canEle' width='500' height='494'></canvas>")); canvasObj = document.getElementById("canEle"); var ctx = canvasObj.getContext("2d"); ctx.drawImage(imgObj, 0, 0); // drawing image into canvas $("#btn").text('finish Editing'); $("#tag").text("Canvas"); } else { toggleButton = false; $(".container").append($('<img width="500" height="494" id="imgEle" />')); document.getElementById("imgEle").src = canvasObj.toDataURL('image/png'); // transfer canvas data to img $(canvasObj).remove(); $("#btn").text('Edit Me'); $("#tag").text("Image"); } }); }); </script> <style> #btn { height:40px; color:white; background:green; width:500px; } .container { position:relative; width:500px; height:494px; } #tag { position:absolute; right:0px; top:20px; background:black; color:white; padding:10px; min-width:80px; text-align:center; } </style> </head> <body> <div class="container"> <img src="http://www.attuts.com/wp-content/uploads/2015/01/attus.jpg" alt="source: fashionara.com" width="500" height="494" id="imgEle" /> <div id="tag">Image</div> </div> <div> <button id="btn">Edit Me</button> </div> </body> </html>
Working Example – Toggle Image to Canvas and Canvas to Image:
Why we need to change image to canvas? So here is the answer. Through canvas method, we convert our image to imageData and from that data we are able to get pixel. Let’s check how to pick color from the canvas data. Now we are only modify our javaScript code.
How to get color from the Image on click?
$(canvasObj).on('click',function(event){ var x = event.pageX - this.offsetLeft; var y = event.pageY - this.offsetTop; var rgbdata = ctx.getImageData(x, y, 1, 1).data; var Rv = rgbdata[0]; var Gv = rgbdata[1]; var Bv = rgbdata[2]; console.log("R Value is "+ Rv + " Green Value is " +Gv+ " Blue value is "+Bv); });
Working Code : Refer to working code for more clarification.
As you see I modified my javaScript, We assigned a click listener to my canvas that draw our image into canvas and covert output into ImageData rectangle form. getImageData() method returns ImageData object which contains pixel information . On canvas click, we are passing four parameters to .getImageData() method, these parameters ensure we get piece of information that we required from the imageData rectangle. Parameters x and y is the point from where we want to get the information while 1,1 is the pixel block from the rectangle. Data property returns RGB color pixel and Alpha value which we are going to use to remove those pixel value from the image.
Now another interesting part comes,
How to remove color on basis of RGB values from the image.
Ok so here is the trick, since we access the image data, we are able to get all pixel length. We loop through all pixels of the imageData and where we get the value of our choice we set the alpha to 0. Once Loops ended we assign back the new formed imageData to canvas.
Note. Each pixel has its own color channel RBG + Alpha channel (transparency) which represent from 0 to 255.
Below is the implementation.
// get the image data object var image = ctx.getImageData(0, 0, 500, 494); // get the image data values var imageData = image.data, length = imageData.length; // Matching Pixel var r=0, g=1, b=2,a=3; for(var i=0; i < length; i+=4){ if ( imageData[i+r] >= Rv && imageData[i+g] >= Gv && imageData[i+b] >= Bv ) // Change Alpha to 0 when pixel match {imageData[i+a] = 0;} } // after the manipulation, reset the data image.data = imageData; // and put the imagedata back to the canvas ctx.putImageData(image, 0, 0);
Above implementation only remove the single matching pixel from the image. If we required to remove large amount of pixel values than we need to add threshold. Following implementation contains threshold, we made some changes in above code.
var threshold = 20 for(var i=0; i < length; i+=4){ if ( imageData[i+r] >= Rv-threshold && imageData[i+r]<Rv+threshold && imageData[i+g] >= Gv-threshold && imageData[i+g]<Gv+threshold && imageData[i+b] >= Bv-threshold && imageData[i+b]< Bv+threshold ) // if white then change alpha to 0 {imageData[i+a] = 0;} }
If in case you missed demo, here is the link http://jsfiddle.net/attuts/dsxLjovx/1/ and below is the complete working demo, experience it.
New Post has been published on http://www.attuts.com/javascript-based-face-detection-method/
Javascript based Face Detection Method
I’ve been always excited to know the concept behind tagging the faces, detection and recognition of faces on webcam and image. Although I know it’s beyond my imagination to get the logic and algorithms required to develop a face recognition software or plug-in. I get inspired to write a tutorial, when I get to know about Javascript libraries that helps in recognizing smile, eyes and face structure. There are many libraries available either purely javascript based or required java language with pro and cons.
Today we are going to explore tracking.js, it is lightweight javascript library developed by Eduardo Lundgren that enables you to do real-time face detection, color tracking and tagging friends. In this tutorial, we are going to see, how we can detect face, eyes and mouth from the static image.
At the end of the tutorial you find a working example of the tutorial with some more trick and tips and more technical details.
First we need to set up our project, download the project from the github and extract the build folder and place according to your file and directory structure. In this tutorial, i have been used the following file and directory structure.
Folder Structure
Project Folder │ │ index.html │ ├───assets │ face.jpg │ └───js │ tracking-min.js │ tracking.js │ └───data eye-min.js eye.js face-min.js face.js mouth-min.js mouth.js
You may see that “js” folder contains Javascript files that we extracted from the build folder of tracking.js. Let me show you the html code of index.html
HTML Code
<!doctype html> <html> <head> <meta charset="utf-8"> <title>@tuts Face Detection Tutorial</title> <script src="js/tracking-min.js"></script> <script src="js/data/face-min.js"></script> <script src="js/data/eye-min.js"></script> <script src="js/data/mouth-min.js"></script> <style> .rect { border: 2px solid #a64ceb; left: -1000px; position: absolute; top: -1000px; } #img { position: absolute; top: 50%; left: 50%; margin: -173px 0 0 -300px; } </style> </head> <body> <div class="imgContainer"> <img id="img" src="assets/face.jpg" /> </div> </body> </html>
In above html code we have included four javascript files of tracking.js that helps us in detecting face, eyes and mouth from the image. Now we write a code to achieve detect faces, eyes and mouth from the static image. I deliberately use this image because it contains multi-faces with different expressions and poses.
To make this work, we are modifying our previous code in head section of html.
HTML Code
<!doctype html> <html> <head> <meta charset="utf-8"> <title>@tuts Face Detection Tutorial</title> <script src="js/tracking-min.js"></script> <script src="js/data/face-min.js"></script> <script src="js/data/eye-min.js"></script> <script src="js/data/mouth-min.js"></script> <style> .rect { border: 2px solid #a64ceb; left: -1000px; position: absolute; top: -1000px; } #img { position: absolute; top: 50%; left: 50%; margin: -173px 0 0 -300px; } </style> // tracking code. <script> window.onload = function() { var img = document.getElementById('img'); var tracker = new tracking.ObjectTracker(['face', 'eye', 'mouth']); // Based on parameter it will return an array. tracker.setStepSize(1.7); tracking.track('#img', tracker); tracker.on('track', function(event) { event.data.forEach(function(rect) { draw(rect.x, rect.y, rect.width, rect.height); }); }); function draw(x, y, w, h) { var rect = document.createElement('div'); document.querySelector('.imgContainer').appendChild(rect); rect.classList.add('rect'); rect.style.width = w + 'px'; rect.style.height = h + 'px'; rect.style.left = (img.offsetLeft + x) + 'px'; rect.style.top = (img.offsetTop + y) + 'px'; }; }; </script> </head> <body> <div class="imgContainer"> <img id="img" src="assets/face.jpg" /> </div> </body> </html>
Result
Code Explanation.
tracking.ObjectTracker() method classified the object you want to track where it accept parameter as an array.
setStepSize() specify the block step size.
We bind our tracking object with “track” event, soon object tracked, tracking object would trigger the track event.
We got Data in Object Array form where values are width, height, x and y coordination of each object (face, mouth and eyes );
Result Conclusion. As you may see that result vary according to shapes, there are improvements required but we admire and really appreciate the efforts in developing such kind of API.
Working Example:
Working Example with Image.
More Resources – Javascript based Face Detection https://github.com/auduno/headtrackr https://github.com/auduno/clmtrackr
We are planning to produce a tutorial based on face tracking and image tagging on HTML5 Canvas and webcam video. You may refer my previous post on webcam accessing on client side, which helps you in knowing way to access user’s webcam.
New Post has been published on @Tuts - Free Tutorial Resource for Javascript, anguarjs, Jquery
New Post has been published on http://www.attuts.com/webcam-and-video-using-html5-send-video-image-to-server/
Webcam and Video Using HTML5 - Send Video Image to Server
For a long time, Developers have been using flash/flex or non html technologies to use webcam. With the growth of HTML5, it’s now easier for Html front end developers to use webcam and video without any plug in or third party resource. This article comprised following topics
Html5 API to access user’s webcam
Take screen-shot of video using canvas
Display into IMG tag
Export or save image via php
I tried to make this tutorial simple that any novice may get it easily. Let me show you how we can access user’s webcam. Let first we setup our HTML structure.
HTML structure.
<video id="videoEle" width="640" height="480" autoplay></video> <button id=”camOnButton” > Turn On my webcam</buton> <button id=”saveImgButton” >Save Image</buton>
For the sake of this tutorial, I am not using any fallback or null check, but as good developer you should take care of these things. Above html structure contains basic html and dimension of 640 X 480.
1. HTML5 API to access user’s webcam
Javascript Structure.
<script type="text/javascript">// <![CDATA[ window.addEventListener("DOMContentLoaded", function() { var vidObj = document.getElementById(“videoEle”); errCallBack = function(error) { // Video Error Handler console.log("Video error: ", error.code); }; //Attach Click event with camOnButton document.getElementById(“camOnButton”).addEventListener(“click”,function(){ // check web camera support on clicking camOnButton if(navigator.getUserMedia) { // Standard navigator.getUserMedia({"video": true }, function(stream) { vidObj.src = stream; vidObj.play(); }, errCallBack); } else if(navigator.webkitGetUserMedia) { // For WebKit navigator.webkitGetUserMedia({ "video": true }, function(stream){ vidObj.src = window.webkitURL.createObjectURL(stream); vidObj.play(); }, errCallBack); } else if(navigator.mozGetUserMedia) { // For Firefox navigator.mozGetUserMedia({ "video": true }, function(stream){ vidObj.src = window.URL.createObjectURL(stream); vidObj.play(); }, errCallBack); } }); }); // ]]></script>
Experience Code : http://jsfiddle.net/attuts/evfn4hb9/ Once user clicks “Turn On My Webcam “ button, Javascript check the browser support for the webcam access API. Once ensure, browser ask for the permission to open the webcam. Video element gets the source from the API. Wow so far so good. Now next step is to take screenshot from the video and show it into canvas. This is pretty much simple. Let’s update the above html and Javascript code a bit for the canvas.
2. Take screenshot of video using canvas
HTML Structure.
<canvas id="canvasEle" width="640" height="480"></canvas>
Javascript Structure.
var canvas = document.getElementById("canvasEle"), ctx = canvas.getContext("2d") document.getElementById(“saveImgButton”).addEventListener(“click”,function(){ ctx.drawImage(vidObj, 0, 0, 640, 480); });
To avoid confusion I update the code with new integration. http://jsfiddle.net/attuts/svcf41o6/2/
Without any use of Javascript library or any plug-in we successfully have taken image from the user’s web camera that is incredible achievement. As we know that canvas has animation and drawing support that help us in exploring more creative things with images. Now our next step is to show that image into html IMG tag.
3. Display into Img tag
HTML structure
<img id="imageEle" alt="" />
Javascript
document.getElementById(“imageEle”).src = canvas.toDataURL('image/jpeg'); // for Png use 'image/png'
Basically canvas element has a method called toDataURL(), that turns canvas element into base64 encode string. Php provide us advancement to save that data or image to server. Through jquery POST or GET method we can send canvas base64 encoded string data to php.
4. Export or save image via php.
Javascript/Jquery
var data = canvas toDataURL(); $.post("savefile.php", { // php file location imageData : data // imageData is the post request variable }, function(data) { window.location = data; });
Php Code
<?php $data = $_POST['imageData'] $result = base64_decode($data); $fp = fopen("savefile.jpg", 'wb'); fwrite($fp, $ result); fclose(); ?>
Eventually, with the use of javascript , html5 API and PHP we able to save image taken from user machine to server. Hope you enjoy and learned from the tutorial.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
New Post has been published on http://www.attuts.com/aw-snap-solution-video-tag-dispose-method/
"Aw, Snap!" Solution | Video Tag Dispose Method
I was developing an idle play module which contained sequential video rotation. So I used video element to show those high resolution mp4 video using mix of javascript and jquery.
So memory management was the big concern since it was desktop application which has to run for longer time in client machine. When it tested using memory profiler, it had been shocking that the size of the video to be stream was getting increase with each subsequent load of new video and it never dropping back to the baseline.
Following is the code used to delete the video from the DOM.
var vdPlayer = $("#container video")[0]; vdPlayer.remove();
After 6 hours of application runs, The “Aw, Snap!” error in Google Chrome appears on current tab where the video was running in sequential order. This because when a page crashes unexpectedly, there are different reasons of a page crash but mine is related to when chrome is out of memory. The most common fix of the problem is to reload the page again.
Here is the solution.
var vdPlayer = $("#container video")[0]; vdPlayer.pause(); vdPlayer.src=””; // passing empty value vdPlayer.load()// loading video with an empty source vdPlayer.remove(); vdPlayerParent.empty(); // Parent of the video element (optional);
Right ways to dispose a video from the DOM, is first clear the source and load the video with an empty source before removing the video from its container. This way we can prevent memory leakage where video discard from the DOM first and then .remove() method removes the element from the DOM. Please note that if your video tag has any event attached, remove that event before providing an empty source. This way you ensure that no reference is attached with the element.
New Post has been published on @Tuts - Free Tutorial Resource for Javascript, anguarjs, Jquery
New Post has been published on http://www.attuts.com/talking-javascript-explore-speech-synthesis-api-js/
Talking Javascript - Explore Speech Synthesis API Js
You can use Web Speech API and speech synthesis Javascript API to add speech to text and text to speech capability respectively to your page. It will help you in building speech recognition utility for web, mobile and desktop. You can achieve this with just a few lines of code. This post contains basic and important features of API. Start with Basics
Initialize the synthesis API with message and call speechSynthesisis.speak method with message. var speakmsg = new SpeechSynthesisUtterance(“Thanks for speaking”); window.speechSynthesis.speak(speakmsg);
However, interestingly you may add more feature or parameter to control and give effect to voice by altering pitch, volume, voice and language. Here is the example: var speakmsg = new SpeechSynthesisUtterance(); var voices = window.speechSynthesis.getVoices(); speakmsg.voice = voices[10]; speakmsg.voiceURI = 'native'; speakmsg.rate = 1; speakmsg.volume = 1; speakmsg.pitch = 2; speakmsg.text = 'Thanks for speaking'; speakmsg.lang = 'en-US';
speakmsg.onend = function(e) { console.log(‘on end function’); };
speechSynthesis.speak(speakmsg);
You may have notice that the second line contains .getVoices() method and third line contains .voicesproperty. getVoices() method give you an array of all available voice in the browser but some voices doesn’t support alteration. We explore more on that .getVoice() method but first check other options too; like .volume which takes 0 as minimum value and 1 as maximum value. Likewise .rate takes 0.1 to 10 values.
Explore Voice.
Through .foreach method in .getVoice(), you may check available voices . Here is the code. var voices = window.speechSynthesis.getVoices().foreach( function(voice,index){ console.log(“voice name : ” + voice.name + “ index is ” + index ); } );
Use different voice
var voices = window.speechSynthesis.getVoices(); speakmsg.voice = voices .filter( function(voice) { return voice.name == ‘Google UK English Male’; })[0];
Fallback Method
Since not all browser support its feature fully, safari for IOS7 support partially, while chrome has fully support. So below is the fallback method. if ('speechSynthesis' in window) { // Run you code, it support speechSynthesis. }
if (‘SpeechRecognition’ in window) { //Run you code. It support Speech Recognition. }
New Post has been published on Toontuts | Toonlite Tutorial Blog | HTML5 Tutorials | Web Designing Tutorials
New Post has been published on http://www.toontuts.com/phonegap-splash-screen-example/
PhoneGap Splash Screen Example
In the Eclipse development environment, developed with phonegap+jquerymobile, how to set up the SplashScreen? Quite simply, in the Java file in the src folder 1.super.setIntegerProperty(“splashscreen”,R.drawable.splashscreen); 2.super.loadUrl(“file:///android_asset/www/index.html”, 5000); Two codes, 5,000 for sustained 5s splash time clock.