SlideShare a Scribd company logo
1 of 15
Engine
Animation
Animation Engine


  Nguyên lý hoạt động

  Cách thứ mở rộng
Simple move
var ele = document.getElementById(“simple”)
var i = 0;
var timer = setInterval(function(){
 ++ i;
 if (i < 1000) ele.style.left = i + “px”;
  else clearTimeout(timer);
}, 10);
Nguyên lý
    1



Vị trí




    0       Thời gian   1
Nguyên lý
   1



Vị trí




    0      Thời gian   1
Chia trác.

function _split(source, target, divide, unit, func) {
      var x, delta, range = [];
      delta = target - source;
      for (var i = 0; i <= divide; ++i) {
             x = i/divide;
             range.push((source + func(x)*delta).toFixed(2) + unit);
      }
      return range;
}
Nguyên lý
         function _split(source, target, divide, unit, func) {
               var x, delta, range = [];
               delta = target - source;
               for (var i = 0; i <= divide; ++i) {
                      x = i/divide;
                      range.push((source + func(x)*delta).toFixed(2) +
unit);
              }                          target
              return range;
         }




                                         source                      t
Demo


     _split(0, 500, 20, “px”, function(x) {return x;});


  Kết quả:

   ["0.00px", "50.00px", "100.00px", "150.00px", "200.00px", "250.00px",
"300.00px", "350.00px", "400.00px", "450.00px", "500.00px", "550.00px",
"600.00px", "650.00px", "700.00px", "750.00px", "800.00px", "850.00px",
"900.00px", "950.00px", "1000.00px"]
Mở rộng


Albus.transition = {
            0: function(x) {
                  return x;
            },
            1: function(x) {
                  return x*(2 - x);
            },
            2: function(x) {
                  return Math.pow(x, 2);
            }
}
Đồ thị các hàm.

   Fx = (1 – cos(x*pi))/2
   JavaScript function:
function(x) {
return (0.5 – 0.5*Math.cos(x * Math.PI));
}
Đồ thị các hàm.
                4

    Fx = x

    JavaScript function:
function(x) {
return Math.pow(x, 4);
}
Đồ thị các hàm.
                1/4

    Fx = x

    JavaScript function:
function(x) {
return Math.pow(x, 1/4);
}
Đồ thị các hàm.




bnouce                Cos(10*x*Pi)
Tham khảo


    Demo:
http://vnjs.net/www/demo/albus/kick.html


    Tham khảo:
http://cross-browser.com/x/examples/animation_tech.php
http://scripty2.com/doc/scripty2%20fx/s2/fx/transitions.htm

More Related Content

What's hot

Lap trinh huong_doi_tuong_cpp_dhct_lesson08
Lap trinh huong_doi_tuong_cpp_dhct_lesson08Lap trinh huong_doi_tuong_cpp_dhct_lesson08
Lap trinh huong_doi_tuong_cpp_dhct_lesson08xcode_esvn
 
giao trinh c++ Chuong1
giao trinh c++ Chuong1giao trinh c++ Chuong1
giao trinh c++ Chuong1Bễ Nguyễn
 
Sfd2012Hanoi - Hà Thụy Long - Odho: Mã nguồn mở và các bài toán vật lý
Sfd2012Hanoi - Hà Thụy Long - Odho: Mã nguồn mở và các bài toán vật lýSfd2012Hanoi - Hà Thụy Long - Odho: Mã nguồn mở và các bài toán vật lý
Sfd2012Hanoi - Hà Thụy Long - Odho: Mã nguồn mở và các bài toán vật lýVu Hung Nguyen
 
Slide Python Bai 2 pythonvietnam.info
Slide Python Bai 2   pythonvietnam.infoSlide Python Bai 2   pythonvietnam.info
Slide Python Bai 2 pythonvietnam.infoKhánh Nguyễn
 
Lap trinh c++ có lời giải 3
Lap trinh c++ có lời giải 3Lap trinh c++ có lời giải 3
Lap trinh c++ có lời giải 3Minh Ngoc Tran
 
Cpl test1%20key
Cpl test1%20keyCpl test1%20key
Cpl test1%20keyHồ Lợi
 
Xử lý ảnh
Xử lý ảnhXử lý ảnh
Xử lý ảnhjvinhit
 
