SlideShare a Scribd company logo
1 of 8
Basics of using the drawing API
• The drawing API is the name for the functionality built into ActionScript that allows you to create vector
graphics—lines, curves, shapes, fills, and gradients—and display them on the screen using ActionScript.
• The following reference list contains important terms that you will encounter in this chapter:
– Anchor point: One of the two end points of a quadratic Bézier curve.
– Control point: The point that defines the direction and amount of curve of a quadratic Bézier
curve. The curved line never reaches the control point; however, the line curves as though being
drawn toward the control point.
– Coordinate space: The graph of coordinates contained in a display object, on which its child
elements are positioned.
– Fill: The solid inner portion of a shape that has a line filled in with color, or all of a shape that has no
outline.
– Gradient: A color that consists of a gradual transition from one color to one or more other colors
(as opposed to a solid color).
– Point: A single location in a coordinate space. In the 2-d coordinate system used in ActionScript, a
point is defined by its location along the x axis and the y axis (the point’s coordinates).
– Quadratic Bézier curve: A type of curve defined by a particular mathematical formula. In this type
of curve, the shape of the curve is calculated based on the positions of the anchor points (the end
points of the curve) and a control point that defines the amount and direction of the curve.
– Scale: The size of an object relative to its original size. When used as a verb, to scale an object
means to change its size by stretching or shrinking the object.
– Stroke: The outline portion of a shape that has a line filled in with color, or the lines of an un-filled
shape.
– Translate: To change a point’s coordinates from one coordinate space to another.
– X axis: The horizontal axis in the 2-d coordinate system used in ActionScript.
– Y axis: The vertical axis in the 2-d coordinate system used in ActionScript.
Drawing straight lines
var triangleHeight:uint = 100;
var triangle:Shape = new Shape();
// red triangle, starting at point 0, 0
triangle.graphics.beginFill(0xFF0000);
triangle.graphics.moveTo(triangleHeight/2, 0);
triangle.graphics.lineTo(triangleHeight, triangleHeight);
triangle.graphics.lineTo(0, triangleHeight);
triangle.graphics.lineTo(triangleHeight/2, 0);
// green triangle, starting at point 200, 0
triangle.graphics.beginFill(0x00FF00);
triangle.graphics.moveTo(200 + triangleHeight/2, 0);
triangle.graphics.lineTo(200 + triangleHeight, triangleHeight);
triangle.graphics.lineTo(200, triangleHeight);
triangle.graphics.lineTo(200 + triangleHeight/2, 0);
this.addChild(triangle);
Drawing curves
var size:uint = 100;
var roundObject:Shape = new Shape();
// red circular shape
roundObject.graphics.beginFill(0xFF0000);
roundObject.graphics.moveTo(size / 2, 0);
roundObject.graphics.curveTo(size, 0, size, size / 2);
roundObject.graphics.curveTo(size, size, size / 2, size);
roundObject.graphics.curveTo(0, size, 0, size / 2);
roundObject.graphics.curveTo(0, 0, size / 2, 0);
// green circular shape
roundObject.graphics.beginFill(0x00FF00);
roundObject.graphics.moveTo(200 + size / 2, 0);
roundObject.graphics.curveTo(200 + size, 0, 200 + size, size / 2);
roundObject.graphics.curveTo(200 + size, size, 200 + size / 2, size);
roundObject.graphics.curveTo(200, size, 200, size / 2);
roundObject.graphics.curveTo(200, 0, 200 + size / 2, 0);
this.addChild(roundObject);
Drawing shapes using built-in methods
var squareSize:uint = 100;
var square:Shape = new Shape();
square.graphics.beginFill(0xFF0000, 0.5);
square.graphics.drawRect(0, 0, squareSize,
squareSize);
square.graphics.beginFill(0x00FF00, 0.5);
square.graphics.drawRect(200, 0, squareSize,
squareSize);
square.graphics.beginFill(0x0000FF, 0.5);
square.graphics.drawRect(400, 0, squareSize,
squareSize);
square.graphics.endFill();
this.addChild(square);
Drawing shapes using built-in methods
var mySprite:Sprite = new Sprite();
mySprite.graphics.beginFill(0xFFCC00);
mySprite.graphics.drawCircle(30, 30, 30);
var label:TextField = new TextField();
label.width = 200;
label.text = "They call me mellow yellow...";
label.x = 20;
label.y = 20;
mySprite.addChild(label);
this.addChild(mySprite);
Creating gradient lines and fills
import flash.display.Shape;
import flash.display.GradientType;
import flash.geom.Matrix;
var type:String = GradientType.RADIAL;
var colors:Array = [0x00FF00, 0x000088];
var alphas:Array = [1, 1];
var ratios:Array = [0, 255];
var spreadMethod:String = SpreadMethod.PAD;
var interp:String = InterpolationMethod.LINEAR_RGB;
var focalPtRatio:Number = 0;
var matrix:Matrix = new Matrix();
var boxWidth:Number = 50;
var boxHeight:Number = 100;
var boxRotation:Number = Math.PI/2; // 90°
var tx:Number = 25;
var ty:Number = 0;
matrix.createGradientBox(boxWidth, boxHeight, boxRotation, tx, ty);
var square:Shape = new Shape;
square.graphics.beginGradientFill(type, colors,alphas,ratios, matrix, spreadMethod, interp,
focalPtRatio);
square.graphics.drawRect(0, 0, 100, 100);
addChild(square);
var myShape:Shape = new Shape();
var gradientBoxMatrix:Matrix = new Matrix();
gradientBoxMatrix.createGradientBox(100, 40,
0, 0, 0);
myShape.graphics.beginGradientFill(GradientT
ype.LINEAR, [0xFF0000,
0x00FF00, 0x0000FF], [1, 1, 1], [0, 128, 255],
gradientBoxMatrix);
myShape.graphics.drawRect(0, 0, 50, 40);
myShape.graphics.drawRect(0, 50, 100, 40);
myShape.graphics.drawRect(0, 100, 150, 40);
myShape.graphics.endFill();
this.addChild(myShape);

