Skip to content

Commit

Permalink
Add VAlignAsString and HAlignAsString serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
jobe-m committed Aug 9, 2024
1 parent f7e1888 commit 74cafc3
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ object HorizontalAlignAsDouble : KSerializer<HorizontalAlign> {
override fun serialize(encoder: Encoder, value: HorizontalAlign) = encoder.encodeDouble(value.ratio)
override fun deserialize(decoder: Decoder): HorizontalAlign = HorizontalAlign(decoder.decodeDouble())
}
object HAlignAsString : KSerializer<HorizontalAlign> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("HAlignAsString", PrimitiveKind.STRING)
override fun serialize(encoder: Encoder, value: HorizontalAlign) = encoder.encodeString(value.toString())
override fun deserialize(decoder: Decoder): HorizontalAlign = HorizontalAlign(decoder.decodeString())
}

/**
* A serializer strategy for Korge [VerticalAlign] type. The alignment ratio will be saved as double.
Expand All @@ -217,6 +222,11 @@ object VerticalAlignAsDouble : KSerializer<VerticalAlign> {
override fun serialize(encoder: Encoder, value: VerticalAlign) = encoder.encodeDouble(value.ratio)
override fun deserialize(decoder: Decoder): VerticalAlign = VerticalAlign(decoder.decodeDouble())
}
object VAlignAsString : KSerializer<VerticalAlign> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("VAlignAsString", PrimitiveKind.STRING)
override fun serialize(encoder: Encoder, value: VerticalAlign) = encoder.encodeString(value.toString())
override fun deserialize(decoder: Decoder): VerticalAlign = VerticalAlign(decoder.decodeString())
}

/**
* A serializer strategy for Korge [RGBA] type. The color value is saved as integer number.
Expand Down

0 comments on commit 74cafc3

Please sign in to comment.