diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 526b4c2..a2d7c21 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -13,7 +13,6 @@
-
diff --git a/app/src/main/java/com/example/acapendulum20/canvas/Canvas.kt b/app/src/main/java/com/example/acapendulum20/canvas/Canvas.kt
deleted file mode 100644
index fd50bc2..0000000
--- a/app/src/main/java/com/example/acapendulum20/canvas/Canvas.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.example.acapendulum20.canvas
-
-import android.content.Context
-import android.graphics.Canvas
-import android.graphics.Paint
-import android.util.AttributeSet
-import android.view.View
-
-class CanvasView @JvmOverloads constructor(
- context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
-) : View(context, attrs, defStyleAttr) {
-
-
- val paint: Paint = Paint()
-
- override fun onDraw(canvas: Canvas?) {
- super.onDraw(canvas)
-
- paint.strokeWidth = 9f
- canvas?.drawLine(455f,0f,500f, 630f,paint)
-
- }
- fun drawBob(canvas: Canvas?) {
- paint.style = Paint.Style.STROKE
- paint.strokeWidth = 10f
- canvas?.drawCircle(500f, 700f, 70f, paint)
- }
-
- fun drawBob() {
- println("hallo")
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/acapendulum20/canvas/CanvasPendulum.kt b/app/src/main/java/com/example/acapendulum20/canvas/CanvasPendulum.kt
new file mode 100644
index 0000000..2f96c26
--- /dev/null
+++ b/app/src/main/java/com/example/acapendulum20/canvas/CanvasPendulum.kt
@@ -0,0 +1,61 @@
+package com.example.acapendulum20.canvas
+
+import android.content.Context
+import android.graphics.Canvas
+import android.graphics.Paint
+import android.util.AttributeSet
+import android.view.View
+
+class CanvasPendulum @JvmOverloads constructor(
+ context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
+) : View(context, attrs, defStyleAttr) {
+
+
+ val paint: Paint = Paint()
+ lateinit var canvas: Canvas
+
+ override fun onDraw(canvas: Canvas?) {
+ super.onDraw(canvas)
+
+ //if canvas not NULL then this canvas = it
+ canvas?.let {
+ this.canvas = it
+ }
+
+ }
+
+ fun drawPendulum() {
+ paint.style = Paint.Style.STROKE
+ paint.strokeWidth = 10f
+ canvas.drawCircle(500f, 700f, 70f, paint)
+ paint.strokeWidth = 9f
+ canvas.drawLine(455f,0f,500f, 630f,paint)
+ }
+
+ fun stopDrawingPendulum() {
+ canvas.drawCircle(400f, 300f, 70f, paint)
+ }
+
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+/**/
\ No newline at end of file
diff --git a/app/src/main/java/com/example/acapendulum20/fragments/pendulum/PendulumFragment.kt b/app/src/main/java/com/example/acapendulum20/fragments/pendulum/PendulumFragment.kt
index c447f0c..63598db 100644
--- a/app/src/main/java/com/example/acapendulum20/fragments/pendulum/PendulumFragment.kt
+++ b/app/src/main/java/com/example/acapendulum20/fragments/pendulum/PendulumFragment.kt
@@ -1,42 +1,70 @@
package com.example.acapendulum20.fragments.pendulum
-import android.content.Context
-import android.graphics.*
-import android.graphics.drawable.Drawable
+import android.graphics.Canvas
import android.os.Bundle
-import android.util.AttributeSet
import android.view.LayoutInflater
+import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
-import android.widget.ImageView
-import androidx.core.content.res.ResourcesCompat
+import android.widget.Button
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
-import androidx.navigation.fragment.findNavController
import com.example.acapendulum20.R
-import com.example.acapendulum20.canvas.CanvasView
-import com.example.acapendulum20.viewmodel.UserViewmodel
-import kotlinx.android.synthetic.main.fragment_pendulum.*
+import com.example.acapendulum20.canvas.CanvasPendulum
+import com.google.android.material.canvas.CanvasCompat
import kotlinx.android.synthetic.main.fragment_pendulum.view.*
-import kotlinx.android.synthetic.main.fragment_update.view.*
class PendulumFragment : Fragment() {
- private lateinit var mCanvasView: CanvasView
-
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val view = inflater.inflate(R.layout.fragment_pendulum, container, false)
+ val mCanvasPendulum: CanvasPendulum
+ mCanvasPendulum = view.findViewById(R.id.canvasContainer)!!
//activate the magnet
- view.activate_btn.setOnClickListener{
- mCanvasView.drawBob()
+ val button = view.findViewById