You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- adding metadata to ensure the extension displays correctly in LiveCode
@@ -211,7 +213,7 @@ public handler getColor() returns String
211
213
if mColor is nothing then
212
214
return ""
213
215
else
214
-
return colorToString(mColor)
216
+
return colorToString(mColor, true)
215
217
end if
216
218
end handler
217
219
----------
@@ -227,62 +229,6 @@ public handler getPaint(pType) returns Paint
227
229
228
230
return solid paint with stringToColor("255,100,200")
229
231
end handler
230
-
----------
231
-
232
-
233
-
----------
234
-
-- this handler converts a string of numbers to an RGBA color
235
-
private handler stringToColor(in pString as String) returns Color
236
-
variable tRed as Real
237
-
variable tGreen as Real
238
-
variable tBlue as Real
239
-
variable tAlpha as Real
240
-
241
-
variable tComponentList as List
242
-
split pString by "," into tComponentList
243
-
244
-
variable tComponentCount
245
-
put the number of elements in tComponentList into tComponentCount
246
-
if tComponentCount is not 3 and tComponentCount is not 4 then
247
-
// Invalid number of components detected
248
-
throw "Invalid color"
249
-
end if
250
-
251
-
put (element 1 of tComponentList) parsed as number into tRed
252
-
put (element 2 of tComponentList) parsed as number into tGreen
253
-
put (element 3 of tComponentList) parsed as number into tBlue
254
-
255
-
if tComponentCount is 4 then
256
-
put (element 4 of tComponentList) parsed as number into tAlpha
257
-
else
258
-
put 255 into tAlpha
259
-
end if
260
232
261
-
return color [ tRed/255, tGreen/255, tBlue/255, tAlpha/255 ]
262
-
end handler
263
-
----------
264
-
265
-
----------
266
-
-- this handler converts an RGBA color to a string
267
-
private handler colorToString(in pColor as Color) returns String
268
-
return stripZeros((the rounded of ((the red of pColor) * 255)) formatted as string) & "," & stripZeros((the rounded of ((the green of pColor) * 255)) formatted as string) & "," & stripZeros((the rounded of ((the blue of pColor) * 255)) formatted as string) & "," & stripZeros((the rounded of ((the alpha of pColor) * 255)) formatted as string)
269
-
end handler
270
-
----------
271
-
272
-
-- this handler strips the zeros when an integer is formatted as a string
273
-
private handler stripZeros(in pString as String) returns String
274
-
if pString contains "." then
275
-
repeat while ((the last char of pString) is in ".0")
0 commit comments