public static void initStars() { for (var i = 0; i < sc; i++) { stars[i] = new star(JLib.rollDice(50) - 25, JLib.rollDice(50) - 25, JLib.rollDice(31)); } }
public static Text Init( this Text text, Transform parent, string content = "", Vector2 size = default(Vector2), int font_size = 50, string font = "Arial", Color?color = null, TextAnchor alignment = TextAnchor.MiddleCenter, JLib.TextFitMode?fit = null) { text.transform.SetParent(parent, false); text.text = content; text.GetComponent <RectTransform>().sizeDelta = size; text.fontSize = font_size; //text.font = Font(font); text.font = Resources.GetBuiltinResource <Font>("Arial.ttf"); text.alignment = alignment; if (color.HasValue) { text.color = color.Value; } else { text.color = Color.black; } if (fit.HasValue) { var fitter = text.gameObject.AddComponent <ContentSizeFitter>(); if (fit.Value == JLib.TextFitMode.ShrinkX || fit.Value == JLib.TextFitMode.StretchX) { fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; if (fit.Value == JLib.TextFitMode.ShrinkX) { text.Add <RectShrinker>().Init(size.x, JLib.Axes(true, false, false)); } } else if (fit.Value == JLib.TextFitMode.ShrinkY || fit.Value == JLib.TextFitMode.StretchY) { fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; if (fit.Value == JLib.TextFitMode.ShrinkY) { text.Add <RectShrinker>().Init(size.x, JLib.Axes(true, false, false)); } } } else { UnityEngine.Object.Destroy(text.Get <ContentSizeFitter>()); UnityEngine.Object.Destroy(text.Get <RectShrinker>()); } return(text); }
private void tick_Tick(object sender, EventArgs e) { ticks += 0.01; int R = (int)((Math.Sin(ticks) + 1) * 127) / 2; int B = (int)((Math.Cos(ticks) + 1) * 127) / 2; int G = (int)(-((Math.Sin(ticks) - 1)) * 127) / 2; int Ri = (int)((Math.Sin(ticks) + 1) * 127) / 4; int Bi = (int)((Math.Cos(ticks) + 1) * 127) / 4; int Gi = (int)(-((Math.Sin(ticks) - 1)) * 127) / 4; Color hshift = Color.FromArgb(R, G, B); Color iboxsh = Color.FromArgb(Ri, Gi, Bi); rect(0, 0, canvas.Width, canvas.Height, hshift); logo.BackColor = hshift; tickerpanel.BackColor = iboxsh; msg.BackColor = iboxsh; msg.Location = new Point(msg.Location.X - 5, msg.Location.Y); if (msg.Location.X < -msg.Width - 10) { msg.Location = new Point(Width + 100, msg.Location.Y); tickm++; try { msg.Text = tickerms[tickm]; } catch { tickm = 0; msg.Text = tickerms[tickm]; } } for (var i = 0; i < sc; i++) { stars[i].z -= 0.2; if (stars[i].z <= 0) { stars[i].x = JLib.rollDice(50) - 25; stars[i].y = JLib.rollDice(50) - 25; stars[i].z = MAX_DEPTH; } double k = 128.0 / stars[i].z; int px = (int)(stars[i].x * k + canvas.Width / 2); int py = (int)(stars[i].y * k + canvas.Height / 2); if (px >= 0 && px <= canvas.Width && py >= 0 && py <= canvas.Height) { float size = (float)((1 - stars[i].z / 32.0) * 5); int shade = (int)((1 - stars[i].z / 32.0) * 255); rect(px, py, size, size, Color.FromArgb(shade, shade, shade)); } } }
public static int NumAxes(this Vector3 v) { v = JLib.ReduceToAxes(v); return((int)(v.x + v.y + v.z)); }