public Armour(string aName, char aGlyph, Colour aColour, Location3i l, ArmourLocation aArmourLocation) : base(ItemType.Armour, aName, aGlyph, aColour, l) { ArmourLocation = aArmourLocation; Condition = 100; }
private Colour ExaggerateColour(int iterations, Colour mean) { var redness = Extremise(mean.Redness, iterations); var greenness = Extremise(mean.Greenness, iterations); var blueness = Extremise(mean.Blueness, iterations); return new Colour(redness, greenness, blueness); }
/// <summary> /// Creates a (base) instance of Potion/ /// </summary> /// <param name="aType">The type of potion</param> /// <param name="aName">The name of the potion.</param> /// <param name="aColor">The color of the potion.</param> public Potion(PotionType aPotionType, PotionStrength aPotionStrength, string aName, Colour aColor) : base(ItemType.Potion, aName, '!', aColor) { PotionType = aPotionType; PotionStrength = aPotionStrength; }
public void DrawBox(int x, int y, int height, int width, Colour colour) { DrawLine(x, y, (x + width), y, colour); DrawLine((x + width), y, (x + width), (y + height), colour); DrawLine((x + width), (y + height), x, (y + height), colour); DrawLine(x, (y + height), x, y, colour); }
public void LineDeleted(Colour lineColour) { lineCounts.Increment(lineColour); Messenger<Colour, int>.Broadcast(Events.LineDeleted, lineColour, GetLineCountForColour(lineColour)); GAHelper.LevelLineDeleted(lineColour); }
protected override void LoadFromStream(Stream stream) { base.LoadFromStream(stream); GraphicsMode = (CompositionMode)stream.ReadBEUInt16(); OpColour = new Colour(stream.ReadBEUInt16(), stream.ReadBEUInt16(), stream.ReadBEUInt16()); }
private void SetColour(Colour colour) { if(sprite != null) sprite.SetSprite("LineInner" + colour.ToString()); SetLayer(colour); }
/// <summary> /// Player /// </summary> /// <param name="aPlayerName"></param> /// <param name="aLocation"></param> public Player(string aPlayerName, Location3i aLocation) : base() { // Create the players key-chain KeyChain = new KeyChain(); // Create the players wallet. Wallet = new Currency(0); G = '@'; Name = aPlayerName; Location = aLocation; C = new Colour() { FG = ConsoleColor.Gray }; Stats = new Stats() { Agility = 2, Charisma = 4, Endurance = 7, Intelligence = 7, Luck = 4, Perception = 2, Strength = 7, }; Initialize(); }
public void WhenGivenDifferentValues_ReturnsFalse() { var x = new Colour(0f, 1f, 0f); var y = new Colour(360f, 1f, 1f); x.Equals(y).Should().BeFalse(); }
public Block(Axis axis, Colour colour) : this(new List<Tuple<Axis, Colour>>() { new Tuple<Axis, Colour>(axis, colour) }) { }
public void WhenGivenEqualValues_ReturnsTrue() { var x = new Colour(360f, 1f, 1f); var y = new Colour(360f, 1f, 1f); x.Equals(y).Should().BeTrue(); }
void DoHook() { var creature = (this.ReceivedEvent as Hook).Creature; var colour = (this.ReceivedEvent as Hook).Colour; if (this.TotalRendezvous == 0) { this.TotalStoppedCreatures++; this.DoPostRoundProcessing(); return; } if (this.FirstHooker == null) { this.FirstHooker = creature; this.FirstColour = colour; } else { this.Send(this.FirstHooker, new Hook(creature, colour)); this.Send(creature, new Hook(this.FirstHooker, this.FirstColour)); this.FirstHooker = null; this.TotalRendezvous = this.TotalRendezvous - 1; } }
private ConsoleColor MatchColour(Colour colour) { ConsoleColor matchColour; switch (colour) { case Colour.Red: matchColour = ConsoleColor.Red; break; case Colour.Green: matchColour = ConsoleColor.Green; break; case Colour.Blue: matchColour = ConsoleColor.Blue; break; case Colour.Yellow: matchColour = ConsoleColor.Yellow; break; case Colour.Black: matchColour = ConsoleColor.Black; break; default: throw new ArgumentException("Unknown colour type."); } return matchColour; }
/// <summary> /// creates a new weapon /// </summary> /// <param name="aName">the name of the weapon</param> /// <param name="aGlyph">the weapon glyph</param> /// <param name="aColor">the weapon colour</param> /// <param name="l">the weapon location.</param> /// <param name="aWProps">weapon properties</param> /// <param name="aLoc">worn location</param> /// <param name="aSubType">weapon subtype</param> public Weapon(string aName, char aGlyph, Colour aColor, Location3i l, WeaponProperties aWProps, WeaponLocation aLoc, WeaponSubType aSubType) : base(ItemType.Weapon, aName, aGlyph, aColor, l) { WeaponProperties = aWProps; WeaponSubType = aSubType; WeaponLocation = aLoc; }
public void WhenGivenEqualColour_ReturnsTrue() { var x = new Colour(360f, 1f, 1f); Object y = new Colour(360f, 1f, 1f); x.Equals(y).Should().BeTrue(); }
public void Plot(char character, int x, int y, Layer layer, Colour colour) { var characterLines = charmap[character] as Line[]; for (int i = 0; i < characterLines.Length; i++) { layer.DrawLine(characterLines[i].Start.X + x, characterLines[i].Start.Y + y, characterLines[i].End.X + x, characterLines[i].End.Y + y, colour); } }
public void WhenGivenValues_ReturnsInitializedColour() { var colour = new Colour(1f, 1f, 1f); colour.H.Should<float>().Be(1f); colour.S.Should<float>().Be(1f); colour.L.Should<float>().Be(1f); }
/// <summary> /// Creates a new instance of <see cref="Actor"/> with the specified glyph /// and colour. /// </summary> public Actor(string aName, char aGlyph, Colour aColor, Location3i aLocation) : this() { Location = aLocation; Name = aName; G = aGlyph; C = aColor; }
void OnTargetHit(Colour targetColour, int hits) { //Debug.Log("Hit event! " + targetColour + "hits " + hits); targetHits.UpdateHits(targetColour, hits); if(targetHits.AllTargetsHaveHitsGreaterOrEqualTo(GOAL_TARGET_HITS)) Messenger.Broadcast(Events.LevelComplete); }
public void LineDrawn(Colour colour) { //Debug.Log ("LineDrawn: " + (lineColour.HasValue ? lineColour.ToString() : "null")); lineCounts.Decrement(colour); Messenger<Colour, int>.Broadcast(Events.LineDrawn, colour, GetLineCountForColour(colour)); GAHelper.LevelLineCreated(colour); }
public void Write(string value, int x, int y, Colour colour) { for (int i = 0; i < value.Length; i++) { var character = value[i]; font.Plot(character, (x + charWidth) * i, y, layer, colour); } }
private void SetButtonVisibilityForColour(Colour colour) { if(lineCounts.GetLineCountForColour(colour) > 0) return; var button = buttons.Where(x => x.Colour == colour).Single(); NGUITools.SetActive(button.gameObject, false); }
public GridPoint(Vector vector, Colour colour = Colour.None) { this.Vector = vector; this.Colour = colour; this.Above = vector + new Vector(0, 1); this.Below = vector + new Vector(0, -1); this.Left = vector + new Vector(-1, 0); this.Right = vector + new Vector(1, 0); }
/// <summary> /// Creates a new instance of an Item /// </summary> /// <param name="aItemType">The type of item this is.</param> /// <param name="aName">The name of the item to create</param> /// <param name="aGlyph">The glyph used to represent the item on screen.</param> /// <param name="aColor">The color of the item.</param> /// <param name="aLocation">The location of the item</param> public Item(ItemType aItemType, string aName, char aGlyph, Colour aColor, Location3i aLocation) { ItemType = aItemType; // Set the item type of this item. Name = aName; // Set the name of the item G = aGlyph; // Set the glyph C = aColor; // Set the color Location = aLocation; // The the location }
public void Colour_Constructor_does_not_limit_red_to_one() { float red = 1.5f; float green = 1.0f; float blue = 0.5f; var colour = new Colour(red, green, blue); Assert.AreEqual(colour.Red, 1.5f, EPSILON); }
public void Colour_Constructor_returns_object_given_valid_parameters() { float red = 0.0f; float green = 1.0f; float blue = 0.5f; var colour = new Colour(red, green, blue); Assert.IsNotNull(colour); }
public Resource(Texture2D sprite, Colour colour, Island.IslandType islandType) : base(sprite) { Colour = colour; scale = new Vector2(0.3f); IsCarried = false; this.islandType = islandType; Debug.WriteLine("Resource Island Type = " + islandType); }
public Block(Axis axis1, Colour colour1, Axis axis2, Colour colour2, Axis axis3, Colour colour3) : this(new List<Tuple<Axis, Colour>>() { new Tuple<Axis, Colour>(axis1, colour1), new Tuple<Axis, Colour>(axis2, colour2), new Tuple<Axis, Colour>(axis3, colour3) }) { }
// creates a new boat matching the specified colour, loading the sprite from the contentmanager public static Resource InitializeFromIslandType(Colour colour, Island.IslandType islandType, ContentManager content) { // retrieve texture name matching specified colour string textureName = resources[islandType]; // load the texture specified from a folder named Resources Texture2D sprite = content.Load<Texture2D>("Cargo/" + textureName); // create a new entity using the loaded sprite return new Resource(sprite, colour, islandType); }
public void Increment(Colour colour) { if(colour == Colour.Purple) PurpleLines++; else if(colour == Colour.Green) GreenLines++; else if(colour == Colour.Blue) BlueLines++; else OrangeLines++; }
public IEnumerable <IMapObject> Create(UniqueNumberGenerator generator, Box box, string texture, int roundfloats) { var length = Math.Max(1, Math.Abs((int)box.Length)); var height = box.Height; var flatten = (float)_flattenFactor.Value; var text = _text.GetValue(); var family = _fontChooser.GetFontFamily(); var style = Enum.GetValues(typeof(FontStyle)).OfType <FontStyle>().FirstOrDefault(fs => family.IsStyleAvailable(fs)); if (!family.IsStyleAvailable(style)) { family = FontFamily.GenericSansSerif; } var set = new List <Polygon>(); var sizes = new List <RectangleF>(); using (var bmp = new Bitmap(1, 1)) { using (var g = Graphics.FromImage(bmp)) { using (var font = new Font(family, length, style, GraphicsUnit.Pixel)) { for (var i = 0; i < text.Length; i += 32) { using (var sf = new StringFormat(StringFormat.GenericTypographic)) { var rem = Math.Min(text.Length, i + 32) - i; var range = Enumerable.Range(0, rem).Select(x => new CharacterRange(x, 1)).ToArray(); sf.SetMeasurableCharacterRanges(range); var reg = g.MeasureCharacterRanges(text.Substring(i, rem), font, new RectangleF(0, 0, float.MaxValue, float.MaxValue), sf); sizes.AddRange(reg.Select(x => x.GetBounds(g))); } } } } } var xOffset = box.Start.X; var yOffset = box.End.Y; for (var ci = 0; ci < text.Length; ci++) { var c = text[ci]; var size = sizes[ci]; var gp = new GraphicsPath(); gp.AddString(c.ToString(CultureInfo.InvariantCulture), family, (int)style, length, new PointF(0, 0), StringFormat.GenericTypographic); gp.Flatten(new System.Drawing.Drawing2D.Matrix(), flatten); var polygons = new List <Polygon>(); var poly = new List <PolygonPoint>(); for (var i = 0; i < gp.PointCount; i++) { var type = gp.PathTypes[i]; var point = gp.PathPoints[i]; poly.Add(new PolygonPoint(point.X + xOffset, -point.Y + yOffset)); if ((type & 0x80) == 0x80) { polygons.Add(new Polygon(poly)); poly.Clear(); } } var tri = new List <Polygon>(); Polygon polygon = null; foreach (var p in polygons) { if (polygon == null) { polygon = p; tri.Add(p); } else if (p.CalculateWindingOrder() != polygon.CalculateWindingOrder()) { polygon.AddHole(p); } else { polygon = null; tri.Add(p); } } foreach (var pp in tri) { try { P2T.Triangulate(pp); set.Add(pp); } catch { // Ignore } } xOffset += size.Width; } var zOffset = box.Start.Z; foreach (var polygon in set) { foreach (var t in polygon.Triangles) { var points = t.Points.Select(x => new Vector3((float)x.X, (float)x.Y, zOffset).Round(roundfloats)).ToList(); var faces = new List <Vector3[]>(); // Add the vertical faces var z = new Vector3(0, 0, height).Round(roundfloats); for (var j = 0; j < points.Count; j++) { var next = (j + 1) % points.Count; faces.Add(new[] { points[j], points[j] + z, points[next] + z, points[next] }); } // Add the top and bottom faces faces.Add(points.ToArray()); faces.Add(points.Select(x => x + z).Reverse().ToArray()); // Nothing new here, move along var solid = new Solid(generator.Next("MapObject")); solid.Data.Add(new ObjectColor(Colour.GetRandomBrushColour())); foreach (var arr in faces) { var face = new Face(generator.Next("Face")) { Plane = new Plane(arr[0], arr[1], arr[2]), Texture = { Name = texture } }; face.Vertices.AddRange(arr.Select(x => x.Round(roundfloats))); solid.Data.Add(face); } solid.DescendantsChanged(); yield return(solid); } } }
//-------------------------------------------------------------- //-------------------------------------------------------------- public static RLColor ToRLColor(this Colour colour) { return(new RLColor(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), colour.GetAlpha())); }
public static void Initialise() { ConfiguredLaptop = new ConfiguredLaptop { Laptop = new Laptop { Id = new Guid("a99a8e22-52f7-4f53-b443-ec2519cd34df"), Name = "DELL XPS 13", Price = 350.00M } }; var ram = new Ram { Id = new Guid("6912564b-5052-47b2-8e2d-f90e5e556556"), ConfigurationType = ConfigurationItemName.Ram, Name = "1GB", Price = 65.00M }; var colour = new Colour { Id = new Guid("34ee3871-7b6f-464a-ba3e-3dd3197ca69e"), ConfigurationType = ConfigurationItemName.Colour, Name = "Red", Price = 30.00M }; //TODO: Create List of Storage devices. var storage = new Storage { ConfigurationType = ConfigurationItemName.Storage, Id = new Guid("ea634923-7e35-449d-8c8b-1d7b17865a9b"), Name = "256GB SSD", Price = 120.00M }; ConfiguredLaptop.ConfigurationItems.Add(ram); ConfiguredLaptop.ConfigurationItems.Add(ram); ConfiguredLaptop.ConfigurationItems.Add(ram); ConfiguredLaptopSame = new ConfiguredLaptop { Laptop = new Laptop { Id = new Guid("a99a8e22-52f7-4f53-b443-ec2519cd34df"), Name = "DELL XPS 13", Price = 350.00M } }; ram = new Ram { Id = new Guid("6912564b-5052-47b2-8e2d-f90e5e556556"), ConfigurationType = ConfigurationItemName.Ram, Name = "1GB", Price = 65.00M }; colour = new Colour { Id = new Guid("34ee3871-7b6f-464a-ba3e-3dd3197ca69e"), ConfigurationType = ConfigurationItemName.Colour, Name = "Red", Price = 30.00M }; storage = new Storage { ConfigurationType = ConfigurationItemName.Storage, Id = new Guid("ea634923-7e35-449d-8c8b-1d7b17865a9b"), Name = "256GB SSD", Price = 120.00M }; ConfiguredLaptopSame.ConfigurationItems.Add(ram); ConfiguredLaptopSame.ConfigurationItems.Add(ram); ConfiguredLaptopSame.ConfigurationItems.Add(ram); ConfiguredLaptopDifferent = new ConfiguredLaptop { Laptop = new Laptop { Id = new Guid("a99a8e22-52f7-4f53-b443-ec2519cd34df"), Name = "DELL XPS 15", Price = 350.00M } }; ram = new Ram { Id = new Guid("6912564b-5052-47b2-8e2d-f90e5e556556"), ConfigurationType = ConfigurationItemName.Ram, Name = "1GB", Price = 65.00M }; colour = new Colour { Id = new Guid("34ee3871-7b6f-464a-ba3e-3dd3197ca69e"), ConfigurationType = ConfigurationItemName.Colour, Name = "Red", Price = 30.00M }; storage = new Storage { ConfigurationType = ConfigurationItemName.Storage, Id = new Guid("ea634923-7e35-449d-8c8b-1d7b17865a9b"), Name = "256GB SSD", Price = 120.00M }; ConfiguredLaptopDifferent.ConfigurationItems.Add(ram); ConfiguredLaptopDifferent.ConfigurationItems.Add(ram); ConfiguredLaptopDifferent.ConfigurationItems.Add(ram); }
public static _ATHToken Read(string source, ref int position, _ATHLexer lexer, Colour expressionColour) { try { var expression = lexer.ReadExpression(source, ref position, expressionColour, typeof(SemicolonToken)); return(new ExpressionOrCommandToken(expression)); } catch { StringBuilder commandBuilder = new StringBuilder(); int bracketDepth = 0; while (bracketDepth != 0 || source[position] != ')') { if (source[position] == '(') { bracketDepth++; } else if (source[position] == ')') { bracketDepth--; } commandBuilder.Append(source[position]); position++; } return(new ExpressionOrCommandToken(commandBuilder.ToString())); } }
public CellVisualiser(IRenderer renderer) { m_renderer = renderer; m_scene = m_renderer.GetNewScene(); m_positions = new List <List <Vector3d> >(); m_random = new Random(); m_renderArrays = new RenderArrays3d(); m_renderArrays.Positions = new List <Vector3d>(); m_renderArrays.Colours = new List <Colour>(); m_scene.CreateCamera(); m_scene.SetCurrentCamera(0); m_scene.RenderArrays3d.Add(m_renderArrays); m_baseColours = new Colour[11]; m_baseColours[00] = new Colour() { R = 1.0f, G = 0.0f, B = 0.0f, A = 0.0f }; m_baseColours[01] = new Colour() { R = 0.0f, G = 1.0f, B = 0.0f, A = 0.0f }; m_baseColours[02] = new Colour() { R = 0.0f, G = 0.0f, B = 1.0f, A = 0.0f }; m_baseColours[03] = new Colour() { R = 1.0f, G = 1.0f, B = 0.0f, A = 0.0f }; m_baseColours[04] = new Colour() { R = 0.0f, G = 1.0f, B = 1.0f, A = 0.0f }; m_baseColours[05] = new Colour() { R = 1.0f, G = 0.5f, B = 0.5f, A = 0.0f }; m_baseColours[06] = new Colour() { R = 0.5f, G = 1.0f, B = 0.5f, A = 0.0f }; m_baseColours[07] = new Colour() { R = 0.5f, G = 0.5f, B = 1.0f, A = 0.0f }; m_baseColours[08] = new Colour() { R = 1.0f, G = 1.0f, B = 0.5f, A = 0.0f }; m_baseColours[09] = new Colour() { R = 0.5f, G = 1.0f, B = 1.0f, A = 0.0f }; m_baseColours[10] = new Colour() { R = 1.0f, G = 0.5f, B = 1.0f, A = 0.0f }; LoadFile("C:/Users/Tim/Desktop/UbuntuScratch/chasteOutput/OverlappingSpheres/results_from_time_0/results.viznodes"); }
/// <summary> /// Constructor. /// </summary> /// <param name="colour"></param> public ColourSource(Colour colour) { this.colour = colour; }
public Wizzard GetById(int id) { string sqLite = @"select * from Wizzard left join Species on Wizzard.SpeciesId = Species.Id left join Gender on Wizzard.GenderId = Gender.Id left join House on Wizzard.HouseId = House.Id left join Ancestry on Wizzard.AncestryId = Ancestry.Id left join Colour eye on Wizzard.EyeColourId = eye.Id left join Colour hair on Wizzard.HairColourId = hair.Id left join Wand on Wizzard.WandId = Wand.Id left join Material mWood on Wand.WoodMaterialId = mWood.Id left join MaterialType mtWood on mWood.MaterialTypeId = mtWood.Id left join Material mCore on Wand.CoreMaterialId = mCore.Id left join MaterialType mtCore on mCore.MaterialTypeId = mtCore.Id left join Patronus on Wizzard.PatronusId = Patronus.Id where Wizzard.Id = " + id + ";"; SQLiteConnection connection = new SQLiteConnection(connectionString); Wizzard wizzard = connection.Query <Wizzard> (sqLite, new[] { typeof(Wizzard), typeof(Species), typeof(Gender), typeof(House), typeof(Ancestry), typeof(Colour), typeof(Colour), typeof(Wand), typeof(Material), typeof(MaterialType), typeof(Material), typeof(MaterialType), typeof(Patronus) } , objects => { Wizzard _wizzard = objects[0] as Wizzard; Species species = objects[1] as Species; Gender gender = objects[2] as Gender; House house = objects[3] as House; Ancestry ancestry = objects[4] as Ancestry; Colour eyeColour = objects[5] as Colour; Colour hairColour = objects[6] as Colour; Wand wand = objects[7] as Wand; Material woodMaterial = objects[8] as Material; MaterialType mt1 = objects[9] as MaterialType; Material coreMaterial = objects[10] as Material; MaterialType mt2 = objects[11] as MaterialType; Patronus patronus = objects[12] as Patronus; _wizzard.Species = species; _wizzard.Gender = gender; _wizzard.House = house; _wizzard.Ancestry = ancestry; _wizzard.EyeColour = eyeColour; _wizzard.HairColour = hairColour; _wizzard.Wand = wand; if (wand != null) { wand.WoodMaterial = woodMaterial; if (woodMaterial != null) { wand.WoodMaterial.MaterialType = mt1; } wand.CoreMaterial = coreMaterial; if (coreMaterial != null) { wand.CoreMaterial.MaterialType = mt2; } } _wizzard.Patronus = patronus; return(_wizzard); }, splitOn: "Id,Id,Id,Id,Id,Id,Id,Id,Id,Id,Id,Id").FirstOrDefault(); return(wizzard); }
public void setColour(Colour newCol) { tag = newCol.ToString(); }
public IEnumerable <MapObject> Create(IDGenerator generator, Box box, ITexture texture, int roundDecimals) { var crossSides = (int)_crossSides.GetValue(); if (crossSides < 3) { yield break; } var crossWidth = _crossRadius.GetValue() * 2; if (crossWidth < 1) { yield break; } var crossMakeHollow = _crossMakeHollow.GetValue(); var crossArc = !crossMakeHollow ? 360 : (int)_crossArc.GetValue(); if (crossArc < 1) { yield break; } var crossStartAngle = (int)_crossStartAngle.GetValue(); if (crossStartAngle < 0 || crossStartAngle > 359) { yield break; } var crossWallWidth = _crossWallWidth.GetValue(); if (crossWallWidth < 1) { yield break; } var ringSides = (int)_ringSides.GetValue(); if (ringSides < 3) { yield break; } var ringArc = (int)_ringArc.GetValue(); if (ringArc < 1) { yield break; } var ringStartAngle = (int)_ringStartAngle.GetValue(); if (ringStartAngle < 0 || ringStartAngle > 359) { yield break; } var rotationHeight = _rotationHeight.GetValue(); // Sort of a combination of cylinder and pipe brushes var width = box.Width; var length = box.Length; var height = box.Height; var majorPrimary = (width - crossWidth) / 2; // Primary = donut circle var minorPrimary = (length - crossWidth) / 2; var majorSecondaryOuter = crossWidth / 2; // Secondary = cross section circle var minorSecondaryOuter = height / 2; // Outer = Outer ring var majorSecondaryInner = (crossWidth - crossWallWidth) / 2; // Inner = inner ring (hollow only) var minorSecondaryInner = (height - crossWallWidth) / 2; var ringStart = DMath.DegreesToRadians(ringStartAngle); var ringAngle = DMath.DegreesToRadians(ringArc) / ringSides; var crossStart = DMath.DegreesToRadians(crossStartAngle); var crossAngle = DMath.DegreesToRadians(crossArc) / crossSides; var heightAdd = rotationHeight / ringSides; // Rotate around the ring, generating each cross section var ringOuterSections = new List <Coordinate[]>(); var ringInnerSections = new List <Coordinate[]>(); for (var i = 0; i < ringSides + 1; i++) { var ring = ringStart + i * ringAngle; var rxval = box.Center.X + majorPrimary * DMath.Cos(ring); var ryval = box.Center.Y + minorPrimary * DMath.Sin(ring); var rzval = box.Center.Z; var crossSecOuter = new Coordinate[crossSides + 1]; var crossSecInner = new Coordinate[crossSides + 1]; for (var j = 0; j < crossSides + 1; j++) { var cross = crossStart + j * crossAngle; var xval = majorSecondaryOuter * DMath.Cos(cross) * DMath.Cos(ring); var yval = majorSecondaryOuter * DMath.Cos(cross) * DMath.Sin(ring); var zval = minorSecondaryOuter * DMath.Sin(cross); crossSecOuter[j] = new Coordinate(xval + rxval, yval + ryval, zval + rzval).Round(roundDecimals); if (!crossMakeHollow) { continue; } xval = majorSecondaryInner * DMath.Cos(cross) * DMath.Cos(ring); yval = majorSecondaryInner * DMath.Cos(cross) * DMath.Sin(ring); zval = minorSecondaryInner * DMath.Sin(cross); crossSecInner[j] = new Coordinate(xval + rxval, yval + ryval, zval + rzval).Round(roundDecimals); } ringOuterSections.Add(crossSecOuter); ringInnerSections.Add(crossSecInner); } // Create the solids var colour = Colour.GetRandomBrushColour(); for (var i = 0; i < ringSides; i++) { var vertical = Coordinate.UnitZ * heightAdd * i; var nexti = i + 1; if (crossMakeHollow) { // Use pipe cross sections var outerPoints = ringOuterSections[i]; var nextOuterPoints = ringOuterSections[nexti]; var innerPoints = ringInnerSections[i]; var nextInnerPoints = ringInnerSections[nexti]; for (var j = 0; j < crossSides; j++) { var nextj = j + 1; var faces = new List <Coordinate[]>(); faces.Add(new[] { outerPoints[j], outerPoints[nextj], nextOuterPoints[nextj], nextOuterPoints[j] }.Select(x => x + vertical).ToArray()); faces.Add(new[] { nextInnerPoints[j], nextInnerPoints[nextj], innerPoints[nextj], innerPoints[j] }.Select(x => x + vertical).ToArray()); faces.Add(new[] { innerPoints[nextj], nextInnerPoints[nextj], nextOuterPoints[nextj], outerPoints[nextj] }.Select(x => x + vertical).ToArray()); faces.Add(new[] { outerPoints[j], nextOuterPoints[j], nextInnerPoints[j], innerPoints[j] }.Select(x => x + vertical).ToArray()); faces.Add(new[] { innerPoints[j], innerPoints[nextj], outerPoints[nextj], outerPoints[j] }.Select(x => x + vertical).ToArray()); faces.Add(new[] { nextOuterPoints[j], nextOuterPoints[nextj], nextInnerPoints[nextj], nextInnerPoints[j] }.Select(x => x + vertical).ToArray()); yield return(MakeSolid(generator, faces, texture, colour)); } } else { // Use cylindrical cross sections var faces = new List <Coordinate[]>(); var points = ringOuterSections[i]; var nextPoints = ringOuterSections[nexti]; // Add the outer faces for (var j = 0; j < crossSides; j++) { var nextj = (j + 1) % crossSides; faces.Add(new[] { points[j], points[nextj], nextPoints[nextj], nextPoints[j] }.Select(x => x + vertical).ToArray()); } // Add the cross section faces faces.Add(points.Reverse().Select(x => x + vertical).ToArray()); faces.Add(nextPoints.Select(x => x + vertical).ToArray()); yield return(MakeSolid(generator, faces, texture, colour)); } } }
public async Task Send(string ipAddress, string command, string zone = null, decimal level = 0) { var controller = GetController(ipAddress); if (controller != null) { Zone z; byte[] bCommand = null; Enum.TryParse(zone, out z); switch (command) { case "On": if (zone != null) { bCommand = Colour.On(z); } break; case "AllOff": bCommand = Colour.AllOff(); break; case "AllOn": bCommand = Colour.AllOn(); break; case "EffectDown": bCommand = Colour.EffectDown(); break; case "EffectUp": bCommand = Colour.EffectUp(); break; case "Hue": bCommand = Colour.Hue(level); break; case "Off": if (zone != null) { bCommand = Colour.Off(z); } break; case "SetBrightness": bCommand = Colour.SetBrightness((int)level); break; case "SpeedDown": bCommand = Colour.SpeedDown(); break; case "SpeedUp": bCommand = Colour.SpeedUp(); break; } if (bCommand != null) { await controller.Send(bCommand); } } }
public IEnumerable <MapObject> Create(IDGenerator generator, Box box, ITexture texture, int roundDecimals) { var numSides = (int)_numSides.GetValue(); if (numSides < 3) { yield break; } roundDecimals = 2; // don't support rounding var width = box.Width; var length = box.Length; var height = box.Height; var major = width / 2; var minor = length / 2; var heightRadius = height / 2; var angleV = DMath.DegreesToRadians(180) / numSides; var angleH = DMath.DegreesToRadians(360) / numSides; var faces = new List <Coordinate[]>(); var bottom = new Coordinate(box.Center.X, box.Center.Y, box.Start.Z).Round(roundDecimals); var top = new Coordinate(box.Center.X, box.Center.Y, box.End.Z).Round(roundDecimals); for (var i = 0; i < numSides; i++) { // Top -> bottom var zAngleStart = angleV * i; var zAngleEnd = angleV * (i + 1); var zStart = heightRadius * DMath.Cos(zAngleStart); var zEnd = heightRadius * DMath.Cos(zAngleEnd); var zMultStart = DMath.Sin(zAngleStart); var zMultEnd = DMath.Sin(zAngleEnd); for (var j = 0; j < numSides; j++) { // Go around the circle in X/Y var xyAngleStart = angleH * j; var xyAngleEnd = angleH * ((j + 1) % numSides); var xyStartX = major * DMath.Cos(xyAngleStart); var xyStartY = minor * DMath.Sin(xyAngleStart); var xyEndX = major * DMath.Cos(xyAngleEnd); var xyEndY = minor * DMath.Sin(xyAngleEnd); var one = (new Coordinate(xyStartX * zMultStart, xyStartY * zMultStart, zStart) + box.Center).Round(roundDecimals); var two = (new Coordinate(xyEndX * zMultStart, xyEndY * zMultStart, zStart) + box.Center).Round(roundDecimals); var three = (new Coordinate(xyEndX * zMultEnd, xyEndY * zMultEnd, zEnd) + box.Center).Round(roundDecimals); var four = (new Coordinate(xyStartX * zMultEnd, xyStartY * zMultEnd, zEnd) + box.Center).Round(roundDecimals); if (i == 0) { // Top faces are triangles faces.Add(new[] { top, three, four }); } else if (i == numSides - 1) { // Bottom faces are also triangles faces.Add(new[] { bottom, one, two }); } else { // Inner faces are quads faces.Add(new[] { one, two, three, four }); } } } yield return(MakeSolid(generator, faces, texture, Colour.GetRandomBrushColour())); }
//-------------------------------------------------------------- //-------------------------------------------------------------- public static void DrawText(Font font, string text, Vector2 position, float fontSize, float spacing, Colour tint) { DrawTextEx(font, text, position.ToRLVector2(), fontSize, spacing, tint.ToRLColor()); }
//-------------------------------------------------------------- //-------------------------------------------------------------- public static void DrawRectangle(Vector2 position, Vector2 size, Colour colour) { DrawRectangleV(position.ToRLVector2(), size.ToRLVector2(), colour.ToRLColor()); }
public void TieToEntity() { if (_document.Selection.IsEmpty() || _document.Selection.InFaceSelection) { return; } var entities = _document.Selection.GetSelectedObjects().OfType <Entity>().ToList(); Entity existing = null; if (entities.Count == 1) { var result = new QuickForms.QuickForm("Existing Entity in Selection") { Width = 400 } .Label(String.Format("You have selected an existing entity (a '{0}'), how would you like to proceed?", entities[0].ClassName)) .Label(" - Keep the existing entity and add the selected items to the entity") .Label(" - Create a new entity and add the selected items to the new entity") .Item(new QuickFormDialogButtons() .Button("Keep Existing", DialogResult.Yes) .Button("Create New", DialogResult.No) .Button("Cancel", DialogResult.Cancel)) .ShowDialog(); if (result == DialogResult.Yes) { existing = entities[0]; } } else if (entities.Count > 1) { var qf = new QuickForms.QuickForm("Multiple Entities Selected") { Width = 400 } .Label("You have selected multiple entities, which one would you like to keep?") .ComboBox("Entity", entities.Select(x => new EntityContainer { Entity = x })) .OkCancel(); var result = qf.ShowDialog(); if (result == DialogResult.OK) { var cont = qf.Object("Entity") as EntityContainer; if (cont != null) { existing = cont.Entity; } } } var ac = new ActionCollection(); if (existing == null) { var def = _document.Game.DefaultBrushEntity; var entity = _document.GameData.Classes.FirstOrDefault(x => x.Name.ToLower() == def.ToLower()) ?? _document.GameData.Classes.Where(x => x.ClassType == ClassType.Solid) .OrderBy(x => x.Name.StartsWith("trigger_once") ? 0 : 1) .FirstOrDefault(); if (entity == null) { MessageBox.Show("No solid entities found. Please make sure your FGDs are configured correctly.", "No entities found!"); return; } existing = new Entity(_document.Map.IDGenerator.GetNextObjectID()) { EntityData = new EntityData(entity), ClassName = entity.Name, Colour = Colour.GetDefaultEntityColour() }; ac.Add(new Create(_document.Map.WorldSpawn.ID, existing)); } else { // Move the new parent to the root, in case it is a descendant of a selected parent... ac.Add(new Reparent(_document.Map.WorldSpawn.ID, new[] { existing })); // todo: get rid of all the other entities... } var reparent = _document.Selection.GetSelectedParents().Where(x => x != existing).ToList(); ac.Add(new Reparent(existing.ID, reparent)); ac.Add(new Actions.MapObjects.Selection.Select(existing)); _document.PerformAction("Tie to Entity", ac); if (Sledge.Settings.Select.OpenObjectPropertiesWhenCreatingEntity && !ObjectPropertiesDialog.IsShowing) { Mediator.Publish(HotkeysMediator.ObjectProperties); } }
public static Color CreateColor(Colour color) { return(new Color(color.R, color.G, color.B, color.A)); }
public void DrawString(string text, Position top_left_coordinate, Colour color) { SpriteBatch.DrawString(DefaultFont, text, new Vector2(top_left_coordinate.X, top_left_coordinate.Y), ColorToColourConverter(color)); }
public List <Wizzard> Get() { string sqLite = @"SELECT * FROM Wizzard LEFT JOIN Species on wizzard.SpeciesId = Species.Id LEFT JOIN Gender on wizzard.GenderId = Gender.Id LEFT JOIN House on wizzard.HouseId = House.Id LEFT JOIN Ancestry on wizzard.AncestryId = Ancestry.Id LEFT JOIN Colour c on wizzard.EyeColourId = c.Id LEFT JOIN Colour c2 on wizzard.HairColourId = c2.Id LEFT JOIN Wand on wizzard.WandId = Wand.Id LEFT JOIN Material m1 on Wand.WoodMaterialId = M1.Id LEFT JOIN MaterialType mt1 on m1.MaterialTypeId = mt1.Id LEFT JOIN Material m2 on Wand.CoreMaterialId = M2.Id LEFT JOIN MaterialType mt2 on m2.MaterialTypeId = mt2.Id LEFT JOIN patronus on wizzard.PatronusId = Patronus.Id"; SQLiteConnection connection = new SQLiteConnection(connectionString); List <Wizzard> wizzards = connection.Query <Wizzard> (sqLite, new[] { typeof(Wizzard), typeof(Species), typeof(Gender), typeof(House), typeof(Ancestry), typeof(Colour), typeof(Colour), typeof(Wand), typeof(Material), typeof(MaterialType), typeof(Material), typeof(MaterialType), typeof(Patronus) } , objects => { Wizzard wizzard = objects[0] as Wizzard; Species species = objects[1] as Species; Gender gender = objects[2] as Gender; House house = objects[3] as House; Ancestry ancestry = objects[4] as Ancestry; Colour eyeColour = objects[5] as Colour; Colour hairColour = objects[6] as Colour; Wand wand = objects[7] as Wand; Material woodMaterial = objects[8] as Material; MaterialType mt1 = objects[9] as MaterialType; Material coreMaterial = objects[10] as Material; MaterialType mt2 = objects[11] as MaterialType; Patronus patronus = objects[12] as Patronus; wizzard.Species = species; wizzard.Gender = gender; wizzard.House = house; wizzard.Ancestry = ancestry; wizzard.EyeColour = eyeColour; wizzard.HairColour = hairColour; wizzard.Wand = wand; if (wand != null) { wand.WoodMaterial = woodMaterial; if (woodMaterial != null) { wand.WoodMaterial.MaterialType = mt1; } wand.CoreMaterial = coreMaterial; if (coreMaterial != null) { wand.CoreMaterial.MaterialType = mt2; } } wizzard.Patronus = patronus; return(wizzard); }, splitOn: "Id,Id,Id,Id,Id,Id,Id,Id,Id,Id,Id,Id").ToList(); return(wizzards); }
public static Color ToRgb(this Colour c) { return(ToRgb(c.H, c.S, c.L)); }
public BackgroundElementProps(Colour colour, Action <IReadOnlyList <IEvent>, IElementState> onEvents = null) { this.Colour = colour; }
/// <summary> /// Convers a <see cref="SystemColor"/> into to a <see cref="Colour"/>. /// </summary> /// <returns>The <see cref="Colour"/>.</returns> /// <param name="source">Source <see cref="SystemColor"/>.</param> public static Colour ToColour(this SystemColor source) => Colour.FromArgb(source.A, source.R, source.G, source.B);
/// <summary> /// Convert a Nucleus colour to a WPF color /// </summary> /// <param name="col">The colour to be converterd</param> /// <param name="alphaLimit">Optional. The maximum value to which to limit the alpha channel of the colour. /// Use this to specify that the colour should be displayed as semitransparent even if the original to be converted /// was not. /// </param> /// <returns></returns> public static Media.Color Convert(Colour col, byte alphaLimit = 255) { return(Media.Color.FromArgb((byte)Math.Min(col.A, alphaLimit), col.R, col.G, col.B)); }
void Start() { vault = GameObject.FindGameObjectWithTag("Vault"); colourScript = vault.GetComponent <Colour> (); }
public Cookie(int _Weight, string _Shape, Colour _Colour) { this.Weight = _Weight; this.Shape = _Shape; this.Clr = _Colour; }
private Color ColorFromSpanColour(Colour spanColour) { return(Color.FromArgb(spanColour.Alpha, spanColour.Red, spanColour.Green, spanColour.Blue)); }
public AddSpriteEvent(Colour newColour) { this.NewColour = newColour; }
//-------------------------------------------------------------- //-------------------------------------------------------------- public static void DrawLine(Vector2 startPos, Vector2 endPos, float thick, Colour colour) { DrawLineEx(startPos.ToRLVector2(), endPos.ToRLVector2(), thick, colour.ToRLColor()); }
public bool HasColour() => !Colour.Equals(SKColors.Empty);
void Start() { GetComponent <TextMesh>().text = " "; vault = GameObject.FindGameObjectWithTag("Vault"); colourScript = vault.GetComponent <Colour> (); }
//-------------------------------------------------------------- //-------------------------------------------------------------- public static void DrawCircle(Vector2 center, float radius, Colour colour) { DrawCircleV(center.ToRLVector2(), radius, colour.ToRLColor()); }
public void DrawRectangle(Position top_left_coordinate, int width, int height, Colour color) { SpriteBatch.Draw(WhitePixel, new Rectangle(top_left_coordinate.X, top_left_coordinate.Y, width, height), ColorToColourConverter(color)); }