SlideShare ist ein Scribd-Unternehmen logo
1 von 52
@glomadrian
Adrián García Lomas
Canvas al ajillo
Lo que me gustaría que me
hubieran contado sobre
Canvas y Custom Views
Los detalles importan
Adapta las vistas a las
necesidades no las
necesidades a las vistas
Un mundo diferente y
divertido
Ciclo de vida
de una vista
Constructor
onAttachedToWindow()
onMeassure()
onLayout()
dispatchDraw()
draw()
onDraw()
invalidate()
Animación de carga
public Loading(Context context) {
super(context);
initialize();
}
public Loading(Context context, AttributeSet attrs) {
super(context, attrs);
initialize();
}
public Loading(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize();
}
private void initialize() {
circlePaint = new Paint();
circlePaint.setColor(circleColor);
circlePaint.setAntiAlias(true);
circlePaint.setStyle(Paint.Style.STROKE);
circlePaint.setStrokeWidth(circleStroke);
}
¿Qué pasa con el
tamaño de la vista?
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
width = w;
height = h;
createCircle();
}
private void createCircleArea() {
int circleAreawidth = width - strokeWidth;
int circleAreaHeight = heihgt - strokeWidth;
circleArea = new RectF(strokeWidth, strokeWidth, circleAreawidth,
circleAreaHeight);
}
onDraw(Canvas canvas)
16ms (60 fps)
Evitar nuevas instancias
No usar invalidate()
X
Y
● width / 2 , height / 2
● 0 , 0
private float circleStartDegree = 0;
private float circleEndDegree = 360;
private float actualCircleEndDegree = circleEndDegree;
@Override
protected void onDraw(Canvas canvas) {
drawCircle(canvas);
}
private void drawCircle(Canvas canvas) {
canvas.drawArc(circleArea, circleStartDegree,
actualCircleEndDegree, false, circlePaint);
}
circlePaint.setPathEffect(new DashPathEffect(new float[]{dashWidth, dashSpace}, 0));
Animación
private void initializeAnimator() {
valueAnimator = ValueAnimator.ofInt(circleStartDegree, circleEndDegree);
valueAnimator.setDuration(1000);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
int degreeValue = (int) valueAnimator.getAnimatedValue();
actualCircleEndDegree = degreeValue;
invalidate();
}
});
}
private void initialize() {
initializePainter();
initializeAnimator();
}
public void start(){
valueAnimator.start();
}
ValueAnimator
onUpdate
degree = value
invalidate
onDraw()
Interpolators
Acelerate
Acelerate Decelerate
BounceInterpolator
OvershootInterpolator
...
valueAnimator.setInterpolator(new BounceInterpolator());
valueAnimator.setInterpolator(new DecelateInterpolator());
blurPainter = new Paint(circlePaint);
blurPainter.setColor(Color.RED);
blurPainter.setStrokeWidth(circleStroke * 1.20F);
blurPainter.setMaskFilter(new BlurMaskFilter(blurRadius, BlurMaskFilter.Blur.NORMAL));
private void drawCircle(Canvas canvas) {
canvas.drawArc(internalCircle, circleStartDegree, circleEndDegree, false, blurPainter);
canvas.drawArc(internalCircle, circleStartDegree, circleEndDegree, false, circlePaint);
}
setLayerType(LAYER_TYPE_SOFTWARE, null);
Muerte a las vistas
cuadradas
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
width = w;
height = h;
createPath();
}
private void createPath() {
curvedPath = new Path();
curvedPath.moveTo(0, 0);
curvedPath.lineTo(width, 0);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawPath(curvedPath, pathPaint);
}
curvedPath.quadTo(x1, y1, x2, y2);
x1, y1
x2, y2
private void createPath() {
float pathCurvatureY = height / 2;
float middleX = width / 2;
curvedPath = new Path();
curvedPath.moveTo(0, 0);
curvedPath.quadTo(middleX, pathCurvatureY, width, 0);
} 0,0
middleX, pathCurvatureY
width, 0
private void createPath() {
float pathCurvatureY = height / 2;
float middleX = width / 2;
curvedPath = new Path();
curvedPath.moveTo(0, 0);
curvedPath.quadTo(middleX, pathCurvatureY, width, 0);
curvedPath.lineTo(width, height);
}
width, height
private void createPath() {
float pathCurvatureY = height / 2;
float middleX = width / 2;
curvedPath = new Path();
curvedPath.moveTo(0, 0);
curvedPath.quadTo(middleX, pathCurvatureY, width, 0);
curvedPath.lineTo(width, height);
curvedPath.lineTo(0, height);
}
0, height
private void createPath() {
float pathCurvatureY = height / 2;
float middleX = width / 2;
curvedPath = new Path();
curvedPath.moveTo(0, 0);
curvedPath.quadTo(middleX, pathCurvatureY, width, 0);
curvedPath.lineTo(width, height);
curvedPath.lineTo(0, height);
curvedPath.close();
}
pathPaint.setStyle(Paint.Style.FILL);
Interceptando
touch events
dentro de un
área
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
width = w;
height = h;
createPath();
createTouchRegion();
}
private void createTouchRegion() {
RectF pathBoundsRect = new RectF();
curvedPath.computeBounds(rectF, true);
regionToCheck = new Region(pathBoundsRect.left,
pathBoundsRect.top, pathBoundsRect.right,
pathBoundsRect.bottom);
regionToCheck.setPath(curvedPath, regionToCheck);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean result = false;
int pointX = (int) event.getX();
int pointY = (int) event.getY();
if (isPointInsidePathArea(pointX, pointY)) {
result = super.onTouchEvent(event);
}
return result;
}
private boolean isPointInsidePathArea(int x, int y) {
return regionToCheck.contains(x, y);
}
Usando path
para animar
private float[] getPathCoordinates(Path path, float fraction)
{
float aCoordinates[] = { 0f, 0f };
PathMeasure pm = new PathMeasure(path, false);
pm.getPosTan(pm.getLength() * fraction, aCoordinates, null);
return aCoordinates;
}
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = animation.getAnimatedFraction();
float[] coordinates = getPathCoordinates(infinitePath, value);
this.ballX = coordinates[0];
this.ballY = coordinates[1];
invalidate()
}
Midiendo el
rendimiento
onDraw()
Recursos
OpenGL
Espera CPU
16 ms
private void onDraw(Canvas canvas) {
heavyWork();
canvas.drawArc(internalCircle, circleStartDegree,
circleEndDegree, false, circlePaint);
}
Clean code
también en
vistas
@Override
protected void onDraw(Canvas canvas) {
if (mRunning) {
if (mShowLeftEye) {
canvas.drawCircle(mLeftEyePos[0], mLeftEyePos[1], mEyeCircleRadius,
mCirclePaint);
}
if (mShowRightEye) {
canvas.drawCircle(mRightEyePos[0], mRightEyePos[1], mEyeCircleRadius,
mCirclePaint);
}
if (mFirstStep) {
mArcPath.reset();
mArcPath.addArc(mRectF, mStartAngle, mSweepAngle);
canvas.drawPath(mArcPath, mArcPaint);
} else {
mArcPath.reset();
mArcPath.addArc(mRectF, mStartAngle, mSweepAngle);
canvas.drawPath(mArcPath, mArcPaint);
}
} else {
canvas.drawCircle(mLeftEyePos[0], mLeftEyePos[1], mEyeCircleRadius, mCirclePaint);
canvas.drawCircle(mRightEyePos[0], mRightEyePos[1], mEyeCircleRadius,mCirclePaint);
canvas.drawPath(mArcPath, mArcPaint);
}
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
externalCirclePainter.draw(canvas);
internalCirclePainter.draw(canvas);
progressPainter.draw(canvas);
iconPainter.draw(canvas);
}
¿Preguntas?

