-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: button bindingAdapter로 isSelected 생성 * feat: 선택된 버튼 색깔 생성 * feat: 브러쉬 요소 추가 * feat: 브러쉬 선택 기능 UI 추가 * feat: 함수 일부 네이밍 변경 및 Circle, Rectangle 그리기 기능 추가 * refactor: 함수 분리 및 중복 코드 삭제 * feat: 지우개 기능 구현 * refactor: Drawing 클래스에서 Path, Paint 복사하도록 수정 * feat: 전체 삭제, undo, redo 구현 * refactor: 함수 순서 수정 * refactor: SettingState sealed class -> enum class로 변경, 상수 위치 이동 * refactor: width로 굵기 네이밍 통일 * refactor: Brush -> Tool로 네이밍 변경 * refactor: enum class 상수 네이밍 변경 * refactor: Drawing 클래스 세분화 * refactor: tool이 drawing 객체를 리턴하도록 수정 * refactor: CanvasView가 하던 일을 Drawing 클래스로 이동 * refactor: undo, redo 코드 줄 수 줄이기 * design: 도구에 따른 설정 화면 변경 * refactor: 도구에 따라 버튼 동적 생성 * refactor: brushes -> tools로 네이밍 수정 * refactor: 함수명 수정 * refactor: tool 바꿀 때 설정창 닫도록 수정 * fix: Rectangle 버그 수정 * refactor: 도구 모음 일치 * refactor: tool -> drawingTool로 네이밍 변경 * refactor: Drawings 일급컬렉션 생성 * refactor: 팩토리 함수 삭제
- Loading branch information
Showing
23 changed files
with
438 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.android") | ||
id("kotlin-kapt") | ||
} | ||
|
||
android { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
package woowacourse.paint | ||
|
||
sealed class PaintChangingState { | ||
object Nothing : PaintChangingState() | ||
object ColorChanging : PaintChangingState() | ||
object WidthChanging : PaintChangingState() | ||
enum class PaintChangingState { | ||
NOTHING, COLOR_CHANGING, WIDTH_CHANGING | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package woowacourse.paint.canvas | ||
|
||
import android.graphics.Paint | ||
import woowacourse.paint.canvas.drawing.Circle | ||
import woowacourse.paint.canvas.drawing.Drawing | ||
import woowacourse.paint.canvas.drawing.Line | ||
import woowacourse.paint.canvas.drawing.Rectangle | ||
|
||
enum class DrawingTool(val hasWidth: Boolean, val hasColor: Boolean) { | ||
PEN(true, true) { | ||
override fun draw(paint: Paint, invalidate: () -> Unit): Drawing = | ||
Line(paint, invalidate) | ||
}, | ||
RECTANGLE(false, true) { | ||
override fun draw(paint: Paint, invalidate: () -> Unit): Drawing = | ||
Rectangle(paint, invalidate) | ||
}, | ||
CIRCLE(false, true) { | ||
override fun draw(paint: Paint, invalidate: () -> Unit): Drawing = | ||
Circle(paint, invalidate) | ||
}, | ||
ERASER(true, false) { | ||
override fun draw(paint: Paint, invalidate: () -> Unit): Drawing = | ||
Line(paint, invalidate) | ||
}, ; | ||
|
||
abstract fun draw(paint: Paint, invalidate: () -> Unit): Drawing | ||
} |
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
app/src/main/java/woowacourse/paint/canvas/drawing/Circle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package woowacourse.paint.canvas.drawing | ||
|
||
import android.graphics.Paint | ||
import android.graphics.Path | ||
import android.view.MotionEvent | ||
import woowacourse.paint.canvas.Point | ||
|
||
class Circle(paint: Paint, private val invalidate: () -> Unit) : | ||
Drawing(Paint(paint)) { | ||
private lateinit var startPoint: Point | ||
|
||
override fun onTouchEvent(event: MotionEvent): Boolean { | ||
val x = event.x | ||
val y = event.y | ||
|
||
when (event.action) { | ||
MotionEvent.ACTION_DOWN -> startPoint = Point(x, y) | ||
MotionEvent.ACTION_MOVE -> { | ||
path.reset() | ||
path.addOval(startPoint.x, startPoint.y, x, y, Path.Direction.CW) | ||
invalidate() | ||
} | ||
|
||
else -> return true | ||
} | ||
return true | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/woowacourse/paint/canvas/drawing/Drawing.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package woowacourse.paint.canvas.drawing | ||
|
||
import android.graphics.Canvas | ||
import android.graphics.Paint | ||
import android.graphics.Path | ||
import android.view.MotionEvent | ||
|
||
abstract class Drawing(val paint: Paint) { | ||
val path = Path() | ||
fun onDraw(canvas: Canvas) { | ||
canvas.drawPath(path, paint) | ||
} | ||
|
||
abstract fun onTouchEvent(event: MotionEvent): Boolean | ||
} |
Oops, something went wrong.