More Related Content

What's hot

2f predict the shape of a graph
2f predict the shape of a graph2f predict the shape of a graph
2f predict the shape of a graphD Sanders
 
INTRODUCTION TO AutoCAD
INTRODUCTION TO AutoCADINTRODUCTION TO AutoCAD
INTRODUCTION TO AutoCADAjith Kumar
 
CIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkCIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkTUOS-Sam
 
FPGA-Sketch Board
FPGA-Sketch BoardFPGA-Sketch Board
FPGA-Sketch Boardshahparin
 
isometric drawing (Chapter )
isometric drawing (Chapter )isometric drawing (Chapter )
isometric drawing (Chapter )Junea June
 
VB Lines and Shapes
VB Lines and ShapesVB Lines and Shapes
VB Lines and Shapesobrienduke
 
Technical Drawing
Technical DrawingTechnical Drawing
Technical Drawingdavidmandle
 
Assembly representation scheme
Assembly representation schemeAssembly representation scheme
Assembly representation schemeManoj Gowda K
 
Lesson 6_Prepare and Interpret Technical Drawing (LO1)
Lesson 6_Prepare and Interpret Technical Drawing (LO1)Lesson 6_Prepare and Interpret Technical Drawing (LO1)
Lesson 6_Prepare and Interpret Technical Drawing (LO1)Judie T
 
Surface modelling
Surface modellingSurface modelling
Surface modellingjntuhcej
 
2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica2D & 3D Modelling with Mathematica
2D & 3D Modelling with MathematicaMiles Ford
 
Nov. 5 Geometric Verifications Using Coordinate Geometry
Nov. 5 Geometric Verifications Using Coordinate GeometryNov. 5 Geometric Verifications Using Coordinate Geometry
Nov. 5 Geometric Verifications Using Coordinate GeometryRyanWatt
 