Stl vector nguyen_trihai_11520094_khmt06
Stl vector nguyen_trihai_11520094_khmt06Stl vector nguyen_trihai_11520094_khmt06
Stl vector nguyen_trihai_11520094_khmt06Quach Long
 

What's hot (18)

Tn ktlt
Tn ktltTn ktlt
Tn ktlt
 
Lap trinh huong_doi_tuong_cpp_dhct_lesson08
Lap trinh huong_doi_tuong_cpp_dhct_lesson08Lap trinh huong_doi_tuong_cpp_dhct_lesson08
Lap trinh huong_doi_tuong_cpp_dhct_lesson08
 
Lesson08
Lesson08Lesson08
Lesson08
 
Pointer
PointerPointer
Pointer
 
giao trinh c++ Chuong1
giao trinh c++ Chuong1giao trinh c++ Chuong1
giao trinh c++ Chuong1
 
Sfd2012Hanoi - Hà Thụy Long - Odho: Mã nguồn mở và các bài toán vật lý
Sfd2012Hanoi - Hà Thụy Long - Odho: Mã nguồn mở và các bài toán vật lýSfd2012Hanoi - Hà Thụy Long - Odho: Mã nguồn mở và các bài toán vật lý
Sfd2012Hanoi - Hà Thụy Long - Odho: Mã nguồn mở và các bài toán vật lý
 
Tut6
Tut6Tut6
Tut6
 
Lab4
Lab4Lab4
Lab4
 
Chuong1 c
Chuong1 c Chuong1 c
Chuong1 c
 
Slide Python Bai 2 pythonvietnam.info
Slide Python Bai 2   pythonvietnam.infoSlide Python Bai 2   pythonvietnam.info
Slide Python Bai 2 pythonvietnam.info
 
Neural Network from Scratch
Neural Network from ScratchNeural Network from Scratch
Neural Network from Scratch
 
Chuong 3 mang
Chuong 3 mangChuong 3 mang
Chuong 3 mang
 
Lap trinh c++ có lời giải 3
Lap trinh c++ có lời giải 3Lap trinh c++ có lời giải 3
Lap trinh c++ có lời giải 3
 
Cpl test1%20key
Cpl test1%20keyCpl test1%20key
Cpl test1%20key
 
C đến C++ phần 1
C đến C++ phần 1C đến C++ phần 1
C đến C++ phần 1
 
Xử lý ảnh
Xử lý ảnhXử lý ảnh
Xử lý ảnh
 
Xu ly anh 2014_b3 CTU
Xu ly anh 2014_b3 CTUXu ly anh 2014_b3 CTU
Xu ly anh 2014_b3 CTU
 
Stl vector nguyen_trihai_11520094_khmt06
Stl vector nguyen_trihai_11520094_khmt06Stl vector nguyen_trihai_11520094_khmt06
Stl vector nguyen_trihai_11520094_khmt06
 

Viewers also liked

html5 css3 the future of web technology
html5 css3 the future of web technologyhtml5 css3 the future of web technology
html5 css3 the future of web technologyhazzaz
 
02 phan-thai-trung-drupal
02 phan-thai-trung-drupal02 phan-thai-trung-drupal
02 phan-thai-trung-drupalhazzaz
 
PolCorridor User Forum, Prague, 25 September 2003
PolCorridor User Forum, Prague, 25 September 2003PolCorridor User Forum, Prague, 25 September 2003
PolCorridor User Forum, Prague, 25 September 2003Antonio Bove
 
Suy ngam
Suy ngamSuy ngam
Suy ngamhazzaz
 
Delivering on the broadband promise: technology trends and institutional land...
Delivering on the broadband promise: technology trends and institutional land...Delivering on the broadband promise: technology trends and institutional land...
Delivering on the broadband promise: technology trends and institutional land...Antonio Bove
 
Creating a new landscape for satellite broadband over Europe and beyond
Creating a new landscape for satellite broadband over Europe and beyondCreating a new landscape for satellite broadband over Europe and beyond
Creating a new landscape for satellite broadband over Europe and beyondAntonio Bove
 
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-servicenguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-servicehazzaz
 

Viewers also liked (7)

html5 css3 the future of web technology
html5 css3 the future of web technologyhtml5 css3 the future of web technology
html5 css3 the future of web technology
 
