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


    江嘉诚
基本概念
• 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
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>

Mais conteúdo relacionado

Mais procurados

Processing資料(8) 文字
Processing資料(8) 文字Processing資料(8) 文字
Processing資料(8) 文字reona396
 
Implementation of c string functions
Implementation of c string functionsImplementation of c string functions
Implementation of c string functionsmohamed sikander
 
PROGRAM FOR INSERTION SORTING IN ARRAY
PROGRAM FOR INSERTION SORTING IN ARRAY PROGRAM FOR INSERTION SORTING IN ARRAY
PROGRAM FOR INSERTION SORTING IN ARRAY daemian2
 
Oops in c++
Oops in c++Oops in c++
Oops in c++DravidSh
 
Making Games in JavaScript
Making Games in JavaScriptMaking Games in JavaScript
Making Games in JavaScriptSam Cartwright
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring CanvasKevin Hoyt
 
Ass day2 1_checkerboard...copy in cpp
Ass day2 1_checkerboard...copy in cppAss day2 1_checkerboard...copy in cpp
Ass day2 1_checkerboard...copy in cppRobi Parvez
 
玉転がしゲームで学ぶUnity入門
玉転がしゲームで学ぶUnity入門玉転がしゲームで学ぶUnity入門
玉転がしゲームで学ぶUnity入門nakamura001
 
ORM is an Offensive Anti-Pattern
ORM is an Offensive Anti-PatternORM is an Offensive Anti-Pattern
ORM is an Offensive Anti-PatternYegor Bugayenko
 
Introducing AlloyUI DiagramBuilder
Introducing AlloyUI DiagramBuilderIntroducing AlloyUI DiagramBuilder
Introducing AlloyUI DiagramBuilderEduardo Lundgren
 
YUI3 and AlloyUI Introduction for Pernambuco.JS 2012
YUI3 and AlloyUI Introduction for Pernambuco.JS 2012YUI3 and AlloyUI Introduction for Pernambuco.JS 2012
YUI3 and AlloyUI Introduction for Pernambuco.JS 2012Eduardo Lundgren
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C ProgramsKandarp Tiwari
 

Mais procurados (20)

Processing資料(8) 文字
Processing資料(8) 文字Processing資料(8) 文字
Processing資料(8) 文字
 
Implementation of c string functions
Implementation of c string functionsImplementation of c string functions
Implementation of c string functions
 
Document
DocumentDocument
Document
 
PROGRAM FOR INSERTION SORTING IN ARRAY
PROGRAM FOR INSERTION SORTING IN ARRAY PROGRAM FOR INSERTION SORTING IN ARRAY
PROGRAM FOR INSERTION SORTING IN ARRAY
 
Dvst
DvstDvst
Dvst
 
Oops in c++
Oops in c++Oops in c++
Oops in c++
 
Making Games in JavaScript
Making Games in JavaScriptMaking Games in JavaScript
Making Games in JavaScript
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
Pointer level 2
Pointer   level 2Pointer   level 2
Pointer level 2
 
Oprerator overloading
Oprerator overloadingOprerator overloading
Oprerator overloading
 
Ass day2 1_checkerboard...copy in cpp
Ass day2 1_checkerboard...copy in cppAss day2 1_checkerboard...copy in cpp
Ass day2 1_checkerboard...copy in cpp
 
玉転がしゲームで学ぶUnity入門
玉転がしゲームで学ぶUnity入門玉転がしゲームで学ぶUnity入門
玉転がしゲームで学ぶUnity入門
 
Cpp
Cpp Cpp
Cpp
 
ORM is an Offensive Anti-Pattern
ORM is an Offensive Anti-PatternORM is an Offensive Anti-Pattern
ORM is an Offensive Anti-Pattern
 
Introducing AlloyUI DiagramBuilder
Introducing AlloyUI DiagramBuilderIntroducing AlloyUI DiagramBuilder
Introducing AlloyUI DiagramBuilder
 
YUI3 and AlloyUI Introduction for Pernambuco.JS 2012
YUI3 and AlloyUI Introduction for Pernambuco.JS 2012YUI3 and AlloyUI Introduction for Pernambuco.JS 2012
YUI3 and AlloyUI Introduction for Pernambuco.JS 2012
 