TLE 8 - TECHNICAL DRAFTING (INTERPRET TECHNICAL DRAWINGS AND PLANS)
TLE 8 - TECHNICAL DRAFTING (INTERPRET TECHNICAL DRAWINGS AND PLANS) TLE 8 - TECHNICAL DRAFTING (INTERPRET TECHNICAL DRAWINGS AND PLANS)
TLE 8 - TECHNICAL DRAFTING (INTERPRET TECHNICAL DRAWINGS AND PLANS) MichaellaApale
 
Composite Design-Pattern.ppt
Composite Design-Pattern.pptComposite Design-Pattern.ppt
Composite Design-Pattern.pptNimishan Sivaraj
 

What's hot (19)

2f predict the shape of a graph
2f predict the shape of a graph2f predict the shape of a graph
2f predict the shape of a graph
 
INTRODUCTION TO AutoCAD
INTRODUCTION TO AutoCADINTRODUCTION TO AutoCAD
INTRODUCTION TO AutoCAD
 
CIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkCIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & Coursework
 
Cad ppt
Cad pptCad ppt
Cad ppt
 
FPGA-Sketch Board
FPGA-Sketch BoardFPGA-Sketch Board
FPGA-Sketch Board
 
Intro to AutoCAD
Intro to AutoCADIntro to AutoCAD
Intro to AutoCAD
 
isometric drawing (Chapter )
isometric drawing (Chapter )isometric drawing (Chapter )
isometric drawing (Chapter )
 
VB Lines and Shapes
VB Lines and ShapesVB Lines and Shapes
VB Lines and Shapes
 
Technical Drawing
Technical DrawingTechnical Drawing
Technical Drawing
 
Assembly representation scheme
Assembly representation schemeAssembly representation scheme
Assembly representation scheme
 
Lesson 6_Prepare and Interpret Technical Drawing (LO1)
Lesson 6_Prepare and Interpret Technical Drawing (LO1)Lesson 6_Prepare and Interpret Technical Drawing (LO1)
Lesson 6_Prepare and Interpret Technical Drawing (LO1)
 
Draw 111- mechanical drawing and orthographic drawing
Draw 111- mechanical drawing and orthographic drawingDraw 111- mechanical drawing and orthographic drawing
Draw 111- mechanical drawing and orthographic drawing
 
Surface modelling
Surface modellingSurface modelling
Surface modelling
 
Cap.7
Cap.7Cap.7
Cap.7
 
2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica
 
Isometric Drawing
Isometric DrawingIsometric Drawing
Isometric Drawing
 
Nov. 5 Geometric Verifications Using Coordinate Geometry
Nov. 5 Geometric Verifications Using Coordinate GeometryNov. 5 Geometric Verifications Using Coordinate Geometry
Nov. 5 Geometric Verifications Using Coordinate Geometry
 
TLE 8 - TECHNICAL DRAFTING (INTERPRET TECHNICAL DRAWINGS AND PLANS)
TLE 8 - TECHNICAL DRAFTING (INTERPRET TECHNICAL DRAWINGS AND PLANS) TLE 8 - TECHNICAL DRAFTING (INTERPRET TECHNICAL DRAWINGS AND PLANS)
TLE 8 - TECHNICAL DRAFTING (INTERPRET TECHNICAL DRAWINGS AND PLANS)
 
Composite Design-Pattern.ppt
Composite Design-Pattern.pptComposite Design-Pattern.ppt
Composite Design-Pattern.ppt
 

Viewers also liked

Chapter vii(accessing databases with jdbc)
Chapter vii(accessing databases with jdbc)Chapter vii(accessing databases with jdbc)
Chapter vii(accessing databases with jdbc)Chhom Karath
 
Chapter vi(class applet)
Chapter vi(class applet)Chapter vi(class applet)
Chapter vi(class applet)Chhom Karath
 
Ch7(publishing my sql data on the web)
Ch7(publishing my sql data on the web)Ch7(publishing my sql data on the web)
Ch7(publishing my sql data on the web)Chhom Karath
 
