cameras

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 26 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cameras makes the cameras a game looks at its world through and moves them: from above over any world, and over a world in relief on a stick, turned and leaned, orthographically or in perspective, riding with an entity.

Making cameras

NewPlugin takes the world and a Config and makes no camera: each is made where a scene shows it (Write.New, render.NewFeed), beginning as its Start says, with a camera.Config of its own, and sized by whoever shows it. The zero Config is the plain camera from above, which wraps on a wrapping axis; one that turns, tilts, reaches the perspective or has a Cage sees the world in relief, a Cell of it drawn isometrically as a TileW x TileH diamond, and refuses a world that wraps. camera.Config.Follow names the entity a camera starts fastened Centred over. Every camera made is saved with the game, in the order made, and one made after a Load takes the state of the camera made in its place. Every camera but a minimap's observes the world (world.Write.Observe), its sectors ticked at the levels the cameras see them at. A camera sees the world's sight (world.Config.LOD) once as made (camera.Sighted); Sight changes how many times, saved with the camera.

Profiles

Every picture but a minimap's is drawn by the Knobs of its camera's Profile (ProfileOf): Tactical for a camera free, over or behind an entity, in any view, Riding for one inside an entity (Config.Tactical and Riding to begin with, Settings.Tactical and Riding after); a camera whose state changes is dressed anew as the cameras' pass ends. A picture is drawn at its knobs' Resolution of the pixels it is shown at (camera.Resolved; the ui stays sharp), Picture sets it and Resolution steps a camera's, and Adapt has it follow Settings.FrameBudget as the knobs' Strategy says: coarser while the frames come slower, finer again while they keep up, the whole picture's (Uniform) or layer by layer (InLayers). A picture drawn whole below all its pixels draws its figures, all that lies over the ground, at every pixel while its ground is drawn at the resolution (camera.Figured; Knobs.SoftFigures and SharpFigures have them follow the ground's resolution instead, to compare). Drawn in layers (Knobs.Layers, Layers, camera.Layered) a picture is the whole frame at OuterRes of its pixels, its central Middle at MiddleRes and its central Inner at the Resolution (LayerShares, LayerResolutions; 0.6, 60% at 0.8, 35% at all to begin with), each layer inset in the frame but in a tactical perspective, where it stands on the frame's bottom edge, the near ground (camera.Footed); a step takes one layer at a time: coarser the outermost first, each down to a floor, finer the innermost first. A hand on the resolution or a layer's stops its profile's following (Still); the Settings show the first camera's picture in its profile's knobs, the settings screen a section a profile. The telemetry panel shows it, naming the profile (Read.Reporter); ShowLayers outlines a profile's layers.

Cage

A Cage is where the cameras may be: a game hands the one of its map (the topography is one) or its own, and in Config.Walls what stands on it holding a camera's eye and stopping its cursor while the stick's foot passes it (the buildings; Cages makes one cage of several). A line of sight stops where it is not Free, so a camera picks the point under the cursor on the top of what is solid there; a Grained cage steps finer near what is thin, and an Opens one lets a camera into what it opens before it as the camera is fastened (a house a unit stands in).

Views

In relief a camera hangs on a stick whose foot is the point in the middle of the screen: a pan slides the foot over the world at its height, Turn turns the stick about the upright through it, Tilt leans it from straight down to Config.MinPitch over the ground. Isometrically (the 2:1 view of Transport Tycoon, heights lifting what stands) is the stick turned an eighth and leaning at asin(TileH/TileW). The view is orthographic, Zoom screen pixels a world unit, or, where the Config reaches it, in perspective; View switches between the two keeping the foot, the turn, the pitch and the scale. Orthographically the whole screen stays over the world at sea level: a pan stops at the edge, and zooming out stops where the screen just fits the world. In perspective the eye stands at the stick's end, the wheel drawing it and the foot towards the cursor; where the cage puts something solid at the eye, it is lifted straight up and let down as the way clears. Behind an entity the eye is held in the perspective, whatever view the camera stood in, on the arm the settings say (Arm, Config.Arm: its length in cells, its tilt in degrees, under Config.MinPitch too, and the share of the entity's height it is aimed up at), shortened where the cage puts something solid between and leaning flatter under a low roof over the entity, nothing zooming it but the arm's own setting and View switching nothing; the view it came from, with its scale and its stick, comes back on letting go, and a camera whose Config reaches no perspective is fastened behind nothing. The mouse turns the camera round the entity and, where the arm lets (Arm.Tilts), tilts it; the camera eases back behind the entity only as it goes on and a second after the mouse. On a world with a scale the ground far off sinks under the eye's level. Riding in an entity the eye is the entity's world.Eye, going with it and looking the way it faces. A camera in relief saved before the stick begins afresh, the log naming it.

Commands

