SKShapeNode fillColor values above 1.0 and below 0.0 are wrapped and not clamped

Originator:paul.neave
Number:rdar://31581040 Date Originated:12 Apr 2017
Status:Open Resolved:
Product:iOS + SDK Product Version:
Classification:SpriteKit Reproducible:Yes
 
Area:
SpriteKit

Summary:
UIColor can now accept ranges above 1.0 and below 0.0 to represent the Display P3 wide color space. But in SKShapeNode's fillColor, these ranges are not interpreted correctly, instead wrapping the values rather than clamping them.

Steps to Reproduce:
In the following example the fillColor's red value is set to 1.2:

let frame = CGRect(x: 0, y: 0, width: 200, height: 200)
let scene = SKScene(size: frame.size)
let node = SKShapeNode(circleOfRadius: 100)
node.position = CGPoint(x: 100, y: 100)
node.fillColor = UIColor(red: 1.2, green: 0, blue: 0, alpha: 1)
scene.addChild(node)

let view = SKView(frame: frame)
view.presentScene(scene)


Expected Results:
The node should should show a circle with a red fill clamped to it's maximum value, which for sRGB is 1.0, or the maximum allowed in the Display P3 color space.

Actual Results:
Instead, fillColor wraps the red value (1.2) to 0.2. The same applies for values below zero.

Version:
10.3.1 (14E304)

Notes:


Configuration:
iPhone 7

Attachments:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!