Chapter ii(coding)
Chapter ii(coding)Chapter ii(coding)
Chapter ii(coding)Chhom Karath
 
Ch2(working with forms)
Ch2(working with forms)Ch2(working with forms)
Ch2(working with forms)Chhom Karath
 
Interacting with Oracle Database
Interacting with Oracle DatabaseInteracting with Oracle Database
Interacting with Oracle DatabaseChhom Karath
 
Chapter iii(building a simple user interface)
Chapter iii(building a simple user interface)Chapter iii(building a simple user interface)
Chapter iii(building a simple user interface)Chhom Karath
 
Chapter iii(advance function)
Chapter iii(advance function)Chapter iii(advance function)
Chapter iii(advance function)Chhom Karath
 
Chapter i(flash basic)
Chapter i(flash basic)Chapter i(flash basic)
Chapter i(flash basic)Chhom Karath
 
Ch4(saving state with cookies and query strings)
Ch4(saving state with cookies and query strings)Ch4(saving state with cookies and query strings)
Ch4(saving state with cookies and query strings)Chhom Karath
 
Ch3(working with file)
Ch3(working with file)Ch3(working with file)
Ch3(working with file)Chhom Karath
 
Chapter iv(modern gui)
Chapter iv(modern gui)Chapter iv(modern gui)
Chapter iv(modern gui)Chhom Karath
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)Chhom Karath
 
Karate-do
Karate-doKarate-do
Karate-docedric
 
Oracle Database Introduction
Oracle Database IntroductionOracle Database Introduction
Oracle Database IntroductionChhom Karath
 

Viewers also liked (20)

Chapter v(error)
Chapter v(error)Chapter v(error)
Chapter v(error)
 
8. chapter viii
8. chapter viii8. chapter viii
8. chapter viii
 
Chapter vii(accessing databases with jdbc)
Chapter vii(accessing databases with jdbc)Chapter vii(accessing databases with jdbc)
Chapter vii(accessing databases with jdbc)
 
Ch6(mysql front)
Ch6(mysql front)Ch6(mysql front)
Ch6(mysql front)
 
Chapter vi(class applet)
Chapter vi(class applet)Chapter vi(class applet)
Chapter vi(class applet)
 
Ch7(publishing my sql data on the web)
Ch7(publishing my sql data on the web)Ch7(publishing my sql data on the web)
Ch7(publishing my sql data on the web)
 
Chapter ii(coding)
Chapter ii(coding)Chapter ii(coding)
Chapter ii(coding)
 
Ch2(working with forms)
Ch2(working with forms)Ch2(working with forms)
Ch2(working with forms)
 
Ch1
Ch1Ch1
Ch1
 
Interacting with Oracle Database
Interacting with Oracle DatabaseInteracting with Oracle Database
Interacting with Oracle Database
 
Chapter iii(building a simple user interface)
Chapter iii(building a simple user interface)Chapter iii(building a simple user interface)
Chapter iii(building a simple user interface)
 
Chapter ii(oop)
Chapter ii(oop)Chapter ii(oop)
Chapter ii(oop)
 
Chapter iii(advance function)
Chapter iii(advance function)Chapter iii(advance function)
Chapter iii(advance function)
 
Chapter i(flash basic)
Chapter i(flash basic)Chapter i(flash basic)
Chapter i(flash basic)
 
Ch4(saving state with cookies and query strings)
Ch4(saving state with cookies and query strings)Ch4(saving state with cookies and query strings)
Ch4(saving state with cookies and query strings)
 
Ch3(working with file)
Ch3(working with file)Ch3(working with file)
Ch3(working with file)
 
Chapter iv(modern gui)
Chapter iv(modern gui)Chapter iv(modern gui)
Chapter iv(modern gui)
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
 
Karate-do
Karate-doKarate-do
Karate-do
 
Oracle Database Introduction
Oracle Database IntroductionOracle Database Introduction
Oracle Database Introduction
 