Pan moves a camera by screen pixels and lets go of whatever it was fastened to; Zoom scales it about a world point; Follow fastens it Centred over an entity, kept in the middle of the screen as it goes, or lets it go; CenterOn moves it once onto an entity, CenterAt onto the ground at a world point (a click on a minimap), fastened to nothing. In relief View switches the projection, Turn and Tilt move the stick, Ride takes it behind and inside the entity it is fastened to, or behind the entity it names with the camera fastened to nothing, LookFrom and LookAt place the eye in perspective and Look looks round riding, the cursor captured. Resolution draws a camera's picture at a factor of its pixels, a layer at a time in layers. Each names its camera, taken from the context by its binding, so the plugin never knows the players. The picture's commands name a Profile and no camera: Adapt has the resolution of the profile's pictures follow the frame budget as its Strategy says or stay, Picture draws them at a resolution, SharpFigures their figures at every pixel or at the ground's resolution, Layers in layers or whole, LayerShares and LayerResolutions shape the layers, ShowLayers outlines them, a profile each; Budget sets the frame budget for both, Sampling how long the rate is averaged over before it is followed and Detail whether, in a world cut into sectors, every picture but a minimap's is drawn up to MostLevelShift levels coarser than the world sees it (camera.Shifted; a sector seen at lod.Standard or finer stays full) before its resolution falls and back after it, the tick untouched. What else follows the budget is a Lever given in Config.Levers, turned ahead of the pictures' level and resolution both ways. The budget is followed on the frame's barrier (Plugin.Pace, told each frame's times): coarser only while the drawing's side holds the frames back, not the simulation, which no lever lightens. The plugin writes only the eye's part of a ridden entity's steering.Driven (Look, Flown, Climb).

Keys

Keys are a player's keys to its camera: four keys held scrolling it, the wheel zooming about the cursor, the middle drag panning, the cursor at an edge scrolling and in a corner scrolling slantwise, or turning as Q and E do (Keys.CornersTurn: as Q in the bottom-left and the top-right, as E in the other two, unless the settings still the corners; nothing while the window has no cursor), two with Ctrl seeing farther and nearer, and, where a game asks (Keys.Grab; Config.Grab for the defaults), the right button grabbing the world and dragging it past a click's slop, yielding to whatever else takes the right drag: a selection's orders. DefaultKeys are W, S, A, D, = and -, Ctrl+= and Ctrl+-, with all three and no grab; Plugin.DefaultBindings are those, the corners turning and the world grabbed where the Config says, and the views' keys the Config gives: Q and E turning, R looking down more steeply and F flatter, Tab switching between the orthographic view and the perspective and leaving the unit, V riding: behind, inside, over it again, the mouse looking round inside an entity and turning the camera round it behind it; = and - drawing the arm in and out where it lets (Arm.Zooms). The scroll keys, the edge, the corners, the middle drag and the grab hold where the hand is free (camera.Free), not behind or in an entity, where the keys drive it (driving). The scroll zones, their opacity, the arm and the pictures' resolution have no key: the settings screen sets them, Config.Zones their start.

Vocabulary

