Skip to content

Commit

Permalink
Fix color
Browse files Browse the repository at this point in the history
  • Loading branch information
SpectralDragon committed Jun 14, 2024
1 parent 5b0f852 commit df0a86c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Sources/AdaEditor/UI/EditorWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class EditorWindow: UIWindow {
let blueView = UIView(frame: Rect(origin: Point(x: 0, y: 0), size: Size(width: 50, height: 50)))
blueView.backgroundColor = .blue

let redView = UIView(frame: Rect(origin: Point(x: 100, y: 0), size: Size(width: 50, height: 50)))
let redView = UIView(frame: Rect(origin: Point(x: 100, y: 50), size: Size(width: 50, height: 50)))
// redView.zIndex = 1
redView.backgroundColor = .red

Expand All @@ -27,9 +27,9 @@ class EditorWindow: UIWindow {
override func draw(in rect: Rect, with context: GUIRenderContext) {
print("Did render", rect)

var count = Int(rect.width / 50)
var count = Int(rect.width / 100)

var x: Float = 0
var x: Float = rect.minX

for i in 0..<count {
context.drawRect(.init(x: x, y: 50, width: 50, height: 50), color: Color.random())
Expand Down
4 changes: 3 additions & 1 deletion Sources/AdaEngine/Utils/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Created by v.prusakov on 11/4/21.
//

import Math

/// A representation of a color that adapts to a given context.
public struct Color: Codable, Hashable {

Expand Down Expand Up @@ -67,7 +69,7 @@ public extension Color {

static let clear = Color(red: 1, green: 1, blue: 1, alpha: 0)

func random() -> Color {
static func random() -> Color {
Color(
red: Float.random(in: 0...255) / 255,
green: Float.random(in: 0...255) / 255,
Expand Down

0 comments on commit df0a86c

Please sign in to comment.