Similar to Chapter v(drawing)

Writeup advanced lane_lines_project
Writeup advanced lane_lines_projectWriteup advanced lane_lines_project
Writeup advanced lane_lines_projectManish Jauhari
 
3D Math Primer: CocoaConf Chicago
3D Math Primer: CocoaConf Chicago3D Math Primer: CocoaConf Chicago
3D Math Primer: CocoaConf ChicagoJanie Clayton
 
computer graphics lab manual 2013-converted.pdf
computer graphics lab manual 2013-converted.pdfcomputer graphics lab manual 2013-converted.pdf
computer graphics lab manual 2013-converted.pdfSyedSajjadShah3
 
Computer graphic
Computer graphicComputer graphic
Computer graphicnusratema1
 
Part 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptxPart 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptxKhalil Alhatab
 
CHAPTER 2 - Create 2D Basic Drawing.pptx
CHAPTER 2 - Create 2D Basic Drawing.pptxCHAPTER 2 - Create 2D Basic Drawing.pptx
CHAPTER 2 - Create 2D Basic Drawing.pptxMuhammad Taufik
 
Image feature extraction
Image feature extractionImage feature extraction
Image feature extractionRushin Shah
 
The Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerThe Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerJanie Clayton
 
Part 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxPart 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxKhalil Alhatab
 
Fundamentals of Multimedia - Vector Graphics.pdf
Fundamentals of Multimedia - Vector Graphics.pdfFundamentals of Multimedia - Vector Graphics.pdf
Fundamentals of Multimedia - Vector Graphics.pdfFatihahIrra
 
Part 2- Transformation.pptx
Part 2- Transformation.pptxPart 2- Transformation.pptx
Part 2- Transformation.pptxKhalil Alhatab
 
C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1 C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1 Mohammad Shaker
 

Similar to Chapter v(drawing) (20)

canvas.pptx
canvas.pptxcanvas.pptx
canvas.pptx
 
Writeup advanced lane_lines_project
Writeup advanced lane_lines_projectWriteup advanced lane_lines_project
Writeup advanced lane_lines_project
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
JDK and AWT
JDK and AWTJDK and AWT
JDK and AWT
 
Autocad Commands
Autocad CommandsAutocad Commands
Autocad Commands
 
3D Math Primer: CocoaConf Chicago
3D Math Primer: CocoaConf Chicago3D Math Primer: CocoaConf Chicago
3D Math Primer: CocoaConf Chicago
 
Primitives
PrimitivesPrimitives
Primitives
 
computer graphics lab manual 2013-converted.pdf
computer graphics lab manual 2013-converted.pdfcomputer graphics lab manual 2013-converted.pdf
computer graphics lab manual 2013-converted.pdf
 
Cad me2155-lab-manual
Cad me2155-lab-manualCad me2155-lab-manual
Cad me2155-lab-manual
 
Computer graphic
Computer graphicComputer graphic
Computer graphic
 
Chapter 13
Chapter 13Chapter 13
Chapter 13
 
Part 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptxPart 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptx
 
CHAPTER 2 - Create 2D Basic Drawing.pptx
CHAPTER 2 - Create 2D Basic Drawing.pptxCHAPTER 2 - Create 2D Basic Drawing.pptx
CHAPTER 2 - Create 2D Basic Drawing.pptx
 
Windows and viewport
Windows and viewportWindows and viewport
Windows and viewport
 
Image feature extraction
Image feature extractionImage feature extraction
Image feature extraction
 
The Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerThe Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math Primer
 
Part 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxPart 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptx
 
Fundamentals of Multimedia - Vector Graphics.pdf
Fundamentals of Multimedia - Vector Graphics.pdfFundamentals of Multimedia - Vector Graphics.pdf
Fundamentals of Multimedia - Vector Graphics.pdf
 
Part 2- Transformation.pptx
Part 2- Transformation.pptxPart 2- Transformation.pptx
Part 2- Transformation.pptx
 
C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1 C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1
 

More from Chhom Karath

More from Chhom Karath (20)

set1.pdf
set1.pdfset1.pdf
set1.pdf
 
Set1.pptx
Set1.pptxSet1.pptx
Set1.pptx
 
orthodontic patient education.pdf
orthodontic patient education.pdforthodontic patient education.pdf
orthodontic patient education.pdf
 
New ton 3.pdf
New ton 3.pdfNew ton 3.pdf
New ton 3.pdf
 
ច្បាប់ញូតុនទី៣.pptx
ច្បាប់ញូតុនទី៣.pptxច្បាប់ញូតុនទី៣.pptx
ច្បាប់ញូតុនទី៣.pptx
 
Control tipping.pptx
Control tipping.pptxControl tipping.pptx
Control tipping.pptx
 
Bulbous loop.pptx
Bulbous loop.pptxBulbous loop.pptx
Bulbous loop.pptx
 
brush teeth.pptx
brush teeth.pptxbrush teeth.pptx
brush teeth.pptx
 
bracket size.pptx
bracket size.pptxbracket size.pptx
bracket size.pptx
 
arch form KORI copy.pptx
arch form KORI copy.pptxarch form KORI copy.pptx
arch form KORI copy.pptx
 
Bracket size
Bracket sizeBracket size
Bracket size
 
Couple
CoupleCouple
Couple
 
ច្បាប់ញូតុនទី៣
ច្បាប់ញូតុនទី៣ច្បាប់ញូតុនទី៣
ច្បាប់ញូតុនទី៣
 
Game1
Game1Game1
Game1
 
Shoe horn loop
Shoe horn loopShoe horn loop
Shoe horn loop
 
Opus loop
Opus loopOpus loop
Opus loop
 
V bend
V bendV bend
V bend
 
Closing loop
Closing loopClosing loop
Closing loop
 
Maxillary arch form
Maxillary arch formMaxillary arch form
Maxillary arch form
 
Front face analysis
Front face analysisFront face analysis
Front face analysis
 

