@@ -63,6 +63,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
6363 private var mCurrBrushSize = 0f
6464 private var mAllowMovingZooming = true
6565 private var mIsEraserOn = false
66+ private var mRelativeBrushSize = true
6667 private var mIsBucketFillOn = false
6768 private var mWasMultitouch = false
6869 private var mIgnoreTouches = false
@@ -291,13 +292,21 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
291292
292293 fun setBrushSize (newBrushSize : Float ) {
293294 mCurrBrushSize = newBrushSize
294- mPaintOptions.strokeWidth = resources.getDimension(R .dimen.full_brush_size) * (mCurrBrushSize / mScaleFactor / 100f )
295+ mPaintOptions.strokeWidth = resources.getDimension(R .dimen.full_brush_size) * (mCurrBrushSize / 100f )
296+ if (mRelativeBrushSize) {
297+ mPaintOptions.strokeWidth / = mScaleFactor
298+ }
295299 }
296300
297301 fun setAllowZooming (allowZooming : Boolean ) {
298302 mAllowMovingZooming = allowZooming
299303 }
300304
305+ fun setRelativeBrushSize (relativeBrushSize : Boolean ) {
306+ mRelativeBrushSize = relativeBrushSize
307+ setBrushSize(mCurrBrushSize)
308+ }
309+
301310 fun getBitmap (): Bitmap {
302311 val bitmap = Bitmap .createBitmap(width, height, Bitmap .Config .ARGB_8888 )
303312 val canvas = Canvas (bitmap)
0 commit comments