Documentation
¶
Index ¶
- Constants
- Variables
- func DrawLabels(win *pixelgl.Window)
- type Camera
- type ChipClass
- type ChipInstance
- type ChipTool
- type CircuitBoard
- func (cb *CircuitBoard) AddChip(chip string, x, y int)
- func (cb *CircuitBoard) AddLamp(x, y int)
- func (cb *CircuitBoard) AddSwitch(x, y int)
- func (cb *CircuitBoard) AddWire(x1, y1, x2, y2 int)
- func (cb *CircuitBoard) CutThrough(a, b pixel.Vec)
- func (cb *CircuitBoard) Draw(win *pixelgl.Window)
- func (cb *CircuitBoard) GetSignal(p GridPoint) bool
- func (cb *CircuitBoard) Load()
- func (cb *CircuitBoard) MarshalJSON() ([]byte, error)
- func (cb *CircuitBoard) PressSwitch(x, y int)
- func (cb *CircuitBoard) Save()
- func (cb *CircuitBoard) SetSignal(p GridPoint, signal bool)
- func (cb *CircuitBoard) SplitWire(pos GridPoint)
- type Finger
- type GridPoint
- type Help
- type LampTool
- type Scissors
- type SwitchTool
- type Tool
- type UI
- type Wire
- type WireGroup
- type WireTool
- type Workspace
Constants ¶
View Source
const CUT_WIDTH = 1
View Source
const GRID_SIZE = 50.0
View Source
const HELP_TEXT = `` /* 250-byte string literal not displayed */
View Source
const HOLE_RADIUS = 7.0
View Source
const LAMP_RADIUS = GRID_SIZE / 2
View Source
const MAX_ZOOM = 2.0
View Source
const MIN_ZOOM = 0.5
View Source
const SWITCH_HEIGHT = GRID_SIZE
View Source
const SWITCH_WIDTH = GRID_SIZE
View Source
const WIRE_WIDTH = 3.0
Variables ¶
View Source
var ADD_WIRE_KEY = pixelgl.Key1
View Source
var ChipClasses = map[string]ChipClass{ "NOT": ChipClass{ InputsCount: 1, OutputsCount: 1, Delay: time.Second / 4, Logic: func(inputs []bool) []bool { return []bool{!inputs[0]} }, }, "AND": ChipClass{ InputsCount: 2, OutputsCount: 1, Delay: time.Second / 2, Logic: func(inputs []bool) []bool { return []bool{inputs[0] && inputs[1]} }, }, "OR": ChipClass{ InputsCount: 2, OutputsCount: 1, Delay: time.Second / 2, Logic: func(inputs []bool) []bool { return []bool{inputs[0] || inputs[1]} }, }, }
Functions ¶
func DrawLabels ¶
Types ¶
type ChipClass ¶
type ChipInstance ¶
func NewChipInstance ¶
func NewChipInstance(class string, pos GridPoint) ChipInstance
func (ChipInstance) HasInputAt ¶
func (ci ChipInstance) HasInputAt(pos GridPoint) bool
func (*ChipInstance) Process ¶
func (ci *ChipInstance) Process(cb *CircuitBoard)
type CircuitBoard ¶
type CircuitBoard struct { Filename string WireGroups map[GridPoint]*WireGroup Switches map[GridPoint]bool Lamps map[GridPoint]bool Chips []ChipInstance // contains filtered or unexported fields }
func NewCircuitBoard ¶
func NewCircuitBoard() *CircuitBoard
func (*CircuitBoard) AddChip ¶
func (cb *CircuitBoard) AddChip(chip string, x, y int)
func (*CircuitBoard) AddLamp ¶
func (cb *CircuitBoard) AddLamp(x, y int)
func (*CircuitBoard) AddSwitch ¶
func (cb *CircuitBoard) AddSwitch(x, y int)
func (*CircuitBoard) AddWire ¶
func (cb *CircuitBoard) AddWire(x1, y1, x2, y2 int)
func (*CircuitBoard) CutThrough ¶
func (cb *CircuitBoard) CutThrough(a, b pixel.Vec)
func (*CircuitBoard) Draw ¶
func (cb *CircuitBoard) Draw(win *pixelgl.Window)
func (*CircuitBoard) GetSignal ¶
func (cb *CircuitBoard) GetSignal(p GridPoint) bool
func (*CircuitBoard) Load ¶
func (cb *CircuitBoard) Load()
func (*CircuitBoard) MarshalJSON ¶
func (cb *CircuitBoard) MarshalJSON() ([]byte, error)
func (*CircuitBoard) PressSwitch ¶
func (cb *CircuitBoard) PressSwitch(x, y int)
func (*CircuitBoard) Save ¶
func (cb *CircuitBoard) Save()
func (*CircuitBoard) SetSignal ¶
func (cb *CircuitBoard) SetSignal(p GridPoint, signal bool)
func (*CircuitBoard) SplitWire ¶
func (cb *CircuitBoard) SplitWire(pos GridPoint)
type SwitchTool ¶
type SwitchTool struct { }
func (*SwitchTool) Update ¶
func (st *SwitchTool) Update(win *pixelgl.Window, cb *CircuitBoard, mp pixel.Vec)
type UI ¶
type WireGroup ¶
func (WireGroup) ConnnectedPoints ¶
func (*WireGroup) SetSignal ¶
func (wg *WireGroup) SetSignal(s bool, cb *CircuitBoard)
Click to show internal directories.
Click to hide internal directories.