ts
tsts
ts
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
WebXR if X = how?
WebXR if X = how?WebXR if X = how?
WebXR if X = how?
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 

Semelhante a Paperjs presentation

ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changeshayato
 
JavaScript - Object-Oriented Programming & Remote Scripting
JavaScript - Object-Oriented Programming & Remote ScriptingJavaScript - Object-Oriented Programming & Remote Scripting
JavaScript - Object-Oriented Programming & Remote ScriptingChen Huang
 
Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Stephen Chin
 
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽tbosstraining
 
Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montageKris Kowal
 
Rule Your Geometry with the Terraformer Toolkit
Rule Your Geometry with the Terraformer ToolkitRule Your Geometry with the Terraformer Toolkit
Rule Your Geometry with the Terraformer ToolkitAaron Parecki
 
Pointer Events in Canvas
Pointer Events in CanvasPointer Events in Canvas
Pointer Events in Canvasdeanhudson
 
The Ring programming language version 1.6 book - Part 178 of 189
The Ring programming language version 1.6 book - Part 178 of 189The Ring programming language version 1.6 book - Part 178 of 189
The Ring programming language version 1.6 book - Part 178 of 189Mahmoud Samir Fayed
 
Raspberry Pi à la GroovyFX
Raspberry Pi à la GroovyFXRaspberry Pi à la GroovyFX
Raspberry Pi à la GroovyFXStephen Chin
 
Raphael JavaScript Library
Raphael JavaScript LibraryRaphael JavaScript Library
Raphael JavaScript LibraryLearningTech
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196Mahmoud Samir Fayed
 
XNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBufferXNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBufferMohammad Shaker
 
SwiftUI Animation - The basic overview
SwiftUI Animation - The basic overviewSwiftUI Animation - The basic overview
SwiftUI Animation - The basic overviewWannitaTolaema
 
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
 
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
 

Semelhante a Paperjs presentation (20)

ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
 
JavaScript - Object-Oriented Programming & Remote Scripting
JavaScript - Object-Oriented Programming & Remote ScriptingJavaScript - Object-Oriented Programming & Remote Scripting
JavaScript - Object-Oriented Programming & Remote Scripting
 
Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)
 
HTML5 Canvas
HTML5 CanvasHTML5 Canvas
HTML5 Canvas
 
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽
 
Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montage
 
Coding for
Coding for Coding for
Coding for
 
Rule Your Geometry with the Terraformer Toolkit
Rule Your Geometry with the Terraformer ToolkitRule Your Geometry with the Terraformer Toolkit
Rule Your Geometry with the Terraformer Toolkit
 
Pointer Events in Canvas
Pointer Events in CanvasPointer Events in Canvas
Pointer Events in Canvas
 
Real life XNA
Real life XNAReal life XNA
Real life XNA
 
Ricky Bobby's World
Ricky Bobby's WorldRicky Bobby's World
Ricky Bobby's World
 
The Ring programming language version 1.6 book - Part 178 of 189
The Ring programming language version 1.6 book - Part 178 of 189The Ring programming language version 1.6 book - Part 178 of 189
The Ring programming language version 1.6 book - Part 178 of 189
 
Raspberry Pi à la GroovyFX
Raspberry Pi à la GroovyFXRaspberry Pi à la GroovyFX
Raspberry Pi à la GroovyFX
 
Raphael JavaScript Library
Raphael JavaScript LibraryRaphael JavaScript Library
Raphael JavaScript Library
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
 
Css5 canvas
Css5 canvasCss5 canvas
Css5 canvas
 
XNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBufferXNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBuffer
 
SwiftUI Animation - The basic overview
SwiftUI Animation - The basic overviewSwiftUI Animation - The basic overview
SwiftUI Animation - The basic overview
 
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
 
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
 

Último

Codex Singularity: Search for the Prisca Sapientia
Codex Singularity: Search for the Prisca SapientiaCodex Singularity: Search for the Prisca Sapientia
Codex Singularity: Search for the Prisca Sapientiajfrenchau
 
Professional Amil baba, Black magic specialist in Lahore and Kala ilam expert...
Professional Amil baba, Black magic specialist in Lahore and Kala ilam expert...Professional Amil baba, Black magic specialist in Lahore and Kala ilam expert...
Professional Amil baba, Black magic specialist in Lahore and Kala ilam expert...makhmalhalaaay
 
Amil baba in Lahore /Amil baba in Karachi /Amil baba in Pakistan
Amil baba in Lahore /Amil baba in Karachi /Amil baba in PakistanAmil baba in Lahore /Amil baba in Karachi /Amil baba in Pakistan
Amil baba in Lahore /Amil baba in Karachi /Amil baba in PakistanAmil Baba Mangal Maseeh
 
A Spiritual Guide To Truth v10.pdf xxxxxxx
A Spiritual Guide To Truth v10.pdf xxxxxxxA Spiritual Guide To Truth v10.pdf xxxxxxx
A Spiritual Guide To Truth v10.pdf xxxxxxxssuser83613b
 
Hire Best Next Js Developer For Your Project
Hire Best Next Js Developer For Your ProjectHire Best Next Js Developer For Your Project
Hire Best Next Js Developer For Your ProjectCyanic lab
 
Peaceful Meditation | Peaceful Way by Kabastro
Peaceful Meditation | Peaceful Way by KabastroPeaceful Meditation | Peaceful Way by Kabastro
Peaceful Meditation | Peaceful Way by KabastroKabastro
 
Genesis 1:10 || Meditate the Scripture daily verse by verse
Genesis 1:10  ||  Meditate the Scripture daily verse by verseGenesis 1:10  ||  Meditate the Scripture daily verse by verse
Genesis 1:10 || Meditate the Scripture daily verse by versemaricelcanoynuay
 
Emails, Facebook, WhatsApp and the Dhamma (English and Chinese).pdf
Emails, Facebook, WhatsApp and the Dhamma  (English and Chinese).pdfEmails, Facebook, WhatsApp and the Dhamma  (English and Chinese).pdf
Emails, Facebook, WhatsApp and the Dhamma (English and Chinese).pdfOH TEIK BIN
 
St John's Church Parish Diary for May 2024
St John's Church Parish Diary for May 2024St John's Church Parish Diary for May 2024
St John's Church Parish Diary for May 2024Chris Lyne
 
The_Chronological_Life_of_Christ_Part_99_Words_and_Works
The_Chronological_Life_of_Christ_Part_99_Words_and_WorksThe_Chronological_Life_of_Christ_Part_99_Words_and_Works
The_Chronological_Life_of_Christ_Part_99_Words_and_WorksNetwork Bible Fellowship
 
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verifiedConnaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
 
Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...
Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...
Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...baharayali
 
NoHo First Good News online newsletter May 2024
NoHo First Good News online newsletter May 2024NoHo First Good News online newsletter May 2024
NoHo First Good News online newsletter May 2024NoHo FUMC
 
Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...
Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...
Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...baharayali
 
Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...
Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...
Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...Amil Baba Naveed Bangali
 
Flores de Mayo-history and origin we need to understand
Flores de Mayo-history and origin we need to understandFlores de Mayo-history and origin we need to understand
Flores de Mayo-history and origin we need to understandvillamilcecil909
 
Genesis 1:5 - Meditate the Scripture Daily bit by bit
Genesis 1:5 - Meditate the Scripture Daily bit by bitGenesis 1:5 - Meditate the Scripture Daily bit by bit
Genesis 1:5 - Meditate the Scripture Daily bit by bitmaricelcanoynuay
 
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxxFrom The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxxssuser83613b
 

Último (20)

Codex Singularity: Search for the Prisca Sapientia
Codex Singularity: Search for the Prisca SapientiaCodex Singularity: Search for the Prisca Sapientia
Codex Singularity: Search for the Prisca Sapientia
 
Professional Amil baba, Black magic specialist in Lahore and Kala ilam expert...
Professional Amil baba, Black magic specialist in Lahore and Kala ilam expert...Professional Amil baba, Black magic specialist in Lahore and Kala ilam expert...
Professional Amil baba, Black magic specialist in Lahore and Kala ilam expert...
 
