public static Color ToColor(this char character) { Color color = new Color(); switch (character) { case 'y': color = Color.Yellow; break; case 'r': color = Color.Red; break; case 'g': color = Color.Green; break; case 'o': color = Color.Orange; break; case 'b': color = Color.Blue; break; case 'w': color = Color.White; break; } return color; }
void Start() { currentlySelected = false; ctrl = Camera.main.GetComponent<cameraController>(); startcolor = GetComponent<Renderer>().material.color; factories = GetComponentsInChildren<UIReq>(); }
public void Initialise() { _primitives = new List<Cube>(); var random = new Random(); for (int i = 0; i < Constants.CubeCount; i++) { _primitives.Add(new Cube { Color = Color.Red, Position = new Vector3(random.Next(100) - 50, random.Next(100) - 50, -random.Next(100)), Radius = random.Next(100), Rotation = Vector3.Zero }); } //How to create a kernel and a channel? // _kernel = // _channel = _colour = Color.Beige; _kernel.Factory.NewCoroutine(ChangePosition); _kernel.Factory.NewCoroutine(ChangeColour); }
public CustomLine(int startLineNr, int endLineNr, Color customColor, bool readOnly) { this.StartLineNr = startLineNr; this.EndLineNr = endLineNr; this.Color = customColor; this.ReadOnly = readOnly; }
public Inventory(int SCREEN_WIDTH, int SCREEN_HEIGHT, Pantheon gameReference) { locationBoxes = new List<Rectangle>(); equippedBoxes = new List<Rectangle>(); types = new List<int>(); infoBox = new Rectangle(); movingBox = new Rectangle(); trashBox = new Rectangle(); tempStorage = new Item(); this.SCREEN_WIDTH = SCREEN_WIDTH; this.SCREEN_HEIGHT = SCREEN_HEIGHT; SetBoxes(); selected = -1; hoveredOver = -1; color = new Color(34, 167, 222, 50); trashColor = Color.White; inventorySelector = gameReference.Content.Load<Texture2D>("Inventory/InvSelect"); trashCan = gameReference.Content.Load<Texture2D>("Inventory/TrashCan"); nullImage = new Texture2D(gameReference.GraphicsDevice, 1,1); nullImage.SetData(new[] { new Color(0,0,0,0) }); }
public static void RenderPolygone(SpriteBatch spriteBatch, Texture2D texture, Polygon polygon, int lineThickness, Color color) { for (int i = 0; i < polygon.Points.Count; ++i) { RenderLine(spriteBatch, texture, polygon.Points[i], polygon.Edges[i], 1, lineThickness, color); } }
public string GetHexCode(Color c) { return string.Format("#{0}{1}{2}", c.R.ToString("X2"), c.G.ToString("X2"), c.B.ToString("X2")); }
/// <summary> /// Draw a rectangle. /// </summary> /// <param name="rectangle">The rectangle to draw.</param> /// <param name="color">The draw color.</param> public void DrawRectangle(Rectangle rectangle, Color color) { this.Draw(this.WhiteTexture, new Rectangle(rectangle.Left, rectangle.Top, rectangle.Width, 1), color); this.Draw(this.WhiteTexture, new Rectangle(rectangle.Left, rectangle.Bottom, rectangle.Width, 1), color); this.Draw(this.WhiteTexture, new Rectangle(rectangle.Left, rectangle.Top, 1, rectangle.Height), color); this.Draw(this.WhiteTexture, new Rectangle(rectangle.Right, rectangle.Top, 1, rectangle.Height + 1), color); }
internal void DrawSpriteGlyph(Texture2D texture, Vector4 dest, Vector4 source, Color color) { if (!m_DrawString_InProgress) Logging.Fatal("BeginDrawString() must be called before DrawSpriteGlyph()"); Vector4 uv = new Vector4( (float)source.X / texture.Width, (float)source.Y / texture.Height, (float)(source.X + source.Z) / texture.Width, (float)(source.Y + source.W) / texture.Height); VertexPositionTextureHueExtra[] v = new VertexPositionTextureHueExtra[4] { new VertexPositionTextureHueExtra(new Vector3(dest.X, dest.Y, m_DrawString_Depth), new Vector2(uv.X, uv.Y), color, Vector4.Zero), // top left new VertexPositionTextureHueExtra(new Vector3(dest.X + dest.Z, dest.Y, m_DrawString_Depth), new Vector2(uv.Z, uv.Y), color, Vector4.Zero), // top right new VertexPositionTextureHueExtra(new Vector3(dest.X, dest.Y + dest.W, m_DrawString_Depth), new Vector2(uv.X, uv.W), color, Vector4.Zero), // bottom left new VertexPositionTextureHueExtra(new Vector3(dest.X + dest.Z, dest.Y + dest.W, m_DrawString_Depth), new Vector2(uv.Z, uv.W), color, Vector4.Zero) // bottom right }; /*if (shadow != null) { Color shadow2 = new Color( shadow.Value.R, shadow.Value.G, shadow.Value.B, 128); for (int i = 0; i < 4; i++) { VertexPositionTextureHueExtra v0 = v[i]; v0.Hue = shadow.Value; v0.Position.Y += 1f; m_DrawString_VertexList.Add(v0); } }*/ for (int i = 0; i < 4; i++) m_DrawString_VertexList.Add(v[i]); }
public Model3DGroup Create(Color modelColor,string pictureName, Point3D startPos, double maxHigh) { try { Uri inpuri = new Uri(@pictureName, UriKind.Relative); BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.UriSource = inpuri; bi.EndInit(); ImageBrush imagebrush = new ImageBrush(bi); imagebrush.Opacity = 100; imagebrush.Freeze(); Point[] ptexture0 = { new Point(0, 0), new Point(0, 1), new Point(1, 0) }; Point[] ptexture1 = { new Point(1, 0), new Point(0, 1), new Point(1, 1) }; SolidColorBrush modelbrush = new SolidColorBrush(modelColor); Model3DGroup cube = new Model3DGroup(); Point3D uppercircle = startPos; modelbrush.Freeze(); uppercircle.Y = startPos.Y + maxHigh; cube.Children.Add(CreateEllipse2D(modelbrush, uppercircle, _EllipseHigh, new Vector3D(0, 1, 0))); cube.Children.Add(CreateEllipse2D(modelbrush, startPos, _EllipseHigh, new Vector3D(0, -1, 0))); cube.Children.Add(CreateEllipse3D(imagebrush, startPos, _EllipseHigh, maxHigh, ptexture0)); return cube; } catch (Exception ex) { throw ex; } }
public Texte(string message, Point position, Color couleur) { this.message = message; this.position = position; this.couleur = couleur; this.police = Fonte.Arial15; }
public override void OnInspectorGUI() { serObj.Update(); EditorGUILayout.LabelField("Overlays animated noise patterns", EditorStyles.miniLabel); EditorGUILayout.PropertyField(dx11Grain, new GUIContent("DirectX 11 Grain")); if (dx11Grain.boolValue && !(target as NoiseAndGrain).Dx11Support()) { EditorGUILayout.HelpBox("DX11 mode not supported (need DX11 GPU and enable DX11 in PlayerSettings)", MessageType.Info); } EditorGUILayout.PropertyField(monochrome, new GUIContent("Monochrome")); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(intensityMultiplier, new GUIContent("Intensity Multiplier")); EditorGUILayout.PropertyField(generalIntensity, new GUIContent(" General")); EditorGUILayout.PropertyField(blackIntensity, new GUIContent(" Black Boost")); EditorGUILayout.PropertyField(whiteIntensity, new GUIContent(" White Boost")); midGrey.floatValue = EditorGUILayout.Slider( new GUIContent(" Mid Grey (for Boost)"), midGrey.floatValue, 0.0f, 1.0f); if (monochrome.boolValue == false) { Color c = new Color(intensities.vector3Value.x,intensities.vector3Value.y,intensities.vector3Value.z,1.0f); c = EditorGUILayout.ColorField(new GUIContent(" Color Weights"), c); intensities.vector3Value = new Vector3(c.r, c.g, c.b); } if (!dx11Grain.boolValue) { EditorGUILayout.Separator(); EditorGUILayout.LabelField("Noise Shape"); EditorGUILayout.PropertyField(noiseTexture, new GUIContent(" Texture")); EditorGUILayout.PropertyField(filterMode, new GUIContent(" Filter")); } else { EditorGUILayout.Separator(); EditorGUILayout.LabelField("Noise Shape"); } softness.floatValue = EditorGUILayout.Slider( new GUIContent(" Softness"),softness.floatValue, 0.0f, 0.99f); if (!dx11Grain.boolValue) { EditorGUILayout.Separator(); EditorGUILayout.LabelField("Advanced"); if (monochrome.boolValue == false) { Vector3 temp = tiling.vector3Value; temp.x = EditorGUILayout.FloatField(new GUIContent(" Tiling (Red)"), tiling.vector3Value.x); temp.y = EditorGUILayout.FloatField(new GUIContent(" Tiling (Green)"), tiling.vector3Value.y); temp.z = EditorGUILayout.FloatField(new GUIContent(" Tiling (Blue)"), tiling.vector3Value.z); tiling.vector3Value = temp; } else { EditorGUILayout.PropertyField(monochromeTiling, new GUIContent(" Tiling")); } } serObj.ApplyModifiedProperties(); }
// From http://edu.cnzz.cn/show_3281.html public static GraphicsPath CalculateGraphicsPathFromBitmap(Bitmap bitmap, Color colorTransparent) { GraphicsPath graphicsPath = new GraphicsPath(); if (colorTransparent == Color.Empty) colorTransparent = bitmap.GetPixel(0, 0); for(int row = 0; row < bitmap.Height; row ++) { int colOpaquePixel = 0; for(int col = 0; col < bitmap.Width; col ++) { if(bitmap.GetPixel(col, row) != colorTransparent) { colOpaquePixel = col; int colNext = col; for(colNext = colOpaquePixel; colNext < bitmap.Width; colNext ++) if(bitmap.GetPixel(colNext, row) == colorTransparent) break; graphicsPath.AddRectangle(new Rectangle(colOpaquePixel, row, colNext - colOpaquePixel, 1)); col = colNext; } } } return graphicsPath; }
public void SetPixel(int x, int y, Color colour) { PixelData* p = PixelAt(x, y); p->Red = colour.R; p->Green = colour.G; p->Blue = colour.B; }
protected override Node Evaluate(Env env) { Guard.ExpectMinArguments(2, Arguments.Count, this, Index); Guard.ExpectMaxArguments(3, Arguments.Count, this, Index); Guard.ExpectAllNodes<Color>(Arguments.Take(2), this, Index); double weight = 50; if (Arguments.Count == 3) { Guard.ExpectNode<Number>(Arguments[2], this, Index); weight = ((Number) Arguments[2]).Value; } var colors = Arguments.Take(2).Cast<Color>().ToArray(); // Note: this algorithm taken from http://github.com/nex3/haml/blob/0e249c844f66bd0872ed68d99de22b774794e967/lib/sass/script/functions.rb var p = weight/100.0; var w = p*2 - 1; var a = colors[0].Alpha - colors[1].Alpha; var w1 = (((w*a == -1) ? w : (w + a)/(1 + w*a)) + 1)/2.0; var w2 = 1 - w1; var rgb = colors[0].RGB.Select((x, i) => x*w1 + colors[1].RGB[i]*w2).ToArray(); var alpha = colors[0].Alpha*p + colors[1].Alpha*(1 - p); var color = new Color(rgb[0], rgb[1], rgb[2], alpha); return color; }
/// <remarks> /// Returns the Color if the line <code>lineNr</code> has custom bg color /// otherwise returns <code>defaultColor</code> /// </remarks> public Color GetCustomColor(int lineNr, Color defaultColor) { foreach(CustomLine line in lines) if (line.StartLineNr <= lineNr && line.EndLineNr >= lineNr) return line.Color; return defaultColor; }
public void ChangeColor(Color newColor) { nextColor = newColor; currentColor = transitionColor; changingColor = true; colorChangeStartTime = Time.time; }
ContentPage CreatePage (Color backgroundColor) { _index++; var button = new Button () { Text = "next Page", }; button.Clicked += (sender, e) => { var page = CreatePage (Color.Green); _navigationPage.PushAsync (page); }; var contentPage = new ContentPage () { Content = new StackLayout () { BackgroundColor = backgroundColor, VerticalOptions = LayoutOptions.Fill, Children = { new Label () { Text = "page " + _index, }, } } }; return contentPage; }
/** * Pull all of our pixels off the texture (Unity stuff isn't thread safe, and this is faster) */ public BitmapData(Color[] _pixels, int _width, int _height) { height = _height; width = _width; pixels = _pixels; }
/// <summary> /// Generates a Windows 8 like skin based on a start color. /// </summary> /// <param name="baseColor">The base color</param> /// <param name="fontName">Font name</param> /// <param name="animated">set to true to generate "Hover" and "Clicked" skins</param> /// <returns>The skin</returns> public static YnSkin Generate(Color baseColor, string fontName, bool animated) { Color tempColor; YnSkin skin = new YnSkin(); // Default state skin.FontNameDefault = fontName; skin.FontDefault = YnG.Game.Content.Load<SpriteFont>(fontName); skin.TextColorDefault = Color.White; skin.BackgroundDefault = YnGraphics.CreateTexture(baseColor, 1, 1); skin.BorderDefault = null; // Borders are left blank // If the skin is "animated", generate data for "Hover" and "Clicked" states if (animated) { // Hover state : change only background color tempColor = Add(baseColor, 50, 50, 50); skin.BackgroundHover = YnGraphics.CreateTexture(tempColor, 1, 1); // Clicked state : invert background & text color skin.TextColorClicked = baseColor; skin.BackgroundClicked = YnGraphics.CreateTexture(Color.White, 1, 1); } return skin; }
public Emitter(Vector2 position, Texture2D sprite, Color color, int size) { this.position = position; this.sprite = sprite; this.color = color; this.size = size; }
public LandClass(string name, double fractalStart, double fractalEnd, Color baseColor) { this.name = name; this.altStart = fractalStart; this.altEnd = fractalEnd; this.color = baseColor; }
public void Generate2DTexture() { texture2D = new Texture2D(n,n,TextureFormat.ARGB32,true); int size = n*n; Color[] cols = new Color[size]; float u,v; int idx = 0; Color c = Color.white; for(int i = 0; i < n; i++) { u = i/(float)n; for(int j = 0; j < n; j++, ++idx) { v = j/(float)n; float noise = Mathf.PerlinNoise(u,v); c.r = c.g = c.b = noise; cols[idx] = c; } } texture2D.SetPixels(cols); texture2D.Apply(); renderer.material.SetTexture("g_tex", texture2D); //Color[] cs = texture3D.GetPixels(); //for(int i = 0; i < 10; i++) // Debug.Log (cs[i]); }
void Start() { Color randColor = new Color(Random.value, Random.value, Random.value); MeshRenderer[] renderers = GetComponentsInChildren<MeshRenderer>(); foreach(MeshRenderer r in renderers) r.material.color = randColor; }
public CashTick(WPos pos, Color color, int value) { this.font = Game.Renderer.Fonts["TinyBold"]; this.pos = pos; this.color = color; this.text = "{0}${1}".F(value < 0 ? "-" : "+", Math.Abs(value)); }
internal void DrawSpriteGlyphDF(Texture2D texture, Vector4 dest, Vector4 source, Color color, float font_scale) { if (!m_DrawString_InProgress) Logging.Fatal("BeginDrawString() must be called before DrawSpriteGlyph()"); Vector4 uv = new Vector4( (float)source.X / texture.Width, (float)source.Y / texture.Height, (float)(source.X + source.Z) / texture.Width, (float)(source.Y + source.W) / texture.Height); float smoothing = 0.4f * Math.Pow(0.333f, font_scale * 2f) + 0.05f; Vector4 extra = new Vector4(0, 0, smoothing, 2); VertexPositionTextureHueExtra[] v = new VertexPositionTextureHueExtra[4] { new VertexPositionTextureHueExtra(new Vector3(dest.X, dest.Y, m_DrawString_Depth), new Vector2(uv.X, uv.Y), color, extra), // top left new VertexPositionTextureHueExtra(new Vector3(dest.X + dest.Z, dest.Y, m_DrawString_Depth), new Vector2(uv.Z, uv.Y), color, extra), // top right new VertexPositionTextureHueExtra(new Vector3(dest.X, dest.Y + dest.W, m_DrawString_Depth), new Vector2(uv.X, uv.W), color, extra), // bottom left new VertexPositionTextureHueExtra(new Vector3(dest.X + dest.Z, dest.Y + dest.W, m_DrawString_Depth), new Vector2(uv.Z, uv.W), color, extra) // bottom right }; for (int i = 0; i < 4; i++) m_DrawString_VertexList.Add(v[i]); }
public Texte(string message, Point position) { this.message = message; this.position = position; this.couleur = Structure.Color.White; this.police = Fonte.Arial15; }
public AreaInfo(Rect theRect, int thePriority, string theName) { itsRect = theRect; itsPriority = thePriority; itsColor = new Color(Random.value,Random.value,Random.value); itsName = theName; }
public Texte(string message, Point position, Color couleur, Fonte police) { this.message = message; this.position = position; this.couleur = couleur; this.police = police; }
public void ShowIcon( string iName, string position, float scale ) { string itemName = iName.Replace(' ', '_'); image.sprite = ItemManager.Instance.GetItemTexture( itemName ); Color col = new Color(); col = Color.white; image.color = col; iconPos pos = new iconPos(); switch( position.ToLower() ) { case "middle": case "mid": case "m": pos = iconPos.middle; break; case "left": case "l": pos = iconPos.left; break; case "right": case "r": pos = iconPos.right; break; } image.GetComponent<Transform>().position = destinationTransforms[(int)pos].position; image.GetComponent<Transform>().localScale *= scale; }