public byte GetByte() { string s = Meth.Sin(this._Seed).ToString(); this._Seed = (this._Seed + 1337) % Meth.Tau; return((byte)(int.Parse(s.Substring(s.Length - 3)) % 256)); }
//public Tuple<Point, Point> GetMousePosition() //{ // Point tile = this.LocalMousePosition / this.Parent.Tilesize; // Point col = (this.LocalMousePosition - tile * this.Parent.Tilesize) / (this.Parent.Tilesize / this.Parent.TileCollisionResolution); // return new Tuple<Point, Point>(tile, col); //} public override void Update() { if (this.MouseArea.IsClicked) { bool key = this.MouseArea.ClickedBy(Key.MouseLeft); Point m = (this.LocalMousePosition - new Vector(this.AlignmentZoom.RectSize.X, 0)) / (this.Parent.TileSize / this.Parent.TileCollisionResolution) / this.Zoom; foreach (Point p in Line.Trace(this.LastPosition, m).Where(item => (new Rect(0, this.TileCount * this.Parent.TileCollisionResolution)).Contains(item))) { Point tile = p / this.Parent.TileCollisionResolution; Point col = p % this.Parent.TileCollisionResolution; this.Colset[tile.X, tile.Y][col.X, col.Y] = (byte)(key ? 1 : 0); this.ColPreviewSource[tile.X * this.Parent.TileCollisionResolution.X + col.X, tile.Y *this.Parent.TileCollisionResolution.Y + col.Y] = key ? Color.White : Color.Transparent; } this.LastPosition = m; } byte b = (byte)((Meth.Sin(this.Runtime / 120.0 * Meth.Tau) + 1) / 2 * 85); this.ColPreview.Color = new Color(b) ^ 170; }
public static Vector FromAngle(double _angle, double _length = 1) => new Vector(Meth.Cos(_angle), Meth.Sin(_angle)) * _length;