Introduction to Generative Art with Processingstefk00
This document provides an introduction to generative art using the Processing programming language. It discusses what Processing is, how to get started with it, and resources for learning Processing like books and websites. It then demonstrates how to create simple generative art by drawing shapes and using loops to manipulate the coordinate space in Processing code. The document shows the user how to set up their first Processing sketch and provides examples of generating simple patterns through nested for loops.
The document discusses the basic components of drawing in Android - Bitmap, Canvas, Drawing Primitives, and Paint. It provides examples of how to use the Canvas class to draw different primitives like points, lines, rectangles, arcs, and paths using a Paint object. It also demonstrates how to draw text, bitmaps and configure properties of the Paint like color, stroke and style.
The document discusses various methods for creating graphics and animation in .NET applications, including using the Graphics object to draw shapes, lines and filled areas; creating simple animation by changing or moving images over time; using the Timer component to automate animation; and incorporating drag-and-drop functionality.
The document compares and contrasts the Canvas and SVG elements in HTML. Canvas uses JavaScript to draw graphics via code and is rendered pixel by pixel, while SVG uses XML to draw graphics as scalable vector shapes. Canvas is better for games, charts, and advertising due to its faster rendering, while SVG is better for icons, logos, and charts due to its scalability and support for event handlers. Several common drawing methods like rectangles, circles, paths, and text are demonstrated for both Canvas and SVG.
The document discusses the HTML5 <canvas> element and 2D Canvas API. It provides details on:
- Creating a canvas element with an id, width, and height
- Getting a 2D drawing context object
- Common drawing methods like lineTo(), arc(), fillText(), strokeRect(), and clearRect()
- Setting properties like fillStyle, strokeStyle, and globalCompositeOperation
- Drawing shapes, images, and text
- Applying transformations with methods like translate(), rotate(), and save()/restore()
- Using requestAnimationFrame() for basic animation
The document provides an overview of the canvas element and its capabilities for 2D drawing and basic animation using JavaScript.
This document provides guidance on custom charting in Android by breaking down the drawing process into layers. It discusses using a Canvas and Paint objects to draw primitives like rectangles, circles, and text. Key aspects covered include calculating marker positions, drawing gradients, guidelines, lines between markers, week labels, and scales. The document encourages learning the main Canvas and Paint APIs and breaking complex views into separate drawing functions for each layer.
This document provides an introduction to HTML5 Canvas and describes some of its key drawing capabilities. It explains that the <canvas> element is used to draw graphics via scripting, usually with JavaScript. It then outlines several methods for drawing paths, boxes, circles, text, and images on the canvas. It also discusses using gradients, setting the coordinate system, and interacting with canvas elements through events.
Introduction to Generative Art with Processingstefk00
This document provides an introduction to generative art using the Processing programming language. It discusses what Processing is, how to get started with it, and resources for learning Processing like books and websites. It then demonstrates how to create simple generative art by drawing shapes and using loops to manipulate the coordinate space in Processing code. The document shows the user how to set up their first Processing sketch and provides examples of generating simple patterns through nested for loops.
The document discusses the basic components of drawing in Android - Bitmap, Canvas, Drawing Primitives, and Paint. It provides examples of how to use the Canvas class to draw different primitives like points, lines, rectangles, arcs, and paths using a Paint object. It also demonstrates how to draw text, bitmaps and configure properties of the Paint like color, stroke and style.
The document discusses various methods for creating graphics and animation in .NET applications, including using the Graphics object to draw shapes, lines and filled areas; creating simple animation by changing or moving images over time; using the Timer component to automate animation; and incorporating drag-and-drop functionality.
The document compares and contrasts the Canvas and SVG elements in HTML. Canvas uses JavaScript to draw graphics via code and is rendered pixel by pixel, while SVG uses XML to draw graphics as scalable vector shapes. Canvas is better for games, charts, and advertising due to its faster rendering, while SVG is better for icons, logos, and charts due to its scalability and support for event handlers. Several common drawing methods like rectangles, circles, paths, and text are demonstrated for both Canvas and SVG.
The document discusses the HTML5 <canvas> element and 2D Canvas API. It provides details on:
- Creating a canvas element with an id, width, and height
- Getting a 2D drawing context object
- Common drawing methods like lineTo(), arc(), fillText(), strokeRect(), and clearRect()
- Setting properties like fillStyle, strokeStyle, and globalCompositeOperation
- Drawing shapes, images, and text
- Applying transformations with methods like translate(), rotate(), and save()/restore()
- Using requestAnimationFrame() for basic animation
The document provides an overview of the canvas element and its capabilities for 2D drawing and basic animation using JavaScript.
This document provides guidance on custom charting in Android by breaking down the drawing process into layers. It discusses using a Canvas and Paint objects to draw primitives like rectangles, circles, and text. Key aspects covered include calculating marker positions, drawing gradients, guidelines, lines between markers, week labels, and scales. The document encourages learning the main Canvas and Paint APIs and breaking complex views into separate drawing functions for each layer.
This document provides an introduction to HTML5 Canvas and describes some of its key drawing capabilities. It explains that the <canvas> element is used to draw graphics via scripting, usually with JavaScript. It then outlines several methods for drawing paths, boxes, circles, text, and images on the canvas. It also discusses using gradients, setting the coordinate system, and interacting with canvas elements through events.
The document provides an overview of the HTML5 <canvas> element and how it can be used to draw graphics on a web page. Some key points:
- The <canvas> element is used to draw graphics programmatically using JavaScript. It acts as a container for graphics.
- Canvas has methods for drawing paths, boxes, circles, text and images. To draw, you first get a 2D drawing context from the canvas element, then use drawing methods like fillRect(), strokeText(), etc.
- The canvas uses a 2D grid with (0,0) at the top-left. Shapes can be filled or stroked. Gradients and shadows can also be used.
-
The document discusses HTML canvas and how to draw graphics on a canvas using JavaScript. It covers how to create a canvas element, get the rendering context, and use various drawing methods like fillRect(), strokeRect(), beginPath(), moveTo(), lineTo(), bezierCurveTo(), quadraticCurveTo() etc. to draw shapes, paths, images and text. It also discusses how to apply colors, gradients, patterns and shadows. The canvas state can be saved and restored using save() and restore() methods. Translations and rotations can be applied using translate() and rotate() methods.
The document discusses the Canvas element in HTML5 which allows dynamic rendering of 2D shapes and images in the browser using JavaScript. It provides basic context methods for drawing rectangles, strokes, gradients and images to the canvas. It also demonstrates how to add event listeners and animate drawings on the canvas.
The document provides an introduction to Processing, an open-source programming language and environment used for creating visuals and animations. It covers downloading and installing Processing, using the Processing Development Environment, setting the canvas size and coordinates, drawing basic shapes using code, adding color, using variables, loops and conditionals to create animations, and provides examples and resources for learning more.
The HTML5 canvas element allows drawing directly onto the page via JavaScript. It provides pixel-level control for creating animations, games, charts, and more. The canvas is drawn upon by using a drawing context object and its methods like fillRect(), stroke(), arc(), and fillText(). Gradients, patterns, and images can also be rendered onto the canvas to create advanced graphics.
Advanced html5 diving into the canvas tagDavid Voyles
The document discusses the HTML5 <canvas> element, which allows for dynamic drawing directly onto the webpage. Some key points:
- The <canvas> element is a 2D drawing surface that works within modern browsers without plugins. It can be used for graphics, games, charts, and more.
- Common uses of the <canvas> include drawing shapes, text, images and applying transformations like scaling, rotation and translation.
- The <canvas> uses a JavaScript API and context to draw onto the element programmatically rather than with CSS. Common methods include fillRect(), strokeRect(), beginPath() and more.
- Gradients, images, and text can all be rendered onto the
The document discusses the user interface capabilities in MIDP, including custom items which allow custom rendering and input handling, and the canvas API which provides low-level graphics and event handling capabilities. It describes the key methods and features of custom items and the canvas, such as painting, sizing, and handling input events from touchscreens and keyboards. Examples are provided and future topics are outlined.
The document summarizes the author's experience learning the Processing programming language. It describes some key challenges, such as Processing using the new Java language. The author overcame these challenges by exploring tutorials on the Processing website. The author then explains the process of learning Processing, which involved installing the software, learning to draw basic shapes and colors, and using functions like "setup()" and "draw()" to create animations. As an example, the author designed an interactive mouse sketch that tracks the mouse position and draws colored rectangles to demonstrate their learning.
Computer Graphics in Java and Scala - Part 1bPhilip Schwarz
First see the Scala program from Part 1 translated into Java.
Then see the Scala program modified to produce a more intricate drawing.
Java Code: https://github.com/philipschwarz/computer-graphics-50-triangles-java
Scala Code: https://github.com/philipschwarz/computer-graphics-chessboard-with-a-great-many-squares-scala
This document discusses HTML canvas drawing and animation. It covers topics like getting a canvas reference, the canvas API, drawing shapes and text, applying transformations, using paths, gradients and patterns, handling events, and animating canvas content using requestAnimationFrame. The document provides details on various canvas methods, properties, and techniques for 2D drawing and basic animation.
This document is a project report submitted by Naresh Kumar, a class 11 student, on programming in C++ under the guidance of his teacher Mr. Sunil Kumar. It includes the source code for a game involving a car avoiding obstacles, an output screen, bibliography, and remarks. The source code uses classes like car, obstacle, and timer to create, move, and time the car as it navigates obstacles on the screen.
The Android framework APIs provides a set 2D drawing APIs that allow you to render your own custom graphics onto a canvas or to modify existing Views to customize their look and feel. When drawing 2D graphics, you'll typically do so in one of two ways Draw your graphics or animations into a View object from your layout or Draw your graphics directly to a Canvas. In this unit we are going to explore about how to draw graphics directly into a canvas.
The document provides an overview of JavaFX, a platform for building rich internet applications. It discusses JavaFX's scripting language, graphical elements like text, shapes and images, effects, user interactions, and animation capabilities. Transitions and keyframe animation are described as two approaches for animating nodes over time in JavaFX applications. Examples are given for common tasks like handling events, dragging objects, and animating property changes.
Raphaël is a JavaScript library for working with vector graphics on the web. It allows developers to use SVG, VML, or Canvas to draw and animate graphics in browsers. The library provides a simple API for creating common shapes like circles, rectangles, paths, and text. It also supports animating the attributes of these elements over time. Raphaël aims to make complex vector graphics simple and accessible to work with using JavaScript.
The document provides information about using the canvas API to draw graphics on an HTML5 canvas element. It covers topics such as drawing shapes, paths, images, text, applying styles, transformations, gradients and saving state. Code examples are provided to demonstrate how to use various canvas drawing methods and properties.
The document discusses HTML5 Canvas. It covers basic usage of the canvas element, how to draw shapes, use images, apply styles and colors, transformations, compositing, and basic animations. It also discusses optimizing the canvas and checking for browser support of the canvas element.
This is the winner proposal of the Sismo Challenge programming contest organized by ibuildings.
Reference: http://techportal.ibuildings.com/2012/04/17/sismo-challenge-results/
The document provides an overview of the HTML5 <canvas> element and how it can be used to draw graphics on a web page. Some key points:
- The <canvas> element is used to draw graphics programmatically using JavaScript. It acts as a container for graphics.
- Canvas has methods for drawing paths, boxes, circles, text and images. To draw, you first get a 2D drawing context from the canvas element, then use drawing methods like fillRect(), strokeText(), etc.
- The canvas uses a 2D grid with (0,0) at the top-left. Shapes can be filled or stroked. Gradients and shadows can also be used.
-
The document discusses HTML canvas and how to draw graphics on a canvas using JavaScript. It covers how to create a canvas element, get the rendering context, and use various drawing methods like fillRect(), strokeRect(), beginPath(), moveTo(), lineTo(), bezierCurveTo(), quadraticCurveTo() etc. to draw shapes, paths, images and text. It also discusses how to apply colors, gradients, patterns and shadows. The canvas state can be saved and restored using save() and restore() methods. Translations and rotations can be applied using translate() and rotate() methods.
The document discusses the Canvas element in HTML5 which allows dynamic rendering of 2D shapes and images in the browser using JavaScript. It provides basic context methods for drawing rectangles, strokes, gradients and images to the canvas. It also demonstrates how to add event listeners and animate drawings on the canvas.
The document provides an introduction to Processing, an open-source programming language and environment used for creating visuals and animations. It covers downloading and installing Processing, using the Processing Development Environment, setting the canvas size and coordinates, drawing basic shapes using code, adding color, using variables, loops and conditionals to create animations, and provides examples and resources for learning more.
The HTML5 canvas element allows drawing directly onto the page via JavaScript. It provides pixel-level control for creating animations, games, charts, and more. The canvas is drawn upon by using a drawing context object and its methods like fillRect(), stroke(), arc(), and fillText(). Gradients, patterns, and images can also be rendered onto the canvas to create advanced graphics.
Advanced html5 diving into the canvas tagDavid Voyles
The document discusses the HTML5 <canvas> element, which allows for dynamic drawing directly onto the webpage. Some key points:
- The <canvas> element is a 2D drawing surface that works within modern browsers without plugins. It can be used for graphics, games, charts, and more.
- Common uses of the <canvas> include drawing shapes, text, images and applying transformations like scaling, rotation and translation.
- The <canvas> uses a JavaScript API and context to draw onto the element programmatically rather than with CSS. Common methods include fillRect(), strokeRect(), beginPath() and more.
- Gradients, images, and text can all be rendered onto the
The document discusses the user interface capabilities in MIDP, including custom items which allow custom rendering and input handling, and the canvas API which provides low-level graphics and event handling capabilities. It describes the key methods and features of custom items and the canvas, such as painting, sizing, and handling input events from touchscreens and keyboards. Examples are provided and future topics are outlined.
The document summarizes the author's experience learning the Processing programming language. It describes some key challenges, such as Processing using the new Java language. The author overcame these challenges by exploring tutorials on the Processing website. The author then explains the process of learning Processing, which involved installing the software, learning to draw basic shapes and colors, and using functions like "setup()" and "draw()" to create animations. As an example, the author designed an interactive mouse sketch that tracks the mouse position and draws colored rectangles to demonstrate their learning.
Computer Graphics in Java and Scala - Part 1bPhilip Schwarz
First see the Scala program from Part 1 translated into Java.
Then see the Scala program modified to produce a more intricate drawing.
Java Code: https://github.com/philipschwarz/computer-graphics-50-triangles-java
Scala Code: https://github.com/philipschwarz/computer-graphics-chessboard-with-a-great-many-squares-scala
This document discusses HTML canvas drawing and animation. It covers topics like getting a canvas reference, the canvas API, drawing shapes and text, applying transformations, using paths, gradients and patterns, handling events, and animating canvas content using requestAnimationFrame. The document provides details on various canvas methods, properties, and techniques for 2D drawing and basic animation.
This document is a project report submitted by Naresh Kumar, a class 11 student, on programming in C++ under the guidance of his teacher Mr. Sunil Kumar. It includes the source code for a game involving a car avoiding obstacles, an output screen, bibliography, and remarks. The source code uses classes like car, obstacle, and timer to create, move, and time the car as it navigates obstacles on the screen.
The Android framework APIs provides a set 2D drawing APIs that allow you to render your own custom graphics onto a canvas or to modify existing Views to customize their look and feel. When drawing 2D graphics, you'll typically do so in one of two ways Draw your graphics or animations into a View object from your layout or Draw your graphics directly to a Canvas. In this unit we are going to explore about how to draw graphics directly into a canvas.
The document provides an overview of JavaFX, a platform for building rich internet applications. It discusses JavaFX's scripting language, graphical elements like text, shapes and images, effects, user interactions, and animation capabilities. Transitions and keyframe animation are described as two approaches for animating nodes over time in JavaFX applications. Examples are given for common tasks like handling events, dragging objects, and animating property changes.
Raphaël is a JavaScript library for working with vector graphics on the web. It allows developers to use SVG, VML, or Canvas to draw and animate graphics in browsers. The library provides a simple API for creating common shapes like circles, rectangles, paths, and text. It also supports animating the attributes of these elements over time. Raphaël aims to make complex vector graphics simple and accessible to work with using JavaScript.
The document provides information about using the canvas API to draw graphics on an HTML5 canvas element. It covers topics such as drawing shapes, paths, images, text, applying styles, transformations, gradients and saving state. Code examples are provided to demonstrate how to use various canvas drawing methods and properties.
The document discusses HTML5 Canvas. It covers basic usage of the canvas element, how to draw shapes, use images, apply styles and colors, transformations, compositing, and basic animations. It also discusses optimizing the canvas and checking for browser support of the canvas element.
This is the winner proposal of the Sismo Challenge programming contest organized by ibuildings.
Reference: http://techportal.ibuildings.com/2012/04/17/sismo-challenge-results/
Similar to S'il te plait, dessine moi une vue (20)
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Sinan KOZAK
Sinan from the Delivery Hero mobile infrastructure engineering team shares a deep dive into performance acceleration with Gradle build cache optimizations. Sinan shares their journey into solving complex build-cache problems that affect Gradle builds. By understanding the challenges and solutions found in our journey, we aim to demonstrate the possibilities for faster builds. The case study reveals how overlapping outputs and cache misconfigurations led to significant increases in build times, especially as the project scaled up with numerous modules using Paparazzi tests. The journey from diagnosing to defeating cache issues offers invaluable lessons on maintaining cache integrity without sacrificing functionality.
Introduction- e - waste – definition - sources of e-waste– hazardous substances in e-waste - effects of e-waste on environment and human health- need for e-waste management– e-waste handling rules - waste minimization techniques for managing e-waste – recycling of e-waste - disposal treatment methods of e- waste – mechanism of extraction of precious metal from leaching solution-global Scenario of E-waste – E-waste in India- case studies.
Understanding Inductive Bias in Machine LearningSUTEJAS
This presentation explores the concept of inductive bias in machine learning. It explains how algorithms come with built-in assumptions and preferences that guide the learning process. You'll learn about the different types of inductive bias and how they can impact the performance and generalizability of machine learning models.
The presentation also covers the positive and negative aspects of inductive bias, along with strategies for mitigating potential drawbacks. We'll explore examples of how bias manifests in algorithms like neural networks and decision trees.
By understanding inductive bias, you can gain valuable insights into how machine learning models work and make informed decisions when building and deploying them.
International Conference on NLP, Artificial Intelligence, Machine Learning an...gerogepatton
International Conference on NLP, Artificial Intelligence, Machine Learning and Applications (NLAIM 2024) offers a premier global platform for exchanging insights and findings in the theory, methodology, and applications of NLP, Artificial Intelligence, Machine Learning, and their applications. The conference seeks substantial contributions across all key domains of NLP, Artificial Intelligence, Machine Learning, and their practical applications, aiming to foster both theoretical advancements and real-world implementations. With a focus on facilitating collaboration between researchers and practitioners from academia and industry, the conference serves as a nexus for sharing the latest developments in the field.
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...University of Maribor
Slides from talk presenting:
Aleš Zamuda: Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapter and Networking.
Presentation at IcETRAN 2024 session:
"Inter-Society Networking Panel GRSS/MTT-S/CIS
Panel Session: Promoting Connection and Cooperation"
IEEE Slovenia GRSS
IEEE Serbia and Montenegro MTT-S
IEEE Slovenia CIS
11TH INTERNATIONAL CONFERENCE ON ELECTRICAL, ELECTRONIC AND COMPUTING ENGINEERING
3-6 June 2024, Niš, Serbia
Advanced control scheme of doubly fed induction generator for wind turbine us...IJECEIAES
This paper describes a speed control device for generating electrical energy on an electricity network based on the doubly fed induction generator (DFIG) used for wind power conversion systems. At first, a double-fed induction generator model was constructed. A control law is formulated to govern the flow of energy between the stator of a DFIG and the energy network using three types of controllers: proportional integral (PI), sliding mode controller (SMC) and second order sliding mode controller (SOSMC). Their different results in terms of power reference tracking, reaction to unexpected speed fluctuations, sensitivity to perturbations, and resilience against machine parameter alterations are compared. MATLAB/Simulink was used to conduct the simulations for the preceding study. Multiple simulations have shown very satisfying results, and the investigations demonstrate the efficacy and power-enhancing capabilities of the suggested control system.
6. One day, on my twitter…
“
@florent_champ can you teach me how to draw a custom view ?
7. @florent_champ please teach me how to draw a custom view ?
@florent_champ I saw a video on youtube, a man became rich by building
it own app, and displaying ads $$$$$
8. @florent_champ I need to draw custom views, but I don’t know where to start
@florent_champ Please !!!!!!! Please !!!!!!! Please !!!!!!!
9. K3v1n :
FORTNIGHT <3 <3
Love to code on Windows
Learn Android, want to become billionaire with an
Android app displaying ads
$
$
$
HTML is its favorite programming language
22. Paint
The Paint class holds the style and color
information about how to draw geometries,
text and bitmaps.
https://developer.android.com/reference/android/graphics/Paint
23. PAINT - Style
FILL
FILL AND
STROKE
STROKE
paint.setStyle(FILL)
paint.setStyle(STROKE)
paint.setStyle(FILL_AND_STROKE)
28. Canvas
The Canvas class holds the "draw" calls. To draw something, you
need 4 basic components: A Bitmap to hold the pixels, a Canvas to
host the draw calls (writing into the bitmap), a drawing primitive (e.g.
Rect, Path, text, Bitmap), and a paint (to describe the colors and
styles for the drawing).
https://developer.android.com/reference/android/graphics/Canvas
29. val paint = Paint().apply{
color = Color.WHITE
}
fun onDraw(canvas: Canvas) {
canvas.drawRect(0, 0, 30, 10, paint)
}
Draw a Rect
30
10
30. val paint = Paint().apply{
color = Color.WHITE
}
fun onDraw(canvas: Canvas) {
canvas.drawRect(0, 0, 30, 10, paint)
}
Draw a Rect
30
10
Values in pixels !
31. Draw a Rect
30
10
val myRect = Rect()
fun onSizeChanged(width:Int, height: Int,
oldWidth: Int, oldHeight: Int) {
myRect.right = width
myRect.bottom = height
}
fun onDraw(canvas: Canvas) {
canvas.drawRect(myRect, paint)
}
32. Draw a Circle
canvas.drawCircle(cx: float, cy: float, radius: float, paint: Paint)
fun onDraw(canvas: Canvas) {
canvas.drawCircle(100, 100, 15, paint)
}
30
15
33. Draw a Line
canvas.drawLine(startX: float, startY: float, endX: float,
endY: float, paint: Paint)
fun onDraw(canvas: Canvas) {
canvas.drawLine(0, 30, 100, 50, paint)
}
0,30
100,50
34. Draw a Line
init {
paint.setStrokeWidth(10)
paint.setStrokeCap(ROUND)
}
fun onDraw(canvas: Canvas) {
canvas.drawLine(0, 30, 100, 50, paint)
}
0,30
100,50
35. Draw a Custom Shape
val path = Path()
fun onSizeChanged(width:Int, height: Int,
oldWidth: Int, oldHeight: Int) {
path.reset()
path.move(0,0)
path.lineTo(width, height)
path.lineTo(0, height)
path.close()
}
fun onDraw(canvas: Canvas) {
canvas.drawPath(path, paint)
}
Width
height
65. StaticLayout
StaticLayout is a Layout for text that will not be edited after it is laid
out. Use DynamicLayout for text that may change.
This is used by widgets to control text layout. You should not need to
use this class directly unless you are implementing your own widget
or custom display object, or would be tempted to call
Canvas.drawText() directly.
https://developer.android.com/reference/android/text/StaticLayout
74. “For 90% of cases, you will need a
custom shape, so let’s see what we can
do with Path?“
“
75. Path
The Path class encapsulates compound (multiple contour) geometric
paths consisting of straight line segments, quadratic curves, and
cubic curves. It can be drawn with canvas.drawPath(path, paint),
either filled or stroked (based on the paint's Style), or it can be used
for clipping or to draw text on a path.
https://developer.android.com/reference/android/graphics/Path
76. Draw a Custom Shape
var path = Path()
fun onSizeChanged(width:Int, height: Int,
oldWidth: Int, oldHeight: Int) {
path.reset()
path.move(0,0)
path.lineTo(width, height)
path.lineTo(0, height)
path.close()
}
fun onDraw(canvas: Canvas) {
canvas.drawPath(path, paint)
}
Width
height
77. Draw a Custom Shape
var path = Path()
fun onSizeChanged(width:Int, height: Int,
oldWidth: Int, oldHeight: Int) {
path.reset()
path.move(0,0)
path.lineTo(width, height)
path.lineTo(0, height)
path.close()
}
fun onDraw(canvas: Canvas) {
canvas.drawPath(path, paint)
}
Width
height
78. Draw a Custom Shape
var path = Path()
fun onSizeChanged(width:Int, height: Int,
oldWidth: Int, oldHeight: Int) {
path.reset()
path.move(0,0)
path.lineTo(width, height)
path.lineTo(0, height)
path.close()
}
fun onDraw(canvas: Canvas) {
canvas.drawPath(path, paint)
}
Width
height
79. Draw a Custom Shape
var path = Path()
fun onSizeChanged(width:Int, height: Int,
oldWidth: Int, oldHeight: Int) {
path.reset()
path.move(0,0)
path.lineTo(width, height)
path.lineTo(0, height)
path.close()
}
fun onDraw(canvas: Canvas) {
canvas.drawPath(path, paint)
}
Width
height
80. Draw a Custom Shape
var path = Path()
fun onSizeChanged(width:Int, height: Int,
oldWidth: Int, oldHeight: Int) {
path.reset()
path.move(0,0)
path.lineTo(width, height)
path.lineTo(0, height)
path.close()
}
fun onDraw(canvas: Canvas) {
canvas.drawPath(path, paint)
}
Width
height
81. Draw a Custom Shape
var path = Path()
fun onSizeChanged(width:Int, height: Int,
oldWidth: Int, oldHeight: Int) {
path.reset()
path.move(0,0)
path.lineTo(width, height)
path.lineTo(0, height)
path.close()
}
fun onDraw(canvas: Canvas) {
canvas.drawPath(path, paint)
}
Width
height
109. class Arc(val startAngle: Float, val finalAngle: Float, val color: Int) {
val rect = RectF()
val radius = 200f
var currentAngle = 5f
}
Animations
110. class Arc(val startAngle: Float, val finalAngle: Float, val color: Int) {
val rect = RectF()
val radius = 200f
var currentAngle = 5f
}
Animations
StartAngle
FinalAngle
Color
Radius
111. class Arc(…) {
…
fun setup(parentWidth: Int, parentHeight: Int){
val centerX = parentWidth/2f
val centerY = parentHeight / 2f
rect.set(centerX - radius, centerY - radius,
centerX + radius, centerY + radius)
}
Animations
Radius
+
112. class Arc(…) {
…
fun onDraw(paint: Paint, canvas: Canvas){
paint.color = color //update current drawing color
canvas.drawArc(rect, -90f, angleToDraw, false, paint)
}
}
Animations
-90
125. Gesture
Example : click on a rect
- event.action is ActionDown
- next event.action is ActionUp
- difference touch X/Y is small
- delay is > 200ms
- the rect contains the point X/Y
Override View.onTouch(motionEvent)