MCPcopy Create free account
hub / github.com/facebook/chisel / _showColor

Function _showColor

commands/FBVisualizationCommands.py:80–115  ·  view source on GitHub ↗
(color)

Source from the content-addressed store, hash-verified

78
79
80def _showColor(color):
81 color = "(" + color + ")"
82
83 colorToUse = color
84 isCF = _colorIsCGColorRef(color)
85 if isCF:
86 colorToUse = "[[UIColor alloc] initWithCGColor:(CGColorRef){}]".format(color)
87 else:
88 isCI = objectHelpers.isKindOfClass(color, "CIColor")
89 if isCI:
90 colorToUse = "[UIColor colorWithCIColor:(CIColor *){}]".format(color)
91
92 imageSize = 58
93 fb.evaluateEffect(
94 "UIGraphicsBeginImageContextWithOptions((CGSize)CGSizeMake({imageSize}, {imageSize}), NO, 0.0)".format(
95 imageSize=imageSize
96 )
97 )
98 fb.evaluateEffect("[(id){} setFill]".format(colorToUse))
99 fb.evaluateEffect(
100 "UIRectFill((CGRect)CGRectMake(0.0, 0.0, {imageSize}, {imageSize}))".format(
101 imageSize=imageSize
102 )
103 )
104
105 result = fb.evaluateExpressionValue(
106 "(UIImage *)UIGraphicsGetImageFromCurrentImageContext()"
107 )
108 if result.GetError() is not None and str(result.GetError()) != "success":
109 print("got error {}".format(result))
110 print(result.GetError())
111 else:
112 image = result.GetValue()
113 _showImage(image)
114
115 fb.evaluateEffect("UIGraphicsEndImageContext()")
116
117
118def _showLayer(layer):

Callers 1

_visualizeFunction · 0.85

Calls 2

_colorIsCGColorRefFunction · 0.85
_showImageFunction · 0.85

Tested by

no test coverage detected