Skip to content

Commit

Permalink
Merge pull request #101 from Ark-Kit/refactor/canvas-method
Browse files Browse the repository at this point in the history
[ark-render] refactor: use more general canvas return type
  • Loading branch information
markusyeo authored Apr 21, 2024
2 parents 11f0840 + bb3dd6f commit f07fdbf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ArkKit/ark-render-kit/CanvasContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ protocol CanvasContext<View> {
var arkView: (any ArkView<View>)? { get }
var memo: [EntityID: [RenderableComponentType: (any RenderableComponent, any Renderable)]] { get }

func getFlatCanvas() -> ArkFlatCanvas
func getFlatCanvas() -> any Canvas
func render(_ canvas: any Canvas, using renderer: any RenderableBuilder<View>)
}

Expand Down Expand Up @@ -62,7 +62,7 @@ class ArkCanvasContext<View>: CanvasContext {
}

/// Outputs a logical canvas with the relevant entities in the canvas and their renderable components only
func getFlatCanvas() -> ArkFlatCanvas {
func getFlatCanvas() -> any Canvas {
var arkCanvas = ArkFlatCanvas()
for renderableCompType in ArkCanvasSystem.renderableComponentTypes {
let renderableEntities = ecs.getEntities(with: [renderableCompType])
Expand Down
3 changes: 3 additions & 0 deletions ArkKit/ark-render-kit/canvas/Canvas.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ protocol Canvas {
typealias RenderableComponentType = ObjectIdentifier
typealias CanvasElements = [EntityID: [RenderableComponentType: any RenderableComponent]]
var canvasElements: CanvasElements { get }
mutating func addEntityRenderableToCanvas(entityId: EntityID,
componentType: RenderableComponentType,
renderableComponent: any RenderableComponent)
}

0 comments on commit f07fdbf

Please sign in to comment.