Skip to content

Commit

Permalink
Remove Bitmap.toPath[s] and Path.divide
Browse files Browse the repository at this point in the history
We now rely on the APIs provided by the pathway library.
  • Loading branch information
romainguy committed Dec 2, 2022
1 parent 6805a95 commit c1d0e0c
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 534 deletions.
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ flow the text content around its children.
- Arbitrary shapes (any `Path`)
- Justification
- Hyphenation
- Generate shapes from images
- Path division (extract multiple contours as a list of paths)
- Compatible with API 29+

## Design Systems
Expand Down Expand Up @@ -106,8 +104,9 @@ TextFlow(
}
```

Using the extension `Bitmap.toPath` provided by this library, a shape can be extracted from a
bitmap and used as the flow shape for the desired child:
The non-rectangular `Path` shape is created using the extension `Bitmap.toPath` from the
[pathway](https://github.com/romainguy/pathway) library. Using that API, a shape can be extracted
from a bitmap and used as the flow shape for the desired child:

![Flow around non-rectangular shapes](art/screenshot_arbitrary_shapes.png)

Expand All @@ -117,9 +116,9 @@ the example below, both justification and hyphenation are enabled:
![Justification and hyphenation](art/screenshot_styles_and_justification.png)

You can also specify multiple shapes for any given element by using the `flowShapes` modifiers
instead of `flowShape`. `flowShapes` accepts/returns list of paths instead of a single path. You
can easily extract a list of paths from a `Bitmap` by using `Bitmap.toPaths()` instead of
`Bitmap.toPath()`. For instance:
instead of `flowShape`. `flowShapes` accepts/returns list of paths instead of a single path.
For instance, with [pathway](https://github.com/romainguy/pathway) you can easily extract a list of
paths from a `Bitmap` by using `Bitmap.toPaths()` instead of `Bitmap.toPath()`.

```kotlin
val heartsShapes = heartsBitmap.toPaths().map { it.asComposePath() }
Expand All @@ -139,7 +138,7 @@ TextFlow(
}
```

The division operation create many shapes around which the text can flow:
This creates many shapes around which the text can flow:

![Multiple shapes per element](art/screenshot_shapes.png)

Expand All @@ -153,10 +152,10 @@ repositories {
dependencies {
// Use this library and BasicTextFlow() if you don't want a dependency on material3
implementation 'dev.romainguy:combo-breaker:0.7.0'
implementation 'dev.romainguy:combo-breaker:0.8.0'
// Use this library and TextFlow() if you use material3
implementation 'dev.romainguy:combo-breaker-material3:0.7.0'
implementation 'dev.romainguy:combo-breaker-material3:0.8.0'
}
```

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
}

plugins {
id 'com.android.application' version '8.0.0-alpha08' apply false
id 'com.android.library' version '8.0.0-alpha08' apply false
id 'com.android.application' version '8.0.0-alpha09' apply false
id 'com.android.library' version '8.0.0-alpha09' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
}
2 changes: 2 additions & 0 deletions combo-breaker-demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose:1.6.1'

implementation 'dev.romainguy:pathway:0.9.0'

implementation project(path: ':combo-breaker-material3')
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ import dev.romainguy.text.combobreaker.TextFlowHyphenation
import dev.romainguy.text.combobreaker.TextFlowJustification
import dev.romainguy.text.combobreaker.demo.ui.theme.ComboBreakerTheme
import dev.romainguy.text.combobreaker.material3.TextFlow
import dev.romainguy.text.combobreaker.toPath
import dev.romainguy.text.combobreaker.toPaths
import dev.romainguy.graphics.path.toPath
import dev.romainguy.graphics.path.toPaths

class ComboBreakerActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
2 changes: 0 additions & 2 deletions combo-breaker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ dependencies {
implementation platform("androidx.compose:compose-bom:$compose_bom")
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.material3:material3'

implementation 'dev.romainguy:pathway:0.8.0'
}

apply plugin: 'com.vanniktech.maven.publish'

This file was deleted.

Loading

0 comments on commit c1d0e0c

Please sign in to comment.