Weitere ähnliche Inhalte

Was ist angesagt?

Creating custom views
Creating custom viewsCreating custom views
Creating custom views
Mu Chun Wang
 
Test driven game development silly, stupid or inspired?
Test driven game development   silly, stupid or inspired?Test driven game development   silly, stupid or inspired?
Test driven game development silly, stupid or inspired?
Eric Smith
 
刘平川:【用户行为分析】Marmot实践
刘平川:【用户行为分析】Marmot实践刘平川:【用户行为分析】Marmot实践
刘平川:【用户行为分析】Marmot实践
taobao.com
 

Was ist angesagt? (20)

Intro to Game Programming
Intro to Game ProgrammingIntro to Game Programming
Intro to Game Programming
 
Writing a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasWriting a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 Canvas
 
Creating custom views
Creating custom viewsCreating custom views
Creating custom views
 
Introduction to HTML5 Canvas
Introduction to HTML5 CanvasIntroduction to HTML5 Canvas
Introduction to HTML5 Canvas
 
HTML5 Canvas
HTML5 CanvasHTML5 Canvas
HTML5 Canvas
 
Intro to HTML5 Canvas
Intro to HTML5 CanvasIntro to HTML5 Canvas
Intro to HTML5 Canvas
 
Test Driven Cocos2d
Test Driven Cocos2dTest Driven Cocos2d
Test Driven Cocos2d
 
Exploring fractals in CSS, @fronttrends, Warsaw, 2015
Exploring fractals in CSS, @fronttrends, Warsaw, 2015Exploring fractals in CSS, @fronttrends, Warsaw, 2015
Exploring fractals in CSS, @fronttrends, Warsaw, 2015
 
Test driven game development silly, stupid or inspired?
Test driven game development   silly, stupid or inspired?Test driven game development   silly, stupid or inspired?
Test driven game development silly, stupid or inspired?
 
Drawing with the HTML5 Canvas
Drawing with the HTML5 CanvasDrawing with the HTML5 Canvas
Drawing with the HTML5 Canvas
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
 
刘平川:【用户行为分析】Marmot实践
刘平川:【用户行为分析】Marmot实践刘平川:【用户行为分析】Marmot实践
刘平川:【用户行为分析】Marmot实践
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision Detection
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2ME
 
Proga 090525
Proga 090525Proga 090525
Proga 090525
 
Building mobile web apps with Mobello
Building mobile web apps with MobelloBuilding mobile web apps with Mobello
Building mobile web apps with Mobello
 
用户行为系统Marmot - D2 2011 session
用户行为系统Marmot - D2 2011 session用户行为系统Marmot - D2 2011 session
用户行为系统Marmot - D2 2011 session
 
Александр Зимин – Анимация как средство самовыражения
Александр Зимин – Анимация как средство самовыраженияАлександр Зимин – Анимация как средство самовыражения
Александр Зимин – Анимация как средство самовыражения
 
MongoDB - Introduction
MongoDB - IntroductionMongoDB - Introduction
MongoDB - Introduction
 
Introduction to Game Programming Tutorial
Introduction to Game Programming TutorialIntroduction to Game Programming Tutorial
Introduction to Game Programming Tutorial
 

Andere mochten auch (10)

1 redes sociais estratégias e tendencias-resumo
1 redes sociais estratégias e tendencias-resumo1 redes sociais estratégias e tendencias-resumo
1 redes sociais estratégias e tendencias-resumo
 
Ob3 Igualdade GéNero Pilar Maria
Ob3 Igualdade GéNero Pilar MariaOb3 Igualdade GéNero Pilar Maria
Ob3 Igualdade GéNero Pilar Maria
 
Revista Pronews #186
Revista Pronews #186Revista Pronews #186
Revista Pronews #186
 
Actividad postales junio 24
Actividad postales junio 24Actividad postales junio 24
Actividad postales junio 24
 
5 headlines
5 headlines5 headlines
5 headlines
 
What is Corporate Lodging?
What is Corporate Lodging? What is Corporate Lodging?
What is Corporate Lodging?
 
C.V'
C.V'C.V'
C.V'
 
Planificador de proyectos club noel
Planificador de proyectos club noelPlanificador de proyectos club noel
Planificador de proyectos club noel
 
La educación cubana
La educación cubanaLa educación cubana
La educación cubana
 
Autoestima y asertividad
Autoestima y asertividadAutoestima y asertividad
Autoestima y asertividad
 

Ähnlich wie Canvas al ajillo

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
Bitla Software
 
How to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftHow to Clone Flappy Bird in Swift
How to Clone Flappy Bird in Swift
Giordano Scalzo
 
Create a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfCreate a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdf
arihantmobileselepun
 