Recently uploaded

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Chapter v(drawing)

  • 1. Basics of using the drawing API
  • 2. • The drawing API is the name for the functionality built into ActionScript that allows you to create vector graphics—lines, curves, shapes, fills, and gradients—and display them on the screen using ActionScript. • The following reference list contains important terms that you will encounter in this chapter: – Anchor point: One of the two end points of a quadratic Bézier curve. – Control point: The point that defines the direction and amount of curve of a quadratic Bézier curve. The curved line never reaches the control point; however, the line curves as though being drawn toward the control point. – Coordinate space: The graph of coordinates contained in a display object, on which its child elements are positioned. – Fill: The solid inner portion of a shape that has a line filled in with color, or all of a shape that has no outline. – Gradient: A color that consists of a gradual transition from one color to one or more other colors (as opposed to a solid color). – Point: A single location in a coordinate space. In the 2-d coordinate system used in ActionScript, a point is defined by its location along the x axis and the y axis (the point’s coordinates). – Quadratic Bézier curve: A type of curve defined by a particular mathematical formula. In this type of curve, the shape of the curve is calculated based on the positions of the anchor points (the end points of the curve) and a control point that defines the amount and direction of the curve. – Scale: The size of an object relative to its original size. When used as a verb, to scale an object means to change its size by stretching or shrinking the object. – Stroke: The outline portion of a shape that has a line filled in with color, or the lines of an un-filled shape. – Translate: To change a point’s coordinates from one coordinate space to another. – X axis: The horizontal axis in the 2-d coordinate system used in ActionScript. – Y axis: The vertical axis in the 2-d coordinate system used in ActionScript.
  • 3. Drawing straight lines var triangleHeight:uint = 100; var triangle:Shape = new Shape(); // red triangle, starting at point 0, 0 triangle.graphics.beginFill(0xFF0000); triangle.graphics.moveTo(triangleHeight/2, 0); triangle.graphics.lineTo(triangleHeight, triangleHeight); triangle.graphics.lineTo(0, triangleHeight); triangle.graphics.lineTo(triangleHeight/2, 0); // green triangle, starting at point 200, 0 triangle.graphics.beginFill(0x00FF00); triangle.graphics.moveTo(200 + triangleHeight/2, 0); triangle.graphics.lineTo(200 + triangleHeight, triangleHeight); triangle.graphics.lineTo(200, triangleHeight); triangle.graphics.lineTo(200 + triangleHeight/2, 0); this.addChild(triangle);
  • 4. Drawing curves var size:uint = 100; var roundObject:Shape = new Shape(); // red circular shape roundObject.graphics.beginFill(0xFF0000); roundObject.graphics.moveTo(size / 2, 0); roundObject.graphics.curveTo(size, 0, size, size / 2); roundObject.graphics.curveTo(size, size, size / 2, size); roundObject.graphics.curveTo(0, size, 0, size / 2); roundObject.graphics.curveTo(0, 0, size / 2, 0); // green circular shape roundObject.graphics.beginFill(0x00FF00); roundObject.graphics.moveTo(200 + size / 2, 0); roundObject.graphics.curveTo(200 + size, 0, 200 + size, size / 2); roundObject.graphics.curveTo(200 + size, size, 200 + size / 2, size); roundObject.graphics.curveTo(200, size, 200, size / 2); roundObject.graphics.curveTo(200, 0, 200 + size / 2, 0); this.addChild(roundObject);
  • 5. Drawing shapes using built-in methods var squareSize:uint = 100; var square:Shape = new Shape(); square.graphics.beginFill(0xFF0000, 0.5); square.graphics.drawRect(0, 0, squareSize, squareSize); square.graphics.beginFill(0x00FF00, 0.5); square.graphics.drawRect(200, 0, squareSize, squareSize); square.graphics.beginFill(0x0000FF, 0.5); square.graphics.drawRect(400, 0, squareSize, squareSize); square.graphics.endFill(); this.addChild(square);
  • 6. Drawing shapes using built-in methods var mySprite:Sprite = new Sprite(); mySprite.graphics.beginFill(0xFFCC00); mySprite.graphics.drawCircle(30, 30, 30); var label:TextField = new TextField(); label.width = 200; label.text = "They call me mellow yellow..."; label.x = 20; label.y = 20; mySprite.addChild(label); this.addChild(mySprite);
  • 7. Creating gradient lines and fills import flash.display.Shape; import flash.display.GradientType; import flash.geom.Matrix; var type:String = GradientType.RADIAL; var colors:Array = [0x00FF00, 0x000088]; var alphas:Array = [1, 1]; var ratios:Array = [0, 255]; var spreadMethod:String = SpreadMethod.PAD; var interp:String = InterpolationMethod.LINEAR_RGB; var focalPtRatio:Number = 0; var matrix:Matrix = new Matrix(); var boxWidth:Number = 50; var boxHeight:Number = 100; var boxRotation:Number = Math.PI/2; // 90° var tx:Number = 25; var ty:Number = 0; matrix.createGradientBox(boxWidth, boxHeight, boxRotation, tx, ty); var square:Shape = new Shape; square.graphics.beginGradientFill(type, colors,alphas,ratios, matrix, spreadMethod, interp, focalPtRatio); square.graphics.drawRect(0, 0, 100, 100); addChild(square);
  • 8. var myShape:Shape = new Shape(); var gradientBoxMatrix:Matrix = new Matrix(); gradientBoxMatrix.createGradientBox(100, 40, 0, 0, 0); myShape.graphics.beginGradientFill(GradientT ype.LINEAR, [0xFF0000, 0x00FF00, 0x0000FF], [1, 1, 1], [0, 128, 255], gradientBoxMatrix); myShape.graphics.drawRect(0, 0, 50, 40); myShape.graphics.drawRect(0, 50, 100, 40); myShape.graphics.drawRect(0, 100, 150, 40); myShape.graphics.endFill(); this.addChild(myShape);