0.3.0 #23

Open
altavir wants to merge 40 commits from dev into main
4 changed files with 19 additions and 8 deletions
Showing only changes of commit c30f586120 - Show all commits

View File

@ -3,6 +3,7 @@
## Unreleased ## Unreleased
### Added ### Added
- `alpha` extension for feature attribute builder
### Changed ### Changed
@ -11,6 +12,7 @@
### Removed ### Removed
### Fixed ### Fixed
- Add alpha attribute comprehension for all standard features.
### Security ### Security

View File

@ -9,7 +9,7 @@ val kmathVersion: String by extra("0.4.0")
allprojects { allprojects {
group = "space.kscience" group = "space.kscience"
version = "0.3.0" version = "0.3.1-dev"
repositories { repositories {
mavenLocal() mavenLocal()

View File

@ -29,7 +29,8 @@ public fun <T : Any> FeatureDrawScope<T>.drawFeature(
is CircleFeature -> drawCircle( is CircleFeature -> drawCircle(
color, color,
feature.radius.toPx(), feature.radius.toPx(),
center = feature.center.toOffset() center = feature.center.toOffset(),
alpha = alpha
) )
is RectangleFeature -> drawRect( is RectangleFeature -> drawRect(
@ -38,7 +39,8 @@ public fun <T : Any> FeatureDrawScope<T>.drawFeature(
feature.size.width.toPx() / 2, feature.size.width.toPx() / 2,
feature.size.height.toPx() / 2 feature.size.height.toPx() / 2
), ),
size = feature.size.toSize() size = feature.size.toSize(),
alpha = alpha
) )
is LineFeature -> drawLine( is LineFeature -> drawLine(
@ -46,7 +48,8 @@ public fun <T : Any> FeatureDrawScope<T>.drawFeature(
feature.a.toOffset(), feature.a.toOffset(),
feature.b.toOffset(), feature.b.toOffset(),
strokeWidth = feature.attributes[StrokeAttribute] ?: Stroke.HairlineWidth, strokeWidth = feature.attributes[StrokeAttribute] ?: Stroke.HairlineWidth,
pathEffect = feature.attributes[PathEffectAttribute] pathEffect = feature.attributes[PathEffectAttribute],
alpha = alpha
) )
is ArcFeature -> { is ArcFeature -> {
@ -67,14 +70,14 @@ public fun <T : Any> FeatureDrawScope<T>.drawFeature(
} }
is BitmapIconFeature -> drawImage(feature.image, feature.center.toOffset()) is BitmapIconFeature -> drawImage(feature.image, feature.center.toOffset(), alpha = alpha)
is VectorIconFeature -> { is VectorIconFeature -> {
val offset = feature.center.toOffset() val offset = feature.center.toOffset()
val size = feature.size.toSize() val size = feature.size.toSize()
translate(offset.x - size.width / 2, offset.y - size.height / 2) { translate(offset.x - size.width / 2, offset.y - size.height / 2) {
with(this@drawFeature.painterFor(feature)) { with(this@drawFeature.painterFor(feature)) {
draw(size, colorFilter = feature.color?.let { ColorFilter.tint(it) }) draw(size, colorFilter = feature.color?.let { ColorFilter.tint(it) }, alpha = alpha)
} }
} }
} }
@ -152,7 +155,7 @@ public fun <T : Any> FeatureDrawScope<T>.drawFeature(
translate(offset.x, offset.y) { translate(offset.x, offset.y) {
with(this@drawFeature.painterFor(feature)) { with(this@drawFeature.painterFor(feature)) {
draw(rect.size) draw(rect.size, alpha = alpha)
} }
} }
} }
@ -175,7 +178,8 @@ public fun <T : Any> FeatureDrawScope<T>.drawFeature(
x = i * xStep, x = i * xStep,
y = rect.height - j * yStep y = rect.height - j * yStep
), ),
size = pixelSize size = pixelSize,
alpha = alpha
) )
} }
} }

View File

@ -46,6 +46,11 @@ public fun <T : Any, F : Feature<T>> FeatureRef<T, F>.zoomRange(range: FloatRang
public object AlphaAttribute : Attribute<Float> public object AlphaAttribute : Attribute<Float>
public fun <T : Any, F : Feature<T>> FeatureRef<T, F>.alpha(alpha: Float): FeatureRef<T, F> {
require(alpha in 0f..1f) { "Alpha value must be between 0 and 1" }
return modifyAttribute(AlphaAttribute, alpha)
}
public fun <T : Any, F : Feature<T>> FeatureRef<T, F>.modifyAttributes( public fun <T : Any, F : Feature<T>> FeatureRef<T, F>.modifyAttributes(
modification: AttributesBuilder<F>.() -> Unit, modification: AttributesBuilder<F>.() -> Unit,
): FeatureRef<T, F> { ): FeatureRef<T, F> {