02 phan-thai-trung-drupal
02 phan-thai-trung-drupal02 phan-thai-trung-drupal
02 phan-thai-trung-drupal
 
PolCorridor User Forum, Prague, 25 September 2003
PolCorridor User Forum, Prague, 25 September 2003PolCorridor User Forum, Prague, 25 September 2003
PolCorridor User Forum, Prague, 25 September 2003
 
Suy ngam
Suy ngamSuy ngam
Suy ngam
 
Delivering on the broadband promise: technology trends and institutional land...
Delivering on the broadband promise: technology trends and institutional land...Delivering on the broadband promise: technology trends and institutional land...
Delivering on the broadband promise: technology trends and institutional land...
 
Creating a new landscape for satellite broadband over Europe and beyond
Creating a new landscape for satellite broadband over Europe and beyondCreating a new landscape for satellite broadband over Europe and beyond
Creating a new landscape for satellite broadband over Europe and beyond
 
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-servicenguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
 

Similar to Albus

Lap trinh huong_doi_tuong_cpp_dhct_lesson07
Lap trinh huong_doi_tuong_cpp_dhct_lesson07Lap trinh huong_doi_tuong_cpp_dhct_lesson07
Lap trinh huong_doi_tuong_cpp_dhct_lesson07xcode_esvn
 
C8 object-oriented thinking
C8 object-oriented thinkingC8 object-oriented thinking
C8 object-oriented thinkingHồ Lợi
 
Speaker dang minh tuan javascript for php developer
Speaker dang minh tuan   javascript for php developerSpeaker dang minh tuan   javascript for php developer
Speaker dang minh tuan javascript for php developerAiTi Education
 
Javascript for php developer
Javascript for php developerJavascript for php developer
Javascript for php developerDang Tuan
 
Thuchanh Ktdk-matlab
Thuchanh Ktdk-matlabThuchanh Ktdk-matlab
Thuchanh Ktdk-matlabmark
 
Bài 2: Biến và toán tử - Giáo trình FPT
Bài 2: Biến và toán tử - Giáo trình FPTBài 2: Biến và toán tử - Giáo trình FPT
Bài 2: Biến và toán tử - Giáo trình FPTMasterCode.vn
 
Bài tập CTDL và GT 8
Bài tập CTDL và GT 8Bài tập CTDL và GT 8
Bài tập CTDL và GT 8Hồ Lợi
 
C7 class relationship
C7 class relationshipC7 class relationship
C7 class relationshipHồ Lợi
 
Bài 3: Cấu trúc điều khiển, hàm và xử lý sự kiện - Giáo trình FPT
Bài 3: Cấu trúc điều khiển, hàm và xử lý sự kiện - Giáo trình FPTBài 3: Cấu trúc điều khiển, hàm và xử lý sự kiện - Giáo trình FPT
Bài 3: Cấu trúc điều khiển, hàm và xử lý sự kiện - Giáo trình FPTMasterCode.vn
 
C10 generic algorithms
C10 generic algorithmsC10 generic algorithms
C10 generic algorithmsHồ Lợi
 
Session 4
Session 4Session 4
Session 4pnanhvn
 
Lec3. Ham.pdf
Lec3. Ham.pdfLec3. Ham.pdf
Lec3. Ham.pdfKinHongnh
 

Similar to Albus (20)

Lap trinh huong_doi_tuong_cpp_dhct_lesson07
Lap trinh huong_doi_tuong_cpp_dhct_lesson07Lap trinh huong_doi_tuong_cpp_dhct_lesson07
Lap trinh huong_doi_tuong_cpp_dhct_lesson07
 
C8 object-oriented thinking
C8 object-oriented thinkingC8 object-oriented thinking
C8 object-oriented thinking
 
C8 object-oriented thinking
C8 object-oriented thinkingC8 object-oriented thinking
C8 object-oriented thinking
 
Speaker dang minh tuan javascript for php developer
Speaker dang minh tuan   javascript for php developerSpeaker dang minh tuan   javascript for php developer
Speaker dang minh tuan javascript for php developer
 
Javascript for php developer
Javascript for php developerJavascript for php developer
Javascript for php developer
 
Thuchanh Ktdk-matlab
Thuchanh Ktdk-matlabThuchanh Ktdk-matlab
Thuchanh Ktdk-matlab
 
