Skip to content

Write phase 3 articles#8

Open
MartinBozhilov-coh wants to merge 10 commits into
content-creation-guidefrom
write-phase-3
Open

Write phase 3 articles#8
MartinBozhilov-coh wants to merge 10 commits into
content-creation-guidefrom
write-phase-3

Conversation

@MartinBozhilov-coh
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@alien1976 alien1976 left a comment

Choose a reason for hiding this comment

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

Part 1

Comment on lines +2 to +4
title: Alternative Frameworks
description: Learn about alternative frameworks that you can use to build your Gameface projects.
sidebar:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
title: Alternative Frameworks
description: Learn about alternative frameworks that you can use to build your Gameface projects.
sidebar:
title: Alternative Frameworks
draft: true
description: Learn about alternative frameworks that you can use to build your Gameface projects.
sidebar:


Gameface's internal layout engine is highly optimized and incredibly fast. However, the environment it runs in is extremely demanding. If a game targets 60 frames per second, the entire game engine has exactly <Highlight>16.6 milliseconds</Highlight> to render a single frame. The UI is usually allocated only a tiny fraction of that time (often 1-2ms).

In a standard web browser, a 15ms layout recalculation goes completely unnoticed. In a game engine, it blows your entire frame budget. To ensure your UI runs at peak performance and leaves plenty of CPU room for the game itself, we need to architect our layouts following a few core rules.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe? :D Using architect is fine but for me is kind of weird when reading the text. You can also use build, develop or other word.

Suggested change
In a standard web browser, a 15ms layout recalculation goes completely unnoticed. In a game engine, it blows your entire frame budget. To ensure your UI runs at peak performance and leaves plenty of CPU room for the game itself, we need to architect our layouts following a few core rules.
In a standard web browser, a 15ms layout recalculation goes completely unnoticed. In a game engine, it blows your entire frame budget. To ensure your UI runs at peak performance and leaves plenty of CPU room for the game itself, we need to design our layouts following a few core rules.


## High-Performance Layout Rules

Before we look at the screen structure, here are the practical "Do's and Don'ts" for styling your elements in Gameface.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
Before we look at the screen structure, here are the practical "Do's and Don'ts" for styling your elements in Gameface.
Before we look at the screen structure, here are the practical "Good" and "Bad" practices for styling your elements in Gameface.


Before we look at the screen structure, here are the practical "Do's and Don'ts" for styling your elements in Gameface.

### Define explicit dimensions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For the next headings you can add badges for "Good" and "Bad" or add X and checkmark emojis so the reader knows which is bad and which is good before starting to read the section.

For example:

Suggested change
### Define explicit dimensions
### [Good badge/checkmark icon] Define explicit dimensions

or

Suggested change
### Define explicit dimensions
### Define explicit dimensions [Good badge/checkmark icon]


Try to use `align-items: center` or `flex-start` and rely on explicit dimensions instead.

:::danger[Default property]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

IMO this should be marked as caution and not danger


This algorithm can only be used inside `<p>` elements and is enabled by adding the special `cohinline` attribute.

Here is how you use `cohinline` to resolve the issuue mentioned above:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
Here is how you use `cohinline` to resolve the issuue mentioned above:
Here is how you use `cohinline` to resolve the issue mentioned above:


However, `cohinline` handles vertical space differently than a web browser, which often leads to misaligned icons if you aren't expecting it.

### The Problem: Ignored Image Heights
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
### The Problem: Ignored Image Heights
### Image heights are ignored


![](../../../../assets/phase-3/text-and-fonts/vertical-align-wrong.png)

### The Solution: Explicit Line Heights
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
### The Solution: Explicit Line Heights
### Setting explicit line heights to fit the image

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I am suggesting these changes because personally I don't like the The problem and The solution texts :D

Comment on lines +151 to +161
**Actionable Rule:** Always explicitly define a base `font-size` on the element that is as close to the expected final rendering size as possible. This minimizes the iterations required by the engine's calculation loop.

