Skip to content
A library for more easy work with the android canvas
Branch: dev
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A library for more easy work with the android canvas

License: MIT CodeFactor Android Arsenal Dependabot Status JitPack

Branches stastus

master Build Status codecov

dev Build Status codecov


Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			maven { url '' }

Add the dependency

dependencies {
	        implementation 'com.github.schoolhelper:androidgraphextension:v1.2.0'

Graphextension include following kotlin extension methods

Module has the following extension methods for path (

with library without library
path.moveTo(pointF) path.moveTo(pointF.x, pointF.y)
path.moveTo(point) path.moveTo(point.x.toFloat(), point.y.toFloat())
path.moveTo(xIntValue, yIntValue) path.moveTo(xIntValue.toFloat(), yIntValue.toFloat()
path.lineTo(pointF) path.lineTo(pointF.x, pointF.y)
path.lineTo(point) path.lineTo(point.x.toFloat(), point.y.toFloat())
path.lineTo(xIntValue, yIntValue) path.lineTo(xIntValue.toFloat(), yIntValue.toFloat()
path.setLastPoint(pointF) path.setLastPoint(pointF.x, pointF.y)
path.setLastPoint(point) path.setLastPoint(point.x.toFloat(), point.y.toFloat())
path.setLastPoint(xIntValue, yIntValue) path.setLastPoint(xIntValue.toFloat(), yIntValue.toFloat()
path.offset(pointF) path.offset(pointF.x, pointF.y)
path.offset(point) path.offset(point.x.toFloat(), point.y.toFloat())
path.offset(xIntValue, yIntValue) path.offset(xIntValue.toFloat(), yIntValue.toFloat()
path.addRect(pointF1, pointF2) path.addRect(pointF1.x, pointF1.y, pointF2.x, pointF2.y)
path.addRect(point1, point2) path.addRect(point1.x.toFloat(), point1.y.toFloat(), point2.x.toFloat(), point2.y.toFloat())
path.addRect(leftInt, topInt, rightInt, bottomInt) path.addRect(leftInt.toFloat(), topInt.toFloat(), rightInt.toFloat(), bottomInt.toFloat())
path.quadTo(controlPointF, pointF) path.quadTo(controlPointF.x, controlPointF.y, pointF.x, pointF.y)

Module has the following operators for Point( and PointF (

  • unaryMinus val point = -somePoint
  • minus pointA - pointB
  • plus pointA + pointB
  • times point * Double
  • times point * Float
  • times point * Int
  • div point / Double
  • div point / Float
  • div point / Int

Module has the following extension methods for the Point(, PointF ( and MotionEvent(android.view.MotionEvent):

  • distanceTo(MotionEvent)
  • distanceTo(Point)
  • distanceTo(PointF)
  • distanceTo(Int, Int)
  • distanceTo(Float, Float)
  • distanceTo(Double, Double)

Module has following operators for the Rect(

  • Rect.contains(event: MotionEvent) : Boolean
  • Rect.contains(Float, Float) : Boolean
  • Rect.contains(Double, Double)
  • Rect.contains(Point) : Boolean
  • Rect.contains(PointF) : Boolean
  • Rect.contains(RectF) : Boolean
  • Rect.getCenter() : PointF
  • Rect.isNotEmpty : Boolean

Module has following operators for the RectF(

  • RectF.contains(MotionEvent) : Boolean
  • RectF.contains(Float, Float) : Boolean
  • RectF.contains(Double, Double)
  • RectF.contains(Point) : Boolean
  • RectF.contains(PointF) : Boolean
  • RectF.contains(Rect) : Boolean
  • RectF.getCenter() : PointF
  • RectF.isNotEmpty : Boolean

Easy make Quad Path

val samplePoints = listOf<PointF>() // list must be init
val path = samplePoints.toQuadPath()
canvas.drawPath(path, paint)

Apachextension module include following kotlin extension methods

Module has following variables for work with numbers (this variable use FastMath)

  • Float.sqr
  • Double.sqr

Module has following variables for Vector2D:

  • Vector2D(PointF, PointF) : Vector2D
  • Vector2D(Point, Point) : Vector2D
  • Vector2D.safeNormalize : Vector2D
  • Vector2D.makeNormalVector : Vector2D


Easy make point base on event

view.setOnTouchListener { v, event ->
	val point = PointF(event)
	return@setOnTouchListener true

Easy times for point

val point = PointF(5F, 5F)
val scaleUpPoint = point * 5
val scaleDownPoint = point / 5


Point -> PointF

val point = Point(5, 5)

PointF -> Point

val pointF = PointF(5F, 5F)


Easy add point to path

val point1 = PointF(2, 2)
val point2 = PointF(4, 4)
val point3 = PointF(6, 6)
val path = Path()



./gradlew uploadArchives -PNEXUS_USERNAME=$NEXUS_USERNAME -PNEXUS_PASSWORD=$NEXUS_PASSWORD -Psigning.secretKeyRingFile=../secring.gpg -Psigning.keyId=$keyId -Psigning.password=$password
You can’t perform that action at this time.