Bài 2: Biến và toán tử - Giáo trình FPT
Bài 2: Biến và toán tử - Giáo trình FPTBài 2: Biến và toán tử - Giáo trình FPT
Bài 2: Biến và toán tử - Giáo trình FPT
 
Bài tập CTDL và GT 8
Bài tập CTDL và GT 8Bài tập CTDL và GT 8
Bài tập CTDL và GT 8
 
C7 class relationship
C7 class relationshipC7 class relationship
C7 class relationship
 
C7 class relationship
C7 class relationshipC7 class relationship
C7 class relationship
 
Bài 3: Cấu trúc điều khiển, hàm và xử lý sự kiện - Giáo trình FPT
Bài 3: Cấu trúc điều khiển, hàm và xử lý sự kiện - Giáo trình FPTBài 3: Cấu trúc điều khiển, hàm và xử lý sự kiện - Giáo trình FPT
Bài 3: Cấu trúc điều khiển, hàm và xử lý sự kiện - Giáo trình FPT
 
Php day4
Php day4Php day4
Php day4
 
C10 generic algorithms
C10 generic algorithmsC10 generic algorithms
C10 generic algorithms
 
C10 generic algorithms
C10 generic algorithmsC10 generic algorithms
C10 generic algorithms
 
344444
344444344444
344444
 
Session 4
Session 4Session 4
Session 4
 
LINQ
LINQLINQ
LINQ
 
Chuong4 (2)
Chuong4 (2)Chuong4 (2)
Chuong4 (2)
 
Bai tap java
Bai tap javaBai tap java
Bai tap java
 
Lec3. Ham.pdf
Lec3. Ham.pdfLec3. Ham.pdf
Lec3. Ham.pdf
 

More from hazzaz

Coffee1
Coffee1Coffee1
Coffee1hazzaz
 
Tu dong dat hang tu he thong ban le lon nhat trung quoc
Tu dong dat hang tu he thong ban le lon nhat trung quocTu dong dat hang tu he thong ban le lon nhat trung quoc
Tu dong dat hang tu he thong ban le lon nhat trung quochazzaz
 
how startups can benefit from launch community
how startups can benefit from launch communityhow startups can benefit from launch community
how startups can benefit from launch communityhazzaz
 
social network game
social network gamesocial network game
social network gamehazzaz
 
trung oss magento overview
trung oss magento overviewtrung oss magento overview
trung oss magento overviewhazzaz
 
su dung drupal xay dung mang xa hoi
su dung drupal xay dung mang xa hoisu dung drupal xay dung mang xa hoi
su dung drupal xay dung mang xa hoihazzaz
 
java script unit testing framework
java script unit testing frameworkjava script unit testing framework
java script unit testing frameworkhazzaz
 
build your own php extension
build your own php extensionbuild your own php extension
build your own php extensionhazzaz
 
kiem tien online
kiem tien onlinekiem tien online
kiem tien onlinehazzaz
 
web optimization
web optimizationweb optimization
web optimizationhazzaz
 
speed up ntvv2 by php ext module
speed up ntvv2 by php ext modulespeed up ntvv2 by php ext module
speed up ntvv2 by php ext modulehazzaz
 
zingmepracticeforbuildingscalablewebsitewithphp
zingmepracticeforbuildingscalablewebsitewithphpzingmepracticeforbuildingscalablewebsitewithphp
zingmepracticeforbuildingscalablewebsitewithphphazzaz
 
mysql optimization
mysql optimizationmysql optimization
mysql optimizationhazzaz
 
EAV in Magento
EAV in MagentoEAV in Magento
EAV in Magentohazzaz
 
css_trends
css_trendscss_trends
css_trendshazzaz
 
Phan mem tu do nguon mo
Phan mem tu do nguon moPhan mem tu do nguon mo
Phan mem tu do nguon mohazzaz
 
Howtobuildyourownframework
HowtobuildyourownframeworkHowtobuildyourownframework
Howtobuildyourownframeworkhazzaz
 

More from hazzaz (20)

Coffee1
Coffee1Coffee1
Coffee1
 
Tu dong dat hang tu he thong ban le lon nhat trung quoc
Tu dong dat hang tu he thong ban le lon nhat trung quocTu dong dat hang tu he thong ban le lon nhat trung quoc
Tu dong dat hang tu he thong ban le lon nhat trung quoc
 