I need to create a page looks like a picture. But it looks different.pdf
I need to create a page looks like a picture. But it looks different.pdfI need to create a page looks like a picture. But it looks different.pdf
I need to create a page looks like a picture. But it looks different.pdf
allurafashions98
 
need help with code I wrote. This code is a maze gui, and i need hel.pdf
need help with code I wrote. This code is a maze gui, and i need hel.pdfneed help with code I wrote. This code is a maze gui, and i need hel.pdf
need help with code I wrote. This code is a maze gui, and i need hel.pdf
arcotstarsports
 
package chapter15;import javafx.application.Application;import j.pdf
package chapter15;import javafx.application.Application;import j.pdfpackage chapter15;import javafx.application.Application;import j.pdf
package chapter15;import javafx.application.Application;import j.pdf
KARTIKINDIA
 
[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9
Shih-Hsiang Lin
 

Ähnlich wie Canvas al ajillo (20)

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
 
How to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftHow to Clone Flappy Bird in Swift
How to Clone Flappy Bird in Swift
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
Create a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfCreate a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdf
 
I need to create a page looks like a picture. But it looks different.pdf
I need to create a page looks like a picture. But it looks different.pdfI need to create a page looks like a picture. But it looks different.pdf
I need to create a page looks like a picture. But it looks different.pdf
 
need help with code I wrote. This code is a maze gui, and i need hel.pdf
need help with code I wrote. This code is a maze gui, and i need hel.pdfneed help with code I wrote. This code is a maze gui, and i need hel.pdf
need help with code I wrote. This code is a maze gui, and i need hel.pdf
 
JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011
 
[Ultracode Munich Meetup #7] Android view customization in a nutshell
[Ultracode Munich Meetup #7] Android view customization in a nutshell[Ultracode Munich Meetup #7] Android view customization in a nutshell
[Ultracode Munich Meetup #7] Android view customization in a nutshell
 
Android Animation (in tamil)
Android Animation (in tamil)Android Animation (in tamil)
Android Animation (in tamil)
 
The Ring programming language version 1.6 book - Part 86 of 189
The Ring programming language version 1.6 book - Part 86 of 189The Ring programming language version 1.6 book - Part 86 of 189
The Ring programming language version 1.6 book - Part 86 of 189
 
Learning WebGLで学ぶWebGL入門
Learning WebGLで学ぶWebGL入門Learning WebGLで学ぶWebGL入門
Learning WebGLで学ぶWebGL入門
 
package chapter15;import javafx.application.Application;import j.pdf
package chapter15;import javafx.application.Application;import j.pdfpackage chapter15;import javafx.application.Application;import j.pdf
package chapter15;import javafx.application.Application;import j.pdf
 
The Canvas API for Rubyists
The Canvas API for RubyistsThe Canvas API for Rubyists
The Canvas API for Rubyists
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3D
 
[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9[C++ gui programming with qt4] chap9
[C++ gui programming with qt4] chap9
 
OL4JSF - Latinoware 2010
OL4JSF - Latinoware 2010OL4JSF - Latinoware 2010
OL4JSF - Latinoware 2010
 
HTML5 Canvas (Wall Clock).pptx
HTML5 Canvas (Wall Clock).pptxHTML5 Canvas (Wall Clock).pptx
HTML5 Canvas (Wall Clock).pptx
 
A More Flash Like Web?
A More Flash Like Web?A More Flash Like Web?
A More Flash Like Web?
 
Hacking JavaFX with Groovy, Clojure, Scala, and Visage
Hacking JavaFX with Groovy, Clojure, Scala, and VisageHacking JavaFX with Groovy, Clojure, Scala, and Visage
Hacking JavaFX with Groovy, Clojure, Scala, and Visage
 
The Ring programming language version 1.5.3 book - Part 70 of 184
The Ring programming language version 1.5.3 book - Part 70 of 184The Ring programming language version 1.5.3 book - Part 70 of 184
The Ring programming language version 1.5.3 book - Part 70 of 184
 

Kürzlich hochgeladen

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 

Kürzlich hochgeladen (20)

Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 

Canvas al ajillo

Hinweis der Redaktion

  1. Motivacion de la charla, introdución a la api de canvas, path, algunos trucos un poco de perfonance para ellos explicare dos pequeños ejemplos un loading y una vista que usaremos de boton
  2. Realmente no son dificiles de usar No ir siempre a buscar la solucion a GITHUB No necesitas todo lo que aporta la librearia Más control Adaptado totalmente a tus necesidades Es muy divertido programar vistas, es totalmente diferente a lo que hacemos dia a dia
  3. Ciclo de vida de una vista, por que es importante conocer por que pasos toma la vista
  4. Primero se ejecuta el contructor, que es donde crearemos los objetos necesarios que no dependan del tamaño de la vista Es llamado justo despues de que el padre hagaun addView() measure() && onMeassure() en este momento la vista aun no tiene tamaño y es aqui donde se puede definir en caso de que necesitemos modificarlo, por ejemlo aqui podemos saber si nuestra vista se encuentra dentro de un tamaño concreto, de un math_parent o de un wrap_content y actuar en consecuencia layout && onLayout() el onLayout se ejecuta por cada uno de las vistas hijas añadidas en la mayoria de los casos no es necesario
  5. dispathDraw() && draw() y onDraw() es el metodo más importante y es donde vamos a realizar todas las tareas de pintado de nuestras vistas custom una vez realizado el onDraw() la vista es mostrada y no se volvera a pintar a no ser que se llame al método invalidate() este métoco hace volver a empezar el ciclo de pintado y entonces el método onDraw() vovlera a ser ejecutado
  6. Para ilustrar mejor todo esto vamos hacer paso a paso una animación de carga parecida a esta
  7. Hablar del paint, Controla el color, el estilo los tamaños y muchas cosas más Es un objeto que necesitaremos todo el tiempo que dure la vista por lo que conviene creerlo al principio
  8. Por lo general el tamaño de una vista suele dar problemas sobretodo al principio. Por el proceso que pasa la vista el tamaño no se obtiene hasta cierto momento del ciclo de vida de la vista
  9. El método onSizeChanged es muy importante siempre se llamará cuando el tamaño cambie. Eso quiere decir que se llamara despues del onLayout Este es un buen sitio para crear todos los componentes que necesiten de tamaño. Le resto el borde para evitar que el circulo se corte RectF define un rectangulo, donde se definen las 4 posiciones x1, y1, x2, y2
  10. Método donde ocurre todo Tener en cuenta los 16MS es el tiempo que se tiene para pintar Por eso hay que evitar todos los proceso pesados en este método si se usa invalidate se entra en un bucle Canvas es el objeto donde se pinta todo, canvas provee una cantidad de metodos para el pintado entre ellos drawCircle drawPath etc
  11. explicar método circle RectF Grados desde donde empieza false / true Mejorar circulo
  12. Que es DashPathEffect pinta el stroke dash Hay más pathEffect
  13. QUe es value animator y para que sirve Como lo vamos a usar Crear animación al crear la vista Tiene dos listener importantes Vamos a usar el update listener Este listener salta cada vez que un valor se actualiza El truco consiste en setear el valor del circulo al que nos devuelve el valueAnimator y forzar el pintado Varios tipos de animator float int color
  14. Explicar lo que ha pasado y asi es como funcionan las animaciones en canvas Frame a frame
  15. Explicar que el value animator los devuelve de manera lineal y que se le puede pasar un interpolator para definir cómo deben ser devueltos Explicar que son funciones matemáticas Hay muchos
  16. Explicar que queremos mejorar el ciruclo amarillo poniendo por debajo una distorion
  17. explicar que creamos otro painter con otras propiedades en este caso Rojo con un ancho 20% más y una mascara de blur
  18. No obtenemos nada... Pregunta?
  19. Solo en vistas estaticas vistas que no esten dentro de un adapter ni sean reutilizadas No solo pasa aqui, tambien en las mascaras en canvas para imagenes etc
  20. Cambio de cuadradas - innovar no ir siempre a lo mismo Explicar lo que vamos hacer
  21. Explicar path, que es y para qué sirve Cómo funciona
  22. Explicar como funciona quadTo
  23. Paso 1
  24. Some magic
  25. Resultado, explicar lo que se puede consguir con poco
  26. Explicar el problema Pregunta como solucionar