-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2017382
commit 92ede16
Showing
5 changed files
with
108 additions
and
74 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/kylecorry/trail_sense/tools/augmented_reality/ARMarker.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,12 @@ | ||
package com.kylecorry.trail_sense.tools.augmented_reality | ||
|
||
import com.kylecorry.andromeda.canvas.ICanvasDrawer | ||
import com.kylecorry.trail_sense.shared.canvas.PixelCircle | ||
|
||
interface ARMarker { | ||
fun draw(drawer: ICanvasDrawer, anchor: PixelCircle) | ||
fun getAngularDiameter(view: AugmentedRealityView): Float | ||
fun getHorizonCoordinate(view: AugmentedRealityView): AugmentedRealityView.HorizonCoordinate | ||
fun onFocused(): Boolean | ||
fun onClick(): Boolean | ||
} |
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
36 changes: 36 additions & 0 deletions
36
app/src/main/java/com/kylecorry/trail_sense/tools/augmented_reality/CanvasObject.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,36 @@ | ||
package com.kylecorry.trail_sense.tools.augmented_reality | ||
|
||
import android.graphics.Color | ||
import androidx.annotation.ColorInt | ||
import com.kylecorry.andromeda.canvas.ICanvasDrawer | ||
import com.kylecorry.trail_sense.shared.canvas.PixelCircle | ||
|
||
interface CanvasObject { | ||
// TODO: Use a pixel region instead of a circle | ||
fun draw(drawer: ICanvasDrawer, area: PixelCircle) | ||
} | ||
|
||
class CircleCanvasObject( | ||
@ColorInt | ||
private val color: Int, | ||
@ColorInt | ||
private val strokeColor: Int? = null, | ||
private val opacity: Int = 255, | ||
private val strokeWeight: Float = 0.5f, | ||
) : CanvasObject { | ||
override fun draw(drawer: ICanvasDrawer, area: PixelCircle) { | ||
val size = area.radius * 2f | ||
drawer.noTint() | ||
if (strokeColor != null && strokeColor != Color.TRANSPARENT) { | ||
drawer.stroke(strokeColor) | ||
drawer.strokeWeight(drawer.dp(strokeWeight)) | ||
} else { | ||
drawer.noStroke() | ||
} | ||
if (color != Color.TRANSPARENT) { | ||
drawer.fill(color) | ||
drawer.opacity(opacity) | ||
drawer.circle(area.center.x, area.center.y, size) | ||
} | ||
} | ||
} |