how startups can benefit from launch community
how startups can benefit from launch communityhow startups can benefit from launch community
how startups can benefit from launch community
 
social network game
social network gamesocial network game
social network game
 
trung oss magento overview
trung oss magento overviewtrung oss magento overview
trung oss magento overview
 
su dung drupal xay dung mang xa hoi
su dung drupal xay dung mang xa hoisu dung drupal xay dung mang xa hoi
su dung drupal xay dung mang xa hoi
 
java script unit testing framework
java script unit testing frameworkjava script unit testing framework
java script unit testing framework
 
build your own php extension
build your own php extensionbuild your own php extension
build your own php extension
 
kiem tien online
kiem tien onlinekiem tien online
kiem tien online
 
web optimization
web optimizationweb optimization
web optimization
 
speed up ntvv2 by php ext module
speed up ntvv2 by php ext modulespeed up ntvv2 by php ext module
speed up ntvv2 by php ext module
 
zingmepracticeforbuildingscalablewebsitewithphp
zingmepracticeforbuildingscalablewebsitewithphpzingmepracticeforbuildingscalablewebsitewithphp
zingmepracticeforbuildingscalablewebsitewithphp
 
mysql optimization
mysql optimizationmysql optimization
mysql optimization
 
EAV in Magento
EAV in MagentoEAV in Magento
EAV in Magento
 
css_trends
css_trendscss_trends
css_trends
 
Cloud
CloudCloud
Cloud
 
Phan mem tu do nguon mo
Phan mem tu do nguon moPhan mem tu do nguon mo
Phan mem tu do nguon mo
 
Zing
ZingZing
Zing
 
redis
redisredis
redis
 
Howtobuildyourownframework
HowtobuildyourownframeworkHowtobuildyourownframework
Howtobuildyourownframework
 

Albus

  • 3. Animation Engine  Nguyên lý hoạt động  Cách thứ mở rộng
  • 4. Simple move var ele = document.getElementById(“simple”) var i = 0; var timer = setInterval(function(){ ++ i; if (i < 1000) ele.style.left = i + “px”; else clearTimeout(timer); }, 10);
  • 5. Nguyên lý 1 Vị trí 0 Thời gian 1
  • 6. Nguyên lý 1 Vị trí 0 Thời gian 1
  • 7. Chia trác. function _split(source, target, divide, unit, func) { var x, delta, range = []; delta = target - source; for (var i = 0; i <= divide; ++i) { x = i/divide; range.push((source + func(x)*delta).toFixed(2) + unit); } return range; }
  • 8. Nguyên lý function _split(source, target, divide, unit, func) { var x, delta, range = []; delta = target - source; for (var i = 0; i <= divide; ++i) { x = i/divide; range.push((source + func(x)*delta).toFixed(2) + unit); } target return range; } source t
  • 9. Demo _split(0, 500, 20, “px”, function(x) {return x;}); Kết quả: ["0.00px", "50.00px", "100.00px", "150.00px", "200.00px", "250.00px", "300.00px", "350.00px", "400.00px", "450.00px", "500.00px", "550.00px", "600.00px", "650.00px", "700.00px", "750.00px", "800.00px", "850.00px", "900.00px", "950.00px", "1000.00px"]
  • 10. Mở rộng Albus.transition = { 0: function(x) { return x; }, 1: function(x) { return x*(2 - x); }, 2: function(x) { return Math.pow(x, 2); } }
  • 11. Đồ thị các hàm.  Fx = (1 – cos(x*pi))/2  JavaScript function: function(x) { return (0.5 – 0.5*Math.cos(x * Math.PI)); }
  • 12. Đồ thị các hàm. 4  Fx = x  JavaScript function: function(x) { return Math.pow(x, 4); }
  • 13. Đồ thị các hàm. 1/4  Fx = x  JavaScript function: function(x) { return Math.pow(x, 1/4); }
  • 14. Đồ thị các hàm. bnouce Cos(10*x*Pi)
  • 15. Tham khảo  Demo: http://vnjs.net/www/demo/albus/kick.html  Tham khảo: http://cross-browser.com/x/examples/animation_tech.php http://scripty2.com/doc/scripty2%20fx/s2/fx/transitions.htm