Fixed the hex color visibility.
This commit is contained in:
@@ -11,7 +11,7 @@ import Foundation
|
|||||||
|
|
||||||
extension MTColor {
|
extension MTColor {
|
||||||
|
|
||||||
static func color(fromHexString hexString:String) -> MTColor? {
|
public convenience init?(fromHexString hexString:String) {
|
||||||
if hexString.isEmpty { return nil }
|
if hexString.isEmpty { return nil }
|
||||||
if !hexString.hasPrefix("#") { return nil }
|
if !hexString.hasPrefix("#") { return nil }
|
||||||
|
|
||||||
@@ -19,10 +19,10 @@ extension MTColor {
|
|||||||
let scanner = Scanner(string: hexString)
|
let scanner = Scanner(string: hexString)
|
||||||
scanner.charactersToBeSkipped = CharacterSet(charactersIn: "#")
|
scanner.charactersToBeSkipped = CharacterSet(charactersIn: "#")
|
||||||
scanner.scanHexInt64(&rgbValue)
|
scanner.scanHexInt64(&rgbValue)
|
||||||
return MTColor(red: CGFloat((rgbValue & 0xFF0000) >> 16)/255.0,
|
self.init(red: CGFloat((rgbValue & 0xFF0000) >> 16)/255.0,
|
||||||
green: CGFloat((rgbValue & 0xFF00) >> 8)/255.0,
|
green: CGFloat((rgbValue & 0xFF00) >> 8)/255.0,
|
||||||
blue: CGFloat((rgbValue & 0xFF))/255.0,
|
blue: CGFloat((rgbValue & 0xFF))/255.0,
|
||||||
alpha: 1.0)
|
alpha: 1.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -502,7 +502,7 @@ class MTTypesetter {
|
|||||||
}
|
}
|
||||||
let colorAtom = atom as! MTMathColor
|
let colorAtom = atom as! MTMathColor
|
||||||
let display = MTTypesetter.createLineForMathList(colorAtom.innerList, font: font, style: style)
|
let display = MTTypesetter.createLineForMathList(colorAtom.innerList, font: font, style: style)
|
||||||
display!.localTextColor = MTColor.color(fromHexString: colorAtom.colorString)
|
display!.localTextColor = MTColor(fromHexString: colorAtom.colorString)
|
||||||
display!.position = currentPosition
|
display!.position = currentPosition
|
||||||
currentPosition.x += display!.width
|
currentPosition.x += display!.width
|
||||||
displayAtoms.append(display!)
|
displayAtoms.append(display!)
|
||||||
@@ -515,7 +515,7 @@ class MTTypesetter {
|
|||||||
let colorboxAtom = atom as! MTMathColorbox
|
let colorboxAtom = atom as! MTMathColorbox
|
||||||
let display = MTTypesetter.createLineForMathList(colorboxAtom.innerList, font:font, style:style)
|
let display = MTTypesetter.createLineForMathList(colorboxAtom.innerList, font:font, style:style)
|
||||||
|
|
||||||
display!.localBackgroundColor = MTColor.color(fromHexString: colorboxAtom.colorString)
|
display!.localBackgroundColor = MTColor(fromHexString: colorboxAtom.colorString)
|
||||||
display!.position = currentPosition
|
display!.position = currentPosition
|
||||||
currentPosition.x += display!.width;
|
currentPosition.x += display!.width;
|
||||||
displayAtoms.append(display!)
|
displayAtoms.append(display!)
|
||||||
|
|||||||
Reference in New Issue
Block a user