Commands, a player's through its camera: Pan, Zoom, CenterOn, CenterAt, View, Turn, Tilt, LookFrom, LookAt, Ride, Look, Sight, Resolution; a player's about a Profile's pictures: Adapt (the resolution following the frame budget as a Strategy says), Picture (the resolution), SharpFigures (the figures at every pixel), Layers (drawn in layers), LayerShares and LayerResolutions (the layers' shares of the frame and resolutions), ShowLayers (a look: the layers outlined); about every picture: Budget (the frame budget), Detail (the level of detail following it), Zones (a look: the scroll zones on the glass over every picture, over whatever a scene lays on it), EdgeScroll (the cursor at the edge scrolling, or not), CornerTurn (the cursor in a corner turning, or not), EdgeSpeed (how fast at the very edge, a quarter of it at the zone's inner bound), ZonesOpacity (how opaque at the edge), Hold (the Arm behind an entity); Follow (a player's, or an entity's own fastening the camera over itself). Settings (Settings, saved with the game, in Resources): the zones scrolling, turning in the corners, shown, their opacity and their speed, the arm behind an entity, the frame budget, the detail following it, the layers shown and each profile's Knobs: the strategy, the resolution, the figures at every pixel, the picture drawn in layers, the layers' shares and resolutions.

Index

Constants

View Source
const (
	LeastSampling   = time.Second
	MostSampling    = 20 * time.Second
	DefaultSampling = 2 * time.Second
)

Sampling the frame rate is averaged over before the pictures' resolution follows it (Settings.Sampling): the least, the most and the one the cameras begin with.

View Source
const (
	DefaultUnder = 0.92
	DefaultMet   = 0.98
)

DefaultUnder and DefaultMet are the shares of the budget's rate the cameras begin with: under the first the picture goes coarser, over the second finer (Settings.Under, Settings.Met).

View Source
const (
	LeastPitch = 5
	MostPitch  = 89
	LeastArm   = 0.5
	MostArm    = 8
	MostAim    = 3
)

LeastPitch and MostPitch are the degrees the arm tilts between, LeastArm and MostArm the cells it is drawn between, MostAim the entity's heights it is aimed up to at most.

View Source
const (
	TurnStep   = math.Pi / 72
	CornerStep = TurnStep / 3
	TiltStep   = math.Pi / 180
)

TurnStep is how far Q and E turn the view a tick they are held, in radians, eighteen of them an eighth of a turn; CornerStep how far the cursor in a corner turns it; TiltStep how far R and F tilt it.

View Source
const (
	ResolutionStep  = 0.85
	LeastResolution = 0.4
)

ResolutionStep is the factor the adaptive resolution steps a picture coarser by, and finer by its inverse. LeastResolution is the coarsest a picture is drawn at.

View Source
const (
	// DefaultScrollSpeed is how fast the keys and the edge scroll, screen pixels a tick.
	DefaultScrollSpeed = 8
	// ZoomStep is the factor one wheel notch zooms by.
	ZoomStep = 1.1
)
View Source
const (
	DefaultZonesOpacity = float32(40) / 255
	LeastZonesOpacity   = 0.05
)

DefaultZonesOpacity is how opaque the zones are at the picture's edge until set, LeastZonesOpacity the least they can be set to.

View Source
const MostLevelShift lod.Level = 2

MostLevelShift is the most levels the frame budget draws the pictures coarser than the world sees them (Detail).

View Source
const SightStep = 1.25

SightStep is the factor Ctrl+= and Ctrl+- see farther and nearer by.

Variables

View Source
var DefaultArm = Arm{Pitch: 30, Distance: 2}

DefaultArm is the arm a zero Config.Arm gives: 30 degrees on two cells, aimed at the feet.

Functions

This section is empty.

Types

type Adapt

type Adapt struct {
	Profile  Profile
	Strategy Strategy
}

Adapt has the resolution of Profile's pictures follow the frame budget (Settings.FrameBudget) as Strategy says, Uniform the whole picture's, coarser while the frames come slower and finer again while they keep up, InLayers drawn in layers and stepped a layer at a time, the outer layers first, or stay as set, Still. The settings screen alone.

func (Adapt) Command

func (Adapt) Command()

type Arm added in v0.6.0

type Arm struct {
	Pitch, Distance, Aim float32
	Tilts, Zooms         bool
}

Arm is how a camera is held behind an entity (camera.Behind): on an arm Distance cells long, tilted Pitch degrees over the ground in perspective, aimed Aim of the entity's height over its feet (0 its feet, 1 its top; the higher, the lower the entity on the screen); Tilts lets the player tilt it with the mouse, Zooms draw it in and out with the zoom keys and the wheel. Zero: DefaultArm, nothing the player's.

type Budget

type Budget struct{ Frame time.Duration }

Budget sets the time a Frame may take, which the resolution follows (Settings.FrameBudget).

func (Budget) Command

func (Budget) Command()

type Cage

type Cage interface {
	Free(x, y, z float32) bool
	Span() (low, high float32)
}

Cage is where the cameras may be: Free says whether nothing solid fills the point (x, y, z) — the ground, what stands on it, a deck, a cave's rock — and Span the lowest and highest heights the solid reaches. A line of sight stops where a point is not Free.

func Cages added in v0.24.0

func Cages(cages ...Cage) Cage

Cages is the cage of cages: free where each is, spanning them all, as fine as the finest, a camera let in where each lets it in.

type CenterAt

type CenterAt struct {
	Camera camera.Camera
	X, Y   float32
}

CenterAt moves Camera, once, to have the ground at the world point (X, Y) in the middle of the screen, fastening it to nothing: a click on a minimap.

func (CenterAt) Command

func (CenterAt) Command()

type CenterOn

type CenterOn struct {
	Camera camera.Camera
	Entity uid.UID64
}

CenterOn moves Camera, once, to have Entity in the middle of the screen at its altitude, fastening it to nothing.

func (CenterOn) Command

func (CenterOn) Command()

type Config

type Config struct {
	Turn        bool
	Tilt        bool
	Perspective bool
	// Grab has the right button grab the world and drag it, yielding to whatever else takes the
	// right drag (a selection's orders); a game's choice, off by default
	Grab bool
	// degrees: the flattest the eye may look (zero, 30) and how much it sees top to bottom in
	// perspective (zero, 45)
	MinPitch    float32
	FieldOfView float32
	// world units over the highest ground a camera looks for what stands there; zero, 64
	Headroom float32
	// a Cell-sized square of the world drawn isometrically as a TileW x TileH diamond (zero, 64 x
	// 32), a height lifting a point HeightUnit screen units a world unit (zero, 1)
	Cell       float32
	TileW      float32
	TileH      float32
	HeightUnit float32
	// where the cameras may be; nil, anywhere over level ground at sea level
	Cage Cage
	// what holds a camera's eye and stops its cursor beside the Cage, the stick's foot passing it
	// (the buildings' solids); nil, nothing
	Walls Cage
	// how every picture but a minimap's is drawn from the start (Settings.Tactical, Riding): a
	// camera's free, over or behind an entity by Tactical, one's inside an entity by Riding, the
	// resolution following the FrameBudget where the Strategy says, the time a frame may take
	// (zero, a sixtieth of a second): a rate the vsync caps is met, never exceeded
	Tactical    Knobs
	Riding      Knobs
	FrameBudget time.Duration
	// Levers is what else the frame budget turns, in order, ahead of the pictures' level and
	// resolution both ways.
	Levers []Lever
	// how a camera is held behind an entity from the start (Settings.Arm): the arm's pitch,
	// length and aim, and whether the player leans and draws it; zero, DefaultArm, hands off
	Arm Arm
	// how the scroll zones start (Settings.Zones, StillEdges, StillCorners, ZonesOpacity,
	// EdgeSpeed); zero, the edges scrolling, the corners turning where Turn, the zones hidden
	Zones ZonesCfg
}

Config is what a game's cameras may do and how they see: Turn (Q, E), Tilt (R, F), Perspective (Tab) and Grab (the right drag) say which keys a player has, the rest how a world in relief is drawn and where the cameras may be. The zero Config is the plain camera from above: wrapping on a wrapping axis, a world unit a pixel at zoom 1.

type CornerTurn added in v0.17.0

type CornerTurn struct{ On bool }

CornerTurn has the cursor in a picture's corner turn the camera as Q and E do, or not (Settings.StillCorners). The settings screen alone.

func (CornerTurn) Command added in v0.17.0

func (CornerTurn) Command()

type Detail added in v0.18.0

type Detail struct{ Follows bool }

Detail has the pictures' level of detail follow the frame budget where it Follows, every picture but a minimap's drawn up to MostLevelShift levels coarser than the world sees it before its resolution falls, or stay as the world sees it (Settings.StillDetail). The settings screen alone.

func (Detail) Command added in v0.18.0

func (Detail) Command()

type EdgeScroll

type EdgeScroll struct{ On bool }

EdgeScroll has the cursor at a picture's edge scroll the camera, or not (Settings.StillEdges). The settings screen alone.

func (EdgeScroll) Command

func (EdgeScroll) Command()

type EdgeSpeed

type EdgeSpeed struct{ Speed float32 }

EdgeSpeed sets how fast the cursor at a picture's edge scrolls, screen pixels a tick at the very edge (Settings.EdgeSpeed); 0, the keys' own. The settings screen alone.

func (EdgeSpeed) Command

func (EdgeSpeed) Command()

type Follow

type Follow struct {
	Camera camera.Camera
	Entity uid.UID64
	On     bool
}

Follow fastens Camera over Entity, kept in the middle of the screen as it goes (camera.Centred); with On false, or the camera Centred already, it lets go, and one behind or inside an entity goes Centred over Entity. Given by an entity for itself (kind.Entry.Told, act.Do), Camera is fastened over that entity.

func (Follow) Command

func (Follow) Command()

type Grained

type Grained interface {
	Grain(x, y float32) (step, thin float32)
}

Grained is a Cage with things thinner than half a cell: Grain is how far a line of sight may step at (x, y) and how thin the thinnest thing there is, zero where half a cell will do.

type Hold added in v0.6.0

type Hold struct{ Arm Arm }

Hold sets how the cameras are held behind an entity (Settings.Arm). The settings screen alone.

func (Hold) Command added in v0.6.0

func (Hold) Command()

type Keys

type Keys struct {
	Up, Down, Left, Right control.Key
	ZoomIn, ZoomOut       control.Key
	ScrollSpeed           float32 // screen pixels a tick; zero is DefaultScrollSpeed
	Wheel, Drag, Edge     bool
	// CornersTurn has the cursor in a corner turn the camera the way Q and E do, a CornerStep a
	// tick, where Edge would scroll: the bottom-left and the top-right corners anticlockwise, the
	// bottom-right and the top-left clockwise, the world under the cursor sliding along the top
	// or the bottom edge towards the middle.
	CornersTurn bool
	// Grab has the right button grab the world and drag it past a click's slop, yielding to
	// whatever else takes the right drag: a selection's orders. A game's choice, no default.
	Grab bool
	// Farther and Nearer pressed with Ctrl have the camera see a SightStep farther and nearer.
	Farther, Nearer control.Key
}

Keys are a player's keys to its camera: Up, Down, Left and Right held scroll it on the screen (KeyUnknown leaves one unbound), ZoomIn and ZoomOut pressed zoom about the cursor a ZoomStep, Wheel zooms about the cursor, Drag pans with the middle button, Grab with the right, Edge scrolls with the cursor at a window edge, slantwise in a corner. Scrolling, dragging, grabbing and the zones hold where the hand is free (camera.Free): behind a unit the keys drive it and the cursor at an edge lets go of no camera kept there.

func DefaultKeys

func DefaultKeys() Keys

DefaultKeys are W, S, A and D, = and - to zoom, Ctrl+= and Ctrl+- to see farther and nearer, the wheel, the middle drag and the edge; no grab.

func (Keys) Bindings

func (k Keys) Bindings() []control.Binding

Bindings are the keys bound to Pan and Zoom of the camera the player looks through.

type Knobs

type Knobs struct {
	Strategy   Strategy
	Resolution float32 // of the pixels, the centre layer's in layers; zero, all of them
	// the figures at the ground's resolution; zero, at every pixel
	SoftFigures bool
	Layers      bool
	// the inner and the middle layer's shares of the frame (zero, 0.35 and 0.6), the outer and
	// the middle layer's resolutions (zero, 0.6 and 0.8)
	Inner     float32
	Middle    float32
	OuterRes  float32
	MiddleRes float32
	// the layers' edges outlined over the picture
	ShowLayers bool
}

Knobs are how the pictures of a profile are drawn: the Strategy following the frame budget, the resolution, the figures at every pixel or not, and the layers.

type LayerResolutions

type LayerResolutions struct {
	Profile       Profile
	Outer, Middle float32
}

LayerResolutions has the outer layer of Profile's pictures drawn at Outer of its pixels and the middle layer at Middle (Knobs.OuterRes, MiddleRes), and stops the following (Still).

func (LayerResolutions) Command

func (LayerResolutions) Command()

type LayerShares

type LayerShares struct {
	Profile       Profile
	Inner, Middle float32
}

LayerShares has the inner layer of Profile's pictures cover Inner of the frame and the middle layer Middle, at least a tenth over the inner (Knobs.Inner, Middle).

func (LayerShares) Command

func (LayerShares) Command()

type Layers

type Layers struct {
	Profile Profile
	On      bool
}

Layers has Profile's pictures drawn in layers (Knobs.Layers) or whole; a Strategy saying otherwise stops (Still).

func (Layers) Command

func (Layers) Command()

type Lever

type Lever interface {
	Following() bool
	Coarser() bool
	Finer() bool
}

Lever is what else the frame budget turns, given the cameras in Config.Levers, ahead of the pictures' level and resolution both ways: Coarser a step as the rate falls under the budget, Finer a step as it stays over, each saying whether it could; one not Following is left alone.

type Look

type Look struct {
	Camera camera.Camera
	Dx, Dy float32
}

Look has Camera look round by a move of the mouse of Dx and Dy pixels, a seventh of a degree a pixel: riding in an entity, across turns the entity and up and down the head; behind an entity (camera.Behind), across turns the camera round it and up and down tilts the arm where the settings let the player (Arm.Tilts), the entity left to its way. A camera fastened otherwise stays as it is.

func (Look) Command

func (Look) Command()

type LookAt

type LookAt struct {
	Camera  camera.Camera
	X, Y, Z float32
}

LookAt has Camera's eye look at the world point (X, Y, Z) from where it is, in perspective as LookFrom.

func (LookAt) Command

func (LookAt) Command()

type LookFrom

type LookFrom struct {
	Camera  camera.Camera
	X, Y, Z float32
}

LookFrom puts Camera's eye at the world point (X, Y, Z) in perspective, still looking at the ground point in the middle of the screen; a camera of another view goes into the perspective first, or stays as it is where the Config has none. The eye is put exactly there, below the pitch floor too, until the next Tilt.

func (LookFrom) Command

func (LookFrom) Command()

type Opens added in v0.24.0

type Opens interface {
	FreeTo(how camera.How, x, y, z float32) bool
}

Opens is a Cage letting a camera into some of its solids as it is fastened: FreeTo is Free as a camera fastened how sees it.

type Pan

type Pan struct {
	Camera camera.Camera
	Dx, Dy float32
}

Pan moves Camera by screen pixels, the same at any zoom, letting go of whatever it was fastened to.

func (Pan) Command

func (Pan) Command()

type Picture

type Picture struct {
	Profile    Profile
	Resolution float32
}

Picture has Profile's pictures drawn at Resolution of their pixels, the centre layer's in layers, LeastResolution up to all of them, and stops the following (Still).

func (Picture) Command

func (Picture) Command()

type Plugin

type Plugin struct {
	*world.Self

	Res Resources
	// contains filtered or unexported fields
}

Plugin makes a world's cameras and moves them: Pan, Zoom and Follow, a camera fastened Centred over an entity kept over it as it goes, and in relief the views, turning, tilting and riding.

func NewPlugin

func NewPlugin(worldPlugin *world.Plugin, cfg Config) *Plugin

NewPlugin keeps and moves the cameras of worldPlugin's world as cfg says; it makes none itself. A Config seeing in relief (any but the plain one) panics without a Cell or over a world that wraps.

func (*Plugin) Bindings added in v0.22.0

func (p *Plugin) Bindings(keys Keys) []control.Binding

Bindings are keys and the views' keys as DefaultBindings has them: a game walking its unit on keys of its own binds the views without the keys scrolling the camera.

func (*Plugin) DefaultBindings

func (p *Plugin) DefaultBindings() []control.Binding

DefaultBindings are DefaultKeys, their corners turning where the Config turns and the settings say (CornersTurn), the world grabbed with the right button where it says so and their edge as the settings say (EdgesScroll, EdgeSpeed), and the views' keys the Config gives: Q and E turning, R and F tilting and Tab switching the projection where the hand is free, V riding where the Config reaches the perspective, and the mouse looking round inside an entity and behind it. The scroll zones and the pictures' resolution are the settings screen's.

func (*Plugin) EventHandler

func (p *Plugin) EventHandler() control.EventHandler

EventHandler is nil: a player's bindings issue the commands.

func (*Plugin) Install

func (p *Plugin) Install(ctx plugin.Installer) error

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Pace added in v0.5.0

func (p *Plugin) Pace(t plugin.FrameTimes)

Pace steps what follows the frame budget coarser or finer after the frames' times, on the frame's barrier (plugin.Paced): the levers first, then the pictures' level and resolution.

func (*Plugin) Queues

func (p *Plugin) Queues() []command.CommandQueue

Queues are where the cameras' commands land.

func (*Plugin) Read added in v0.4.0

func (p *Plugin) Read(int) *Read

Read reads the cameras' state on worker w of the game's pool, 0 the game's own goroutine.

func (*Plugin) Restore

func (p *Plugin) Restore()

Restore gives the cameras made so far the state a Load wrote, those made later take theirs as they are made, and takes the Settings loaded, the pictures drawn as they say.

func (*Plugin) RunPlan

func (p *Plugin) RunPlan(ctx goke.RunCtx, d time.Duration)

RunPlan carries out the cameras' commands and keeps every camera fastened to its entity, at once, in the tactical pause too, each dressed by its profile; call it after whatever moves the entities.

func (*Plugin) Serializable

func (p *Plugin) Serializable() plugin.Serializable

Serializable is every camera's state, its window, zoom and fastening, in the order made, and the Settings.

func (*Plugin) Settings

func (p *Plugin) Settings() []control.Setting

Settings are the scroll zones (scrolling, turning in the corners where the camera turns, shown, their speed), the frame budget, the detail following it in a world cut into sectors and each profile's knobs (the strategy following the budget, the resolution, the figures at every pixel, the layers and their edges shown) (plugin.Tunable).

func (*Plugin) Write added in v0.4.0

func (p *Plugin) Write() *Write

Write changes the cameras' state, on the game's goroutine.

type Profile

type Profile uint8

Profile is which Knobs a picture is drawn by, as its camera's state says (ProfileOf).

const (
	// Tactical is the profile of a camera free, over or behind an entity, in any view.
	Tactical Profile = iota
	// Riding is the profile of a camera inside an entity, in first person (camera.Inside).
	Riding
)

func ProfileOf

func ProfileOf(cam camera.Camera) Profile

ProfileOf is the profile cam's picture is drawn by: Riding inside an entity, Tactical else.

func (Profile) String

func (p Profile) String() string

type Read added in v0.4.0

type Read struct {
	// contains filtered or unexported fields
}

Read reads the cameras' state, the same on every goroutine.

func (*Read) Arm added in v0.6.0

func (r *Read) Arm() Arm

Arm is how the cameras are held behind an entity.

func (*Read) Budget added in v0.4.0

func (r *Read) Budget() time.Duration

Budget is the time a frame may take, which the resolution follows.

func (*Read) Cameras added in v0.4.0

func (r *Read) Cameras() []camera.Camera

Cameras are every camera made, in order.

func (*Read) CornersTurn added in v0.17.0

func (r *Read) CornersTurn() bool

CornersTurn reports whether the cursor in a picture's corner turns the camera.

func (*Read) DetailFollows added in v0.18.0

func (r *Read) DetailFollows() bool

DetailFollows reports whether the pictures' level of detail follows the frame budget, as it may in a world cut into sectors alone.

func (*Read) EdgeSpeed added in v0.4.0

func (r *Read) EdgeSpeed() float32

EdgeSpeed is how fast the cursor at the very edge scrolls, 0 for the keys' own.

func (*Read) EdgesScroll added in v0.4.0

func (r *Read) EdgesScroll() bool

EdgesScroll reports whether the cursor at a picture's edge scrolls the camera.

func (*Read) LayerResolutions added in v0.4.0

func (r *Read) LayerResolutions(profile Profile) (outer, middle float32)

LayerResolutions are the outer and the middle layer's resolutions in profile's pictures.

func (*Read) LayerShares added in v0.4.0

func (r *Read) LayerShares(profile Profile) (inner, middle float32)

LayerShares are the inner and the middle layer's shares of the frame in profile's pictures.

func (*Read) Layers added in v0.4.0

func (r *Read) Layers(profile Profile) bool

Layers reports whether profile's pictures are drawn in layers.

func (*Read) LayersShown added in v0.4.0

func (r *Read) LayersShown(profile Profile) bool

LayersShown reports whether profile's layers' edges are shown.

func (*Read) Reporter added in v0.4.0

func (r *Read) Reporter() render.Reporter

Reporter is the cameras' part of the telemetry panel, a line each: the lead camera's profile, the share of its pixels each picture is drawn at, layer by layer, the layers' shares in layers, the figures sharp where a coarser picture draws them at every pixel, the levels its detail is drawn coarser, and the budget it follows, or still where neither its profile nor the detail follows one.

func (*Read) Resolution added in v0.4.0

func (r *Read) Resolution(profile Profile) float32

Resolution is the share of their pixels profile's pictures are drawn at, the centre layer's in layers.

func (*Read) Sampling added in v0.4.0

func (r *Read) Sampling() time.Duration

Sampling is how long the frame rate is averaged over before the pictures follow it.

func (*Read) SharpFigures added in v0.4.0

func (r *Read) SharpFigures(profile Profile) bool

SharpFigures reports whether profile's pictures draw their figures at every pixel.

func (*Read) Strategy added in v0.4.0

func (r *Read) Strategy(profile Profile) Strategy

Strategy is how the resolution of profile's pictures follows the frame budget.

func (*Read) Thresholds added in v0.4.0

func (r *Read) Thresholds() (under, met float32)

Thresholds are the shares of the budget's rate the following steps at: coarser under the first, finer over the second.

func (*Read) ZonesOpacity added in v0.6.0

func (r *Read) ZonesOpacity() float32

ZonesOpacity is how opaque the scroll zones are at the picture's edge, 0 to 1.

func (*Read) ZonesShown added in v0.4.0

func (r *Read) ZonesShown() bool

ZonesShown reports whether the scroll zones are shown.

type Resolution

type Resolution struct {
	Camera camera.Camera
	Factor float32
}

Resolution has Camera drawn at Factor times the pixels it is drawn at now, between LeastResolution and all of them, a layer at a time in layers, and stops the following of its profile (Still).

func (Resolution) Command

func (Resolution) Command()

type Resources

type Resources struct {
	Settings Settings
}

Resources is what the cameras publish: their Settings.

type Ride

type Ride struct {
	Camera camera.Camera
	Entity uid.UID64
}

Ride takes Camera closer round the entity it is fastened to, in the perspective, from whatever view it stands in: over it (camera.Centred), behind it on the arm the settings say (camera.Behind, Arm), inside it in first person (camera.Inside), and over it again, in the view it came from; a camera whose Config reaches no perspective stays as it is. A camera fastened to nothing is fastened behind Entity where one is given and exists; a fastened camera goes round its own.

func (Ride) Command

func (Ride) Command()

type Sampling

type Sampling struct{ Over time.Duration }

Sampling sets how long the frame rate is averaged Over before the resolution follows it (Settings.Sampling), LeastSampling up to MostSampling.

func (Sampling) Command

func (Sampling) Command()

type Settings

type Settings struct {
	Zones        bool
	ZonesOpacity float32 // how opaque at the picture's edge, 0 to 1; zero, the default
	StillEdges   bool    // the cursor at a picture's edge scrolls nothing
	StillCorners bool    // the cursor in a picture's corner turns nothing
	EdgeSpeed    float32 // screen pixels a tick at the very edge; zero, the keys' own
	FrameBudget  time.Duration
	Sampling     time.Duration // the frame rate averaged over this before it is followed
	Under        float32       // of the budget's rate, under which the picture goes coarser
	Met          float32       // over which it goes finer
	StillDetail  bool          // the pictures at the levels the world sees, whatever the rate
	Tactical     Knobs
	Riding       Knobs
	Arm          Arm // how a camera is held behind an entity
}

Settings is what the cameras let the players adjust, saved with the game: the scroll zones, the frame budget, whether the pictures' detail follows it and the Knobs of each Profile.

type SharpFigures

type SharpFigures struct {
	Profile Profile
	On      bool
}

SharpFigures has Profile's pictures draw their figures, all that lies over the ground, at every shown pixel while the ground is drawn at the resolution, or at the resolution too (Knobs.SoftFigures); a picture drawn in layers is drawn as it is.

func (SharpFigures) Command

func (SharpFigures) Command()

type ShowLayers

type ShowLayers struct {
	Profile Profile
	Shown   bool
}

ShowLayers shows the layers' edges over every picture a Profile draws in layers, or hides them (Knobs.ShowLayers).

func (ShowLayers) Command

func (ShowLayers) Command()

type Sight

type Sight struct {
	Camera camera.Camera
	Factor float32
}

Sight has Camera see Factor times as far (camera.Sighted); one in a world seeing without end stays so.

func (Sight) Command

func (Sight) Command()

type Start

type Start uint8

Start is how a camera begins: FromAbove or Isometrically.

const (
	// FromAbove begins a camera looking straight down, a screen pixel a world unit.
	FromAbove Start = iota
	// Isometrically begins a camera in the 2:1 view, a Cell a TileW-wide diamond; a plain Config
	// has none.
	Isometrically
)

type Strategy

type Strategy uint8

Strategy is how the pictures' resolution follows the frame budget: not at all, the whole picture's, or layer by layer (Knobs.Strategy).

const (
	// Still keeps the resolution as set.
	Still Strategy = iota
	// Uniform steps the whole picture's resolution.
	Uniform
	// InLayers has the picture drawn in layers and steps them, the outer layers first.
	InLayers
)

type Thresholds

type Thresholds struct{ Under, Met float32 }

Thresholds sets the shares of the budget's rate the following steps at: coarser Under the first, finer over the second (Settings.Under, Settings.Met).

func (Thresholds) Command

func (Thresholds) Command()

type Tilt

type Tilt struct {
	Camera camera.Camera
	Angle  float32
}

Tilt leans Camera's stick about its foot by Angle radians, towards straight down as it grows and flatter for a negative one, between Config.MinPitch and straight down; a plain camera, or one behind an entity, stays.

func (Tilt) Command

func (Tilt) Command()

type Turn

type Turn struct {
	Camera camera.Camera
	Angle  float32
}

Turn turns Camera's stick about its foot by Angle radians, the world clockwise on the screen; a plain camera stays as it is.

func (Turn) Command

func (Turn) Command()

type View

type View struct{ Camera camera.Camera }

View has Camera switch between the orthographic view and the perspective, keeping the foot of its stick, its turn, pitch and scale, or leave the entity it rides in; a camera whose Config has no Perspective, or one behind an entity, stays as it is.

func (View) Command

func (View) Command()

type Write added in v0.4.0

type Write struct {
	// contains filtered or unexported fields
}

Write changes the cameras' state, on the game's goroutine.

func (*Write) AdaptDetail added in v0.18.0

func (w *Write) AdaptDetail(on bool)

AdaptDetail has the pictures' level of detail follow the frame budget, or stay as the world sees it (Settings.StillDetail); on from the start, in a world cut into sectors.

func (*Write) New added in v0.4.0

func (w *Write) New(start Start, cfg camera.Config) camera.Camera

New is a camera over the world beginning as start says, configured by cfg, made where a scene shows it and sized by whoever shows it. It is saved with the game: one made after a Load is as the camera made in its place was saved.

func (*Write) ScrollFromEdges added in v0.4.0

func (w *Write) ScrollFromEdges(on bool)

ScrollFromEdges has the cursor at a picture's edge scroll the camera, or not (Settings.StillEdges); on from the start.

func (*Write) SetArm added in v0.6.0

func (w *Write) SetArm(a Arm)

SetArm sets how the cameras are held behind an entity (Settings.Arm), within the bounds.

func (*Write) SetBudget added in v0.4.0

func (w *Write) SetBudget(d time.Duration)

SetBudget sets the time a frame may take, which the resolution follows (Settings.FrameBudget); zero or less, a sixtieth of a second.

func (*Write) SetEdgeSpeed added in v0.4.0

func (w *Write) SetEdgeSpeed(speed float32)

SetEdgeSpeed sets how fast the cursor at the very edge scrolls, screen pixels a tick (Settings.EdgeSpeed); 0 or less, the keys' own.

func (*Write) SetLayerResolutions added in v0.4.0

func (w *Write) SetLayerResolutions(profile Profile, outer, middle float32)

SetLayerResolutions has the outer layer of profile's pictures drawn at outer of its pixels and the middle layer at middle, LeastResolution up to 1 (Knobs.OuterRes, MiddleRes), and stops the following (Still).

func (*Write) SetLayerShares added in v0.4.0

func (w *Write) SetLayerShares(profile Profile, inner, middle float32)

SetLayerShares has the inner layer of profile's pictures cover inner of the frame and the middle layer middle, at least a tenth over the inner (Knobs.Inner, Middle).

func (*Write) SetLayers added in v0.4.0

func (w *Write) SetLayers(profile Profile, on bool)

SetLayers has profile's pictures drawn in layers, or whole (Knobs.Layers); a Strategy saying otherwise stops (Still).

func (*Write) SetResolution added in v0.4.0

func (w *Write) SetResolution(profile Profile, r float32)

SetResolution has profile's pictures drawn at r of their pixels, the centre layer's in layers, LeastResolution up to 1 (Knobs.Resolution), and stops the following (Still).

func (*Write) SetSampling added in v0.4.0

func (w *Write) SetSampling(d time.Duration)

SetSampling sets how long the frame rate is averaged over before the pictures follow it (Settings.Sampling), LeastSampling up to MostSampling; zero or less, DefaultSampling.

func (*Write) SetSharpFigures added in v0.4.0

func (w *Write) SetSharpFigures(profile Profile, on bool)

SetSharpFigures has profile's pictures draw their figures, all that lies over the ground, at every shown pixel while the ground is drawn at the resolution, or at the resolution too (Knobs.SoftFigures); a picture drawn in layers is drawn as it is.

func (*Write) SetStrategy added in v0.4.0

func (w *Write) SetStrategy(profile Profile, s Strategy)

SetStrategy has the resolution of profile's pictures follow the frame budget as s says, or stay (Knobs.Strategy): the pictures drawn in layers under InLayers, whole under Uniform.

func (*Write) SetThresholds added in v0.4.0

func (w *Write) SetThresholds(under, met float32)

SetThresholds sets the shares of the budget's rate the following steps at (Settings.Under, Settings.Met): coarser once a window's rate falls under the first, finer once two have met the second, each between a half and the whole, the second never under the first; zero or less, DefaultUnder and DefaultMet.

func (*Write) SetZonesOpacity added in v0.6.0

func (w *Write) SetZonesOpacity(opacity float32)

SetZonesOpacity sets how opaque the scroll zones are at the picture's edge (Settings.ZonesOpacity), kept between LeastZonesOpacity and 1.

func (*Write) ShowLayers added in v0.4.0

func (w *Write) ShowLayers(profile Profile, shown bool)

ShowLayers shows the layers' edges over every picture drawn in layers by profile, or hides them (Knobs.ShowLayers).

func (*Write) ShowZones added in v0.4.0

func (w *Write) ShowZones(shown bool)

ShowZones shows the scroll zones over every picture, or hides them (Settings.Zones).

func (*Write) TurnInCorners added in v0.17.0

func (w *Write) TurnInCorners(on bool)

TurnInCorners has the cursor in a picture's corner turn the camera as Q and E do, or not (Settings.StillCorners); on from the start, where the Config turns.

type Zones

type Zones struct{ Shown bool }

Zones shows the strips at the picture's edges the cursor scrolls from and the squares at its corners it turns from, a translucent yellow deepening to the edge as the scroll quickens, or hides them (Settings.Zones). The settings screen alone.

func (Zones) Command

func (Zones) Command()

type ZonesCfg added in v0.17.0

type ZonesCfg struct {
	Still        bool    // the cursor at a picture's edge scrolls nothing
	StillCorners bool    // the corners turn nothing, scrolling slantwise where the edges scroll
	Shown        bool    // the strips and the squares drawn
	Opacity      float32 // how opaque at the edge, 0 to 1; zero, DefaultZonesOpacity
	// screen pixels a tick at the very edge, a quarter of it at the zone's inner bound; zero, the
	// keys' own
	Speed float32
}

ZonesCfg is how the scroll zones start (Config.Zones); the settings screen changes them later.

type ZonesOpacity added in v0.6.0

type ZonesOpacity struct{ Opacity float32 }

ZonesOpacity sets how opaque the zones are at the picture's edge, Opacity 0 to 1 (Settings.ZonesOpacity). The settings screen alone.

func (ZonesOpacity) Command added in v0.6.0

func (ZonesOpacity) Command()

type Zoom

type Zoom struct {
	Camera camera.Camera
	Factor float32
	At     geom.Vec
}

Zoom scales Camera about the world point At: a Factor above 1 zooms in, below 1 out.

func (Zoom) Command

func (Zoom) Command()

Directories

Path Synopsis
Package cameratest is the cameras plugin's cameras for tests: one from above to draw or cull through when the camera itself is not under test, and a relief camera's keys.
Package cameratest is the cameras plugin's cameras for tests: one from above to draw or cull through when the camera itself is not under test, and a relief camera's keys.
internal
stick
Package stick is the cameras plugin's views of a world in relief: a camera on a stick, seen through orthographically or in perspective, an eye riding in a unit, and their control.
Package stick is the cameras plugin's views of a world in relief: a camera on a stick, seen through orthographically or in perspective, an eye riding in a unit, and their control.
topdown
Package topdown holds the cameras plugin's camera from above behind the camera.Camera contract, with its window arithmetic and wrapping.
Package topdown holds the cameras plugin's camera from above behind the camera.Camera contract, with its window arithmetic and wrapping.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL