- A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
- lengths are in any unit (ex: pixels)
- code snippets are in JavaScript
angleRad = angleDeg * Math.PI / 180;
| // listening to flash stage... | |
| // can't figure out the MouseCollision thing | |
| Main.stage.addEventListener(MouseEvent.MOUSE_MOVE, mousemove, false, 0, true); | |
| // ... | |
| private var tally:Number = 0; | |
| private function mousemove(event:MouseEvent):void |
| stage.addEventListener(MouseEvent.MOUSE_MOVE, mousemove, false, 0, true); | |
| scene3D.addEventListener(Scene3D.UPDATE_EVENT, update, false, 0, true); | |
| private function mousemove(event:MouseEvent):void | |
| { | |
| if (event.movementX != 0) { | |
| const mouseMoveX:Number = (event.movementX); | |
| spinX += mouseMoveX * 0.035; | |
| } |
| package game | |
| { | |
| import flare.basic.Scene3D; | |
| import flare.basic.Viewer3D; | |
| import flare.core.Camera3D; | |
| import flare.core.Mesh3D; | |
| import flare.core.Pivot3D; | |
| import flare.core.Texture3D; | |
| import flare.flsl.FLSLMaterial; | |
| import flare.physics.colliders.SphereCollider; |
| import irc, asyncdispatch, strutils, os, threadpool | |
| proc onIrcEvent(client: PAsyncIrc, event: TIrcEvent) {.async.} = | |
| case event.typ | |
| of EvConnected: | |
| discard | |
| of EvDisconnected, EvTimeout: | |
| await client.reconnect() | |
| of EvMsg: | |
| if event.cmd == MPrivMsg: |
| import macros | |
| macro eval(s: string): expr = | |
| result = parseStmt($s) | |
| eval("echo 5") |
| # option 1 | |
| let x = stdin.readAll | |
| echo "^ " & x | |
| # option 2 | |
| while not endoffile(stdin): | |
| let x = stdin.readLine | |
| echo "^ " & x |
| # werp.py :: toy programming language, lispish and concise. | |
| tokenize = lambda chars: chars.replace('(', ' ( ').replace(')', ' ) ').split() | |
| def read_from_tokens(tokens): | |
| if len(tokens) == 0: | |
| raise SyntaxError('Unexpected EOF') | |
| token = tokens.pop(0) | |
| if token == "(": | |
| L = [] |
| # docker ps, find the hash, e.g. b1d085e45f39 | |
| docker update --restart=always $1 |
| // | |
| // NSImageViewFill.swift | |
| // NSImageView with Fill Aspect Ratio | |
| // Swift 4.0+ | |
| // | |
| // Written by (source) https://stackoverflow.com/a/46262418/200041 | |
| // I take no credit in this but it's too awesome not to gist. | |
| // | |
| import Cocoa |