```css title="optimized-fit.css" ins="font-size: 24px;"
.button-text {
coh-font-fit-mode: shrink;
coh-font-fit-min-size: 14px;

/* Providing a starting point near the expected final size minimizes calculation overhead */
font-size: 24px;
}
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Make this aside. For example tip


## The Asset Format Problem

In a browser prototype, it is common to pick an image format based mainly on visual quality and file size. In a gameface UI, that decision also affects how much work the UI layer performs during layout, rendering, and invalidation.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I am confused about the In a gameface UI what exactly means? Is it the Gameface UI or not? :D

Maybe just In Gameface is enough?


### Practical Format Rules

For most Gameface UI work, the format decision can be made with a few direct rules:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
For most Gameface UI work, the format decision can be made with a few direct rules:
Making a decision which format fits the best for your UI in Gameface you can follow these rules:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Or something else but different from the original text because it does not make sense written in that way.

* Use **JPEG** only when the asset does not need transparency and compression artifacts are acceptable, such as some large background images (although the use case is very rare).

:::caution[SVG Usage Gotcha]
Avoid converting complex painted art into SVG only to make it scalable. If the SVG contains many paths, the visual flexibility may not justify the rendering cost
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
Avoid converting complex painted art into SVG only to make it scalable. If the SVG contains many paths, the visual flexibility may not justify the rendering cost
Avoid converting complex painted art into SVG only to make it scalable. If the SVG contains many paths, the visual flexibility may not justify the rendering cost.


#### `<img>` element

Use when the SVG is meaningful to the content or needs to participate in layout like an image. For example, as a button with an Xbox A glyph icon.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use when the SVG is meaningful to the content - what does this mean? :D


#### CSS `background-image`

Use when the SVG is purely decorative and part of the component's styles. For example, a panel frame with a border.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe we can simplify both sections here for the external SVGs. Instead of explaining the differences between img and background-image, we can just list both as valid approaches. The only strict rule we need to highlight is that external SVGs are for graphics that won't be manipulated at runtime, regardless of how they are used.


Changing `viewBox` on a complex SVG can still trigger redraw work. This is usually appropriate for controlled interactions, such as opening a map
screen or dragging a minimap, but you should avoid unnecessary **per-frame** updates on very large SVG maps. If the SVG contains many moving paths,
labels, and decorative layers, <Highlight>profile the interaction in the target UI</Highlight>.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe? Or something similar? profile the interaction in the target UI is kind of weird for me :D

Suggested change
labels, and decorative layers, <Highlight>profile the interaction in the target UI</Highlight>.
labels, and decorative layers, <Highlight>make sure to profile the performance of the UI</Highlight>.

Comment on lines +380 to +382
rules (`opacity: 1; transform: translateY(0)`). Because a `transition` is declared on both properties, the engine

<Highlight>interpolates between them</Highlight>, producing a smooth fade and slide with no JavaScript animation code.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
rules (`opacity: 1; transform: translateY(0)`). Because a `transition` is declared on both properties, the engine
<Highlight>interpolates between them</Highlight>, producing a smooth fade and slide with no JavaScript animation code.
rules (`opacity: 1; transform: translateY(0)`). Because a `transition` is declared on both properties, the engine <Highlight>interpolates between them</Highlight>, producing a smooth fade and slide with no JavaScript animation code.

Comment on lines +435 to +438
:::caution[Other Limitations]

- `@starting-style` does not work with out-of-line SVGs.
- Custom expressions are not supported inside `@starting-style` rules. :::
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
:::caution[Other Limitations]
- `@starting-style` does not work with out-of-line SVGs.
- Custom expressions are not supported inside `@starting-style` rules. :::
:::caution[Other Limitations]
- `@starting-style` does not work with out-of-line SVGs.
- Custom expressions are not supported inside `@starting-style` rules.
:::

- `@starting-style` does not work with out-of-line SVGs.
- Custom expressions are not supported inside `@starting-style` rules. :::

## Controlling Animations with JavaScript
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I am no sure if this is the place but maybe it is good to add a short example/topic of controlling something with transtionend and transitionstart because they are not documented but are useful in some scenarios

Comment on lines +187 to +189
Not all CSS properties work on SVG child elements the way they do on HTML elements. Properties like `filter` (e.g., `drop-shadow`) and `box-shadow`

<Highlight>will not produce any visible effect</Highlight> when applied directly to a `<path>`, `<rect>`, or other SVG shape. The declaration is
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
Not all CSS properties work on SVG child elements the way they do on HTML elements. Properties like `filter` (e.g., `drop-shadow`) and `box-shadow`
<Highlight>will not produce any visible effect</Highlight> when applied directly to a `<path>`, `<rect>`, or other SVG shape. The declaration is
Not all CSS properties work on SVG child elements the way they do on HTML elements. Properties like `filter` (e.g., `drop-shadow`) and `box-shadow` <Highlight>will not produce any visible effect</Highlight> when applied directly to a `<path>`, `<rect>`, or other SVG shape. The declaration is

Comment on lines +129 to +131
The `mask-image` variant flips the relationship between shape and color. Instead of the sprite sheet carrying the finished visual, it carries only

<Highlight>silhouette frames</Highlight> that define which pixels are visible. The actual color comes from `background-color` on the same element.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
The `mask-image` variant flips the relationship between shape and color. Instead of the sprite sheet carrying the finished visual, it carries only
<Highlight>silhouette frames</Highlight> that define which pixels are visible. The actual color comes from `background-color` on the same element.
The `mask-image` variant flips the relationship between shape and color. Instead of the sprite sheet carrying the finished visual, it carries only <Highlight>silhouette frames</Highlight> that define which pixels are visible. The actual color comes from `background-color` on the same element.

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.

2 participants