@@ -17,7 +17,6 @@ import com.onyx.android.sdk.pen.NeoCharcoalPenV2
1717import com.onyx.android.sdk.pen.NeoMarkerPen
1818import com.onyx.android.sdk.pen.NeoFountainPen
1919import com.onyx.android.sdk.pen.NeoPen
20- import com.onyx.android.sdk.pen.style.StrokeStyle
2120import com.onyx.android.sdk.api.device.epd.EpdController
2221import io.flutter.plugin.platform.PlatformView
2322import io.flutter.plugin.common.MethodChannel
@@ -47,7 +46,45 @@ internal class OnyxsdkPenArea(context: Context, messenger: BinaryMessenger, id:
4746 var strokeStyle = StrokeStyle .FountainPen
4847
4948 private fun updateStroke (paramsRef : Map <String , Any >? ) {
50- strokeColor = paramsRef?.get(" strokeColor" ) as ? Int ? : Color .BLACK
49+ /*
50+ Flutter ints are variable width
51+ Personally, I think it is utterly dumb. I hope there is a way to fix
52+ int size in flutter (why would you need 64 bits to store srgb??),
53+ but unless or until there isn't, this stupidity should be performed
54+ */
55+ val pureColor = (paramsRef?.get(" strokeColor" ) as ? Long )?.toInt()
56+ ? : paramsRef?.get(" strokeColor" ) as ? Int
57+ ? : Color .BLACK
58+ /*
59+ ONYXSDK Pen saturates the colors. Whatever it deems as "light" (luma < 128?)
60+ gets automagically turned to white. Transparency is also accounted apparently.
61+ Unless this is some case-by-case situation, if resulting color, assuming
62+ being drawn on absolutely white background, with a fully opaque brush
63+ is lighter than a certain unknown arbitrary threshold, it turns white,
64+ otherwise, is saturated to max.
65+ These thoughts are, however, purely observational. Nothing in documentation
66+ says this and no binary artifacts have been decompiled to come to these
67+ conclusions. Thus, feel free to correct my incompetence if I turn out wrong
68+ */
69+ var dest = FloatArray (3 )
70+ Color .RGBToHSV (
71+ Color .red(pureColor),
72+ Color .green(pureColor),
73+ Color .blue(pureColor),
74+ dest
75+ )
76+ dest[1 ] = 1.0f /* saturation */
77+ /*
78+ I suppose rounding value is reasonable, but I want color to show
79+ So clamp to black if it's visually indistinguishable from black
80+ and to colorful otherwise. E.g. brown will look red instead of black
81+ */
82+ if (dest[2 ] < 0.2 ) {
83+ dest[2 ] = 0.0f
84+ } else {
85+ dest[2 ] = 1.0f
86+ }
87+ strokeColor = Color .HSVToColor (dest)
5188 strokeWidth = (paramsRef?.get(" strokeWidth" ) as ? Double ? : 3.0 ).toFloat()
5289 strokeStyle = when (paramsRef?.get(" strokeStyle" ) as ? Int ? : 0 ) {
5390 0 -> StrokeStyle .FountainPen
@@ -149,9 +186,9 @@ internal class OnyxsdkPenArea(context: Context, messenger: BinaryMessenger, id:
149186 private fun strokeStyleToOnyx (style : StrokeStyle ): Int {
150187 return when (style) {
151188 StrokeStyle .FountainPen -> TouchHelper .STROKE_STYLE_FOUNTAIN
152- StrokeStyle .Pen -> TouchHelper .STROKE_STYLE_CHARCOAL_V2
189+ StrokeStyle .Pen -> TouchHelper .STROKE_STYLE_PENCIL
153190 StrokeStyle .Brush -> TouchHelper .STROKE_STYLE_NEO_BRUSH
154- StrokeStyle .Pencil -> TouchHelper .STROKE_STYLE_PENCIL
191+ StrokeStyle .Pencil -> TouchHelper .STROKE_STYLE_CHARCOAL_V2
155192 StrokeStyle .Marker -> TouchHelper .STROKE_STYLE_MARKER
156193 }
157194 }
0 commit comments