Amil baba in Lahore /Amil baba in Karachi /Amil baba in Pakistan
Amil baba in Lahore /Amil baba in Karachi /Amil baba in PakistanAmil baba in Lahore /Amil baba in Karachi /Amil baba in Pakistan
Amil baba in Lahore /Amil baba in Karachi /Amil baba in Pakistan
 
A Spiritual Guide To Truth v10.pdf xxxxxxx
A Spiritual Guide To Truth v10.pdf xxxxxxxA Spiritual Guide To Truth v10.pdf xxxxxxx
A Spiritual Guide To Truth v10.pdf xxxxxxx
 
Hire Best Next Js Developer For Your Project
Hire Best Next Js Developer For Your ProjectHire Best Next Js Developer For Your Project
Hire Best Next Js Developer For Your Project
 
Peaceful Meditation | Peaceful Way by Kabastro
Peaceful Meditation | Peaceful Way by KabastroPeaceful Meditation | Peaceful Way by Kabastro
Peaceful Meditation | Peaceful Way by Kabastro
 
Genesis 1:10 || Meditate the Scripture daily verse by verse
Genesis 1:10  ||  Meditate the Scripture daily verse by verseGenesis 1:10  ||  Meditate the Scripture daily verse by verse
Genesis 1:10 || Meditate the Scripture daily verse by verse
 
Emails, Facebook, WhatsApp and the Dhamma (English and Chinese).pdf
Emails, Facebook, WhatsApp and the Dhamma  (English and Chinese).pdfEmails, Facebook, WhatsApp and the Dhamma  (English and Chinese).pdf
Emails, Facebook, WhatsApp and the Dhamma (English and Chinese).pdf
 
St John's Church Parish Diary for May 2024
St John's Church Parish Diary for May 2024St John's Church Parish Diary for May 2024
St John's Church Parish Diary for May 2024
 
The_Chronological_Life_of_Christ_Part_99_Words_and_Works
The_Chronological_Life_of_Christ_Part_99_Words_and_WorksThe_Chronological_Life_of_Christ_Part_99_Words_and_Works
The_Chronological_Life_of_Christ_Part_99_Words_and_Works
 
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verifiedConnaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
 
Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...
Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...
Famous Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in ka...
 
Zulu - The Epistle of Ignatius to Polycarp.pdf
Zulu - The Epistle of Ignatius to Polycarp.pdfZulu - The Epistle of Ignatius to Polycarp.pdf
Zulu - The Epistle of Ignatius to Polycarp.pdf
 
Famous No -1 amil baba in Hyderabad ! Best No _ Astrologer in Pakistan, UK, A...
Famous No -1 amil baba in Hyderabad ! Best No _ Astrologer in Pakistan, UK, A...Famous No -1 amil baba in Hyderabad ! Best No _ Astrologer in Pakistan, UK, A...
Famous No -1 amil baba in Hyderabad ! Best No _ Astrologer in Pakistan, UK, A...
 
NoHo First Good News online newsletter May 2024
NoHo First Good News online newsletter May 2024NoHo First Good News online newsletter May 2024
NoHo First Good News online newsletter May 2024
 
Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...
Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...
Real Kala Jadu, Black magic specialist in Lahore and Kala ilam expert in kara...
 
Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...
Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...
Best Astrologer Vashikaran Specialist in Germany and France Black Magic Exper...
 
Flores de Mayo-history and origin we need to understand
Flores de Mayo-history and origin we need to understandFlores de Mayo-history and origin we need to understand
Flores de Mayo-history and origin we need to understand
 
Genesis 1:5 - Meditate the Scripture Daily bit by bit
Genesis 1:5 - Meditate the Scripture Daily bit by bitGenesis 1:5 - Meditate the Scripture Daily bit by bit
Genesis 1:5 - Meditate the Scripture Daily bit by bit
 
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxxFrom The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
From The Heart v8.pdf xxxxxxxxxxxxxxxxxxx
 

Paperjs presentation

  • 1.
  • 2. Paper.js a nice vector graphics library 江嘉诚
  • 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. 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>