Skip to content

Conversation

@HPezz
Copy link
Contributor

@HPezz HPezz commented Dec 22, 2023

  • πŸ§‘β€πŸ’» (RobotKit): Extend UIColor with toHsv() function
  • ♻️ (RobotKit): Update Robot.Color to future Gradient struct
  • ✨ (RobotKit): Add Robot.Gradient struct
  • πŸ› (GEK): Add reinforcer duration
  • ♻️ (GEK): Refactor Pairing breathe animation with Gradient

@HPezz HPezz requested a review from ladislas December 22, 2023 10:19
@HPezz HPezz self-assigned this Dec 22, 2023
@HPezz HPezz force-pushed the hugo/feature/Add-Gradient-class branch 2 times, most recently from 2e6c295 to 908d583 Compare January 11, 2024 19:14
@HPezz HPezz force-pushed the hugo/feature/Add-Gradient-class branch from 908d583 to 450a2c8 Compare January 11, 2024 19:33
@sonarqubecloud
Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@ladislas ladislas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM πŸ‘ quelques questions techniques :)

Comment on lines +48 to +64
public var robotUiColor: UIColor {
UIColor(
red: Double(self.robotRGB[0]) / 255.0,
green: Double(self.robotRGB[1]) / 255.0,
blue: Double(self.robotRGB[2]) / 255.0,
alpha: 1.0
)
}

public var screenUiColor: UIColor {
UIColor(
red: Double(self.screenRGB[0]) / 255.0,
green: Double(self.screenRGB[1]) / 255.0,
blue: Double(self.screenRGB[2]) / 255.0,
alpha: 1.0
)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pourquoi tu as besoin de passer par UIColor? pourquoi pas une simple struct?

Comment on lines +21 to +46
public func color(at position: Float) -> Robot.Color {
let positionClamped = max(min(position, 1), 0)

let scaledIndex = positionClamped * Float(self.gradientColors.count - 1)
let firstIndex = Int(scaledIndex)
let secondIndex = min(firstIndex + 1, gradientColors.count - 1)
let fraction = CGFloat(scaledIndex - Float(firstIndex))

let firstColor = self.gradientColors[firstIndex]
let secondColor = self.gradientColors[secondIndex]

let (h1, s1, v1) = firstColor.robotUiColor.toHSV()
let (h2, s2, v2) = secondColor.robotUiColor.toHSV()

let h = self.interpolateHue(from: h1, to: h2, fraction: fraction)
let s = self.interpolate(from: s1, to: s2, fraction: fraction)
let v = self.interpolate(from: v1, to: v2, fraction: fraction)

let uiColor = UIColor(hue: h, saturation: s, brightness: v, alpha: 1)

let r = UInt8(max(min(uiColor.cgColor.components![0] * 255.0, 255), 0))
let g = UInt8(max(min(uiColor.cgColor.components![1] * 255.0, 255), 0))
let b = UInt8(max(min(uiColor.cgColor.components![2] * 255.0, 255), 0))

return Robot.Color(red: r, green: g, blue: b)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

par curiositΓ©, cette formule elle vient d'oΓΉ? c'est intΓ©ressant de mettre en commentaire la source de l'explication scientifique/mathΓ©matiques du calcul

Comment on lines +15 to +17
public init(fromColors colors: Color...) {
self.gradientColors = colors
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j'ai un "petit" soucis avec Γ§a : c'est que si tu mets + de 2 couleurs, tu pars du principe qu'elles sont toutes Γ©quidistante les unes des autres.

dans Illustrator, tu peux faire varier la distance entre 2 couleurs.

dans notre cas Γ§a peut Γͺtre trΓ¨s pratique pour "accΓ©lΓ©rer/raccourcir" les zones dans lesquelles les variations sont faibles (ou faiblement perΓ§ues) et "ralentir/allonger" des zones oΓΉ la variation est plus importante

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

une manière simple est d'avoir un autre init qui te permet d'associer couleur et position

Comment on lines +48 to +64
public var robotUiColor: UIColor {
UIColor(
red: Double(self.robotRGB[0]) / 255.0,
green: Double(self.robotRGB[1]) / 255.0,
blue: Double(self.robotRGB[2]) / 255.0,
alpha: 1.0
)
}

public var screenUiColor: UIColor {
UIColor(
red: Double(self.screenRGB[0]) / 255.0,
green: Double(self.screenRGB[1]) / 255.0,
blue: Double(self.screenRGB[2]) / 255.0,
alpha: 1.0
)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public var robotUiColor: UIColor {
UIColor(
red: Double(self.robotRGB[0]) / 255.0,
green: Double(self.robotRGB[1]) / 255.0,
blue: Double(self.robotRGB[2]) / 255.0,
alpha: 1.0
)
}
public var screenUiColor: UIColor {
UIColor(
red: Double(self.screenRGB[0]) / 255.0,
green: Double(self.screenRGB[1]) / 255.0,
blue: Double(self.screenRGB[2]) / 255.0,
alpha: 1.0
)
}
public var robotUIColor: UIColor {
UIColor(
red: Double(self.robotRGB[0]) / 255.0,
green: Double(self.robotRGB[1]) / 255.0,
blue: Double(self.robotRGB[2]) / 255.0,
alpha: 1.0
)
}
public var screenUIColor: UIColor {
UIColor(
red: Double(self.screenRGB[0]) / 255.0,
green: Double(self.screenRGB[1]) / 255.0,
blue: Double(self.screenRGB[2]) / 255.0,
alpha: 1.0
)
}

@ladislas ladislas force-pushed the main branch 2 times, most recently from 1d4a80e to a25305d Compare April 18, 2024 13:28
@ladislas ladislas changed the base branch from main to develop September 26, 2024 13:26
@ladislas ladislas marked this pull request as draft September 26, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants