Skip to content

Commit 96a1b61

Browse files
GoodNotesCIGoodNotesCI
authored andcommitted
Set transparency for outher color
1 parent 3561a34 commit 96a1b61

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Source/Parser/SVG/SVGParserBasics.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ extension SVGHelper {
127127
let x = Array(cleanedHexString)
128128
cleanedHexString = "\(x[0])\(x[0])\(x[1])\(x[1])\(x[2])\(x[2])"
129129
}
130-
return SVGColor(hex: cleanedHexString)
130+
return SVGColor(hex: cleanedHexString).opacity(1.0)
131131
}
132132

133133
static func parseRGBANotation(colorString: String) -> SVGColor {
@@ -142,8 +142,8 @@ extension SVGHelper {
142142
var red = 0.0
143143
var green = 0.0
144144
var blue = 0.0
145-
var alpha = 1.0 // Default to fully opaque
146-
if x.count == 3 {
145+
var alpha = 1.0 // Default to fully opaque, always from 0 to 1 in CSS
146+
if x.count <= 3 {
147147
if let r = Double(x[0]), let g = Double(x[1]), let b = Double(x[2]) {
148148
blue = b
149149
green = g
@@ -157,11 +157,11 @@ extension SVGHelper {
157157
red *= 2.55
158158
green *= 2.55
159159
blue *= 2.55
160-
if x.count == 4, let a = Double(x[3]) {
161-
alpha *= 2.55
160+
if x.count == 4 {
161+
alpha *= 0.01
162162
}
163163
}
164-
return SVGColor(r: Int(round(red)), g: Int(round(green)), b: Int(round(blue)))
164+
return SVGColor(r: Int(round(red)), g: Int(round(green)), b: Int(round(blue))).opacity(round(alpha))
165165
}
166166

167167
static private func parseIdFromUrl(_ urlString: String) -> String? {

0 commit comments

Comments
 (0)