SlideShare una empresa de Scribd logo
1 de 25
Paper.js
a nice vector graphics library


    江嘉诚
PaperScript
•   <head>
•   <script type="text/javascript" src="js/paper.js">
•   </script>
•   <script type="text/paperscript" canvas=“canvas">
      …………..
•   </script>
•   </head>
•   <body>
•     <canvas id=“canvas" resize></canvas>
•   </body>
基本概念
• Point
• Size
• Rectangle

•   多种构造函数
•   大量的语法糖
•   便捷的数学运算
•   运算符重载
基本概念
• var point = new Point(20, 40);
• console.log(point); // { x: 20, y: 40 }

• var size = new Size();
• console.log(size); // { width: 0, height: 0 }

• var rect = new Rectangle(point, size);
• console.log(rect);
• // { x: 10, y: 20, width: 200, height: 100 }
基本概念
•   var point1 = new Point(10, 20);
•   var point2 = point1 * 4;
•   var point3 = point2 - point1;
•   var point4 = point3 + 30;
•   var point6 = point5 * new Point(3, 2);

• vector.angle += 90;

• Point.random();
Vector
Vector
Path
Path

•   var path = new Path();
•   path.strokeColor = 'black';
•   path.add(new Point(30, 75));
•   path.add(new Point(30, 25));
•   path.add(new Point(80, 25));
•   path.add(new Point(80, 75));
•   path.closed = true;
Path

• path.fullySelected = true;

• var copy = path.clone();
• copy.fullySelected = true;
• copy.position.x += 100;

• copy.smooth();
Path

• var myCircle =
    new Path.Circle(new Point(100, 70), 50);
• myCircle.strokeColor = 'black';
• myCircle.selected = true;
Path
Path

• var myCircle =
    new Path.Circle(new Point(100, 70), 50);
• myCircle.strokeColor = 'black';
• myCircle.selected = true;

• myCircle.removeSegment(0);
Path
Path
Event
• function onMouseDown(event) {
•   // event.point
• }

• function onMouseDrag(event) { }

• function onMouseUp(event) { }

• function onMouseMove(event) { }

• function onFrame(event) {
Event
• tool.minDistance = 10;
• tool.maxDistance = 10;
• tool.fixedDistance = 10;
Event
• event.point
• event.middlePoint
• event.delta
Item

Transform

 Layer
Project

Layer

Group
Bound
Symbol
Raster

• var circle =
      new Path.Circle(new Point(80, 50), 5);
• circle.fillColor = 'red';

• var raster = circle.rasterize();
HitTest

            CompoundPath

PointText

               Style
Paper.js的优点

•   简单而清晰的概念
•   大量的语法糖
•   倡导基于矢量绘图
•   统一使用Path
•   引人入胜的例子
•   Processing的有力竞争者

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

jQuery Foot-Gun Features
jQuery Foot-Gun FeaturesjQuery Foot-Gun Features
jQuery Foot-Gun Features
 
Empowering End-users to Find Point-of-interests with a Public Display
Empowering End-users to Find Point-of-interests with a Public DisplayEmpowering End-users to Find Point-of-interests with a Public Display
Empowering End-users to Find Point-of-interests with a Public Display
 
WebXR if X = how?
WebXR if X = how?WebXR if X = how?
WebXR if X = how?
 
ECMAScript 5: Новое в JavaScript
ECMAScript 5: Новое в JavaScriptECMAScript 5: Новое в JavaScript
ECMAScript 5: Новое в JavaScript
 
Cpp
Cpp Cpp
Cpp
 
Testing Black Box
Testing Black BoxTesting Black Box
Testing Black Box
 
D3.js - A picture is worth a thousand words
D3.js - A picture is worth a thousand wordsD3.js - A picture is worth a thousand words
D3.js - A picture is worth a thousand words
 
C questions
C questionsC questions
C questions
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScripters
 
You will learn RxJS in 2017
You will learn RxJS in 2017You will learn RxJS in 2017
You will learn RxJS in 2017
 
Angular.js + Rails at WeWork or: The Accidental Feature
Angular.js + Rails at WeWork or: The Accidental FeatureAngular.js + Rails at WeWork or: The Accidental Feature
Angular.js + Rails at WeWork or: The Accidental Feature
 
Web Components With Rails
Web Components With RailsWeb Components With Rails
Web Components With Rails
 
Arrays
ArraysArrays
Arrays
 
Dion Almaer & Ben Galbraith - Build Once, Deploy Everywhere
Dion Almaer & Ben Galbraith - Build Once, Deploy EverywhereDion Almaer & Ben Galbraith - Build Once, Deploy Everywhere
Dion Almaer & Ben Galbraith - Build Once, Deploy Everywhere
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
Implementation of c string functions
Implementation of c string functionsImplementation of c string functions
Implementation of c string functions
 
In a galaxy far, far away - A procedural generation tale
In a galaxy far, far away - A procedural generation taleIn a galaxy far, far away - A procedural generation tale
In a galaxy far, far away - A procedural generation tale
 
Couchdb
CouchdbCouchdb
Couchdb
 
Pointer level 2
Pointer   level 2Pointer   level 2
Pointer level 2
 
F(2)
F(2)F(2)
F(2)
 

Similar a Paperjs presentation

IE9에서 HTML5 개발하기
IE9에서 HTML5 개발하기IE9에서 HTML5 개발하기
IE9에서 HTML5 개발하기Reagan Hwang
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring CanvasKevin Hoyt
 
JavaScript - Object-Oriented Programming & Remote Scripting
JavaScript - Object-Oriented Programming & Remote ScriptingJavaScript - Object-Oriented Programming & Remote Scripting
JavaScript - Object-Oriented Programming & Remote ScriptingChen Huang
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1Bitla Software
 
Rapidly Iterating Across Platforms with Server-Driven UI
Rapidly Iterating Across Platforms with Server-Driven UIRapidly Iterating Across Platforms with Server-Driven UI
Rapidly Iterating Across Platforms with Server-Driven UILaura Kelly
 
Computer vision Nebraska (Nebraska Code)
Computer vision Nebraska (Nebraska Code)Computer vision Nebraska (Nebraska Code)
Computer vision Nebraska (Nebraska Code)Andrew Rangel
 
CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)창석 한
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonAlex Payne
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvasGary Yeh
 
Rapidly Iterating Across Platforms using Server-Driven UI
Rapidly Iterating Across Platforms using Server-Driven UIRapidly Iterating Across Platforms using Server-Driven UI
Rapidly Iterating Across Platforms using Server-Driven UILaura Kelly
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-futureyiming he
 
Hive introduction 介绍
Hive  introduction 介绍Hive  introduction 介绍
Hive introduction 介绍ablozhou
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天tblanlan
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changeshayato
 
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventHTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventRobert Nyman
 

Similar a Paperjs presentation (20)

IE9에서 HTML5 개발하기
IE9에서 HTML5 개발하기IE9에서 HTML5 개발하기
IE9에서 HTML5 개발하기
 
Ricky Bobby's World
Ricky Bobby's WorldRicky Bobby's World
Ricky Bobby's World
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
JavaScript - Object-Oriented Programming & Remote Scripting
JavaScript - Object-Oriented Programming & Remote ScriptingJavaScript - Object-Oriented Programming & Remote Scripting
JavaScript - Object-Oriented Programming & Remote Scripting
 
HTML5 Canvas
HTML5 CanvasHTML5 Canvas
HTML5 Canvas
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1
 
Rapidly Iterating Across Platforms with Server-Driven UI
Rapidly Iterating Across Platforms with Server-Driven UIRapidly Iterating Across Platforms with Server-Driven UI
Rapidly Iterating Across Platforms with Server-Driven UI
 
Computer vision Nebraska (Nebraska Code)
Computer vision Nebraska (Nebraska Code)Computer vision Nebraska (Nebraska Code)
Computer vision Nebraska (Nebraska Code)
 
Intro to HTML5
Intro to HTML5Intro to HTML5
Intro to HTML5
 
Canvas
CanvasCanvas
Canvas
 
Canvas
CanvasCanvas
Canvas
 
CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)CSS3 TTA (Transform Transition Animation)
CSS3 TTA (Transform Transition Animation)
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
 
Rapidly Iterating Across Platforms using Server-Driven UI
Rapidly Iterating Across Platforms using Server-Driven UIRapidly Iterating Across Platforms using Server-Driven UI
Rapidly Iterating Across Platforms using Server-Driven UI
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-future
 
Hive introduction 介绍
Hive  introduction 介绍Hive  introduction 介绍
Hive introduction 介绍
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
 
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventHTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
 

Último

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Último (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Paperjs presentation

  • 1. Paper.js a nice vector graphics library 江嘉诚
  • 2. PaperScript • <head> • <script type="text/javascript" src="js/paper.js"> • </script> • <script type="text/paperscript" canvas=“canvas"> ………….. • </script> • </head> • <body> • <canvas id=“canvas" resize></canvas> • </body>
  • 3. 基本概念 • Point • Size • Rectangle • 多种构造函数 • 大量的语法糖 • 便捷的数学运算 • 运算符重载
  • 4. 基本概念 • var point = new Point(20, 40); • console.log(point); // { x: 20, y: 40 } • var size = new Size(); • console.log(size); // { width: 0, height: 0 } • var rect = new Rectangle(point, size); • console.log(rect); • // { x: 10, y: 20, width: 200, height: 100 }
  • 5. 基本概念 • var point1 = new Point(10, 20); • var point2 = point1 * 4; • var point3 = point2 - point1; • var point4 = point3 + 30; • var point6 = point5 * new Point(3, 2); • vector.angle += 90; • Point.random();
  • 9. Path • var path = new Path(); • path.strokeColor = 'black'; • path.add(new Point(30, 75)); • path.add(new Point(30, 25)); • path.add(new Point(80, 25)); • path.add(new Point(80, 75)); • path.closed = true;
  • 10. Path • path.fullySelected = true; • var copy = path.clone(); • copy.fullySelected = true; • copy.position.x += 100; • copy.smooth();
  • 11. Path • var myCircle = new Path.Circle(new Point(100, 70), 50); • myCircle.strokeColor = 'black'; • myCircle.selected = true;
  • 12. Path
  • 13. Path • var myCircle = new Path.Circle(new Point(100, 70), 50); • myCircle.strokeColor = 'black'; • myCircle.selected = true; • myCircle.removeSegment(0);
  • 14. Path
  • 15. Path
  • 16. Event • function onMouseDown(event) { • // event.point • } • function onMouseDrag(event) { } • function onMouseUp(event) { } • function onMouseMove(event) { } • function onFrame(event) {
  • 17. Event • tool.minDistance = 10; • tool.maxDistance = 10; • tool.fixedDistance = 10;
  • 21. Bound
  • 23. Raster • var circle = new Path.Circle(new Point(80, 50), 5); • circle.fillColor = 'red'; • var raster = circle.rasterize();
  • 24. HitTest CompoundPath PointText Style
  • 25. Paper.js的优点 • 简单而清晰的概念 • 大量的语法糖 • 倡导基于矢量绘图 • 统一使用Path • 引人入胜的例子 • Processing的有力竞争者