GizStackGizStack
View .mdOpen in ChatGPTOpen in Claude

gizgame/sky

Skies: the light of a scene at a time (Scene3D light).

gizlang
import * as Sky from "gizgame/sky";

Types

Dark

gizlang
type Dark = { light: Vec<f64>; ambient: Vec<f64>; sky: Vec<f64>; zenith: Vec<f64>; fog: f64; }

A sky's night: its moon's LIGHT, its AMBIENT light, its SKY at the horizon, its ZENITH and its FOG.

  • light: Vec<f64>
  • ambient: Vec<f64>
  • sky: Vec<f64>
  • zenith: Vec<f64>
  • fog: f64

Functions

sky

gizlang
function sky(environment: Environment): (game: Game, time: f64) => Environment

ENVIRONMENT at every time.

Effects: fail, alloc.

hourOf

gizlang
function hourOf(game: Game, time: f64, seconds: f64): f64

Where in its turn GAME's day of SECONDS is at TIME (0 to 1 a day, from midnight): the day starts in the morning; with the person's day and night off (Settings.cycle) it stays at noon.

Effects: fail, read.

daylight

gizlang
function daylight(game: Game, time: f64, seconds: f64): f64

How much of the day it is at TIME of GAME's day of SECONDS: 0 at night, 1 at noon.

Effects: fail, read.

night

gizlang
function night(game: Game, time: f64, seconds: f64): f64

How dark it is at TIME of such a day: 0 by day, 1 at night.

Effects: fail, read.

sunlit

gizlang
function sunlit(daylight: f64, turn: f64, dark: Dark = DARK, shadow: f64 = 70.0, haze: f64 = 0.004): Environment

The light at DAYLIGHT (0 at night, 1 at noon) with the sun at TURN of its day (0 to 1 from midnight): noon is warm and blue, dusk red, the night DARK, the light bounces off the ground and gathers in creases; SHADOW meters of shadow. Every sky of a day or a dawn is this one, so a game names only its night. HAZE is the day's fog per meter: less for a world whose skyline is far (mountains past a field).

Effects: fail, alloc.

day

gizlang
function day(seconds: f64, shadow: f64 = 70.0, dark: Dark = DARK): (game: Game, time: f64) => Environment

A day of SECONDS (sunlit): the sun turns from the morning, through a night of DARK; SHADOW meters of shadow.

Effects: fail, alloc.

mix

gizlang
function mix(a: Vec<f64>, b: Vec<f64>, t: f64): Vec<f64>

The colors A to B at T (0 to 1).

Effects: fail, alloc.

Constants

DARK

gizlang
const DARK: Dark = { light: [0.25, 0.3, 0.5], ambient: [0.06, 0.07, 0.12], sky: [0.03, 0.04, 0.09], zenith: [0.01, 0.01, 0.04], fog: 0.008 }

A night of dark blue and a thin mist.