void SetIconFor(StarInfoDB db) { //TODO: change pen colour depending on star temp and lum? double temp = db.Temperature; double lum = db.Luminosity; Pen starPen = new Pen(Colors.DarkOrange); float width = 8; float height = 8; float hw = width * 0.25f; float hh = height * 0.25f; GraphicsPath starPath = new GraphicsPath(); PointF start = new PointF(0, -height); PointF end = new PointF(-width, 0); PointF c1 = new PointF(-hw, -hh); PointF c2 = new PointF(-hw, -hh); starPath.AddBezier(start, c1, c2, end); start = new PointF(-width, 0); end = new PointF(0, height); c1 = new PointF(-hw, hh); c2 = new PointF(-hw, hh); starPath.AddBezier(start, c1, c2, end); start = new PointF(0, height); end = new PointF(width, 0); c1 = new PointF(hw, hh); c2 = new PointF(hw, hh); starPath.AddBezier(start, c1, c2, end); start = new PointF(width, 0); end = new PointF(0, -height); c1 = new PointF(hw, -hh); c2 = new PointF(hw, -hh); starPath.AddBezier(start, c1, c2, end); PenPathPair starPathPair = new PenPathPair() { Pen = starPen, Path = starPath }; _shapes.Add(starPathPair); }
private void StarSetup(StarInfoDB starInfo) { switch (starInfo.SpectralType) { case SpectralType.A: { ItemTextureName = DEFAULT_PLANET_ICON; } break; default: { ItemTextureName = DEFAULT_PLANET_ICON; } break; } double maxTempValue = 60000; //todo get this from game settings? double divisor = maxTempValue / 255; byte temp = Convert.ToByte(starInfo.Temperature / divisor); ItemColour = new Color4(temp, 100 - temp, 0, 0);//stab in the dark. }
public StarIcon(Entity entity) : base(entity.GetDataBlob <PositionDB>()) { StarInfoDB starInfo = entity.GetDataBlob <StarInfoDB>(); _tempK = starInfo.Temperature + 273.15; var massVol = entity.GetDataBlob <MassVolumeDB>(); _bodyRadiusAU = massVol.Radius; double calcTemp = GMath.Clamp(_tempK, 1000, 40000); calcTemp = calcTemp / 100; //Red if (calcTemp <= 660) { _color.r = 255; } else { _color.r = (byte)(329.698727446 * Math.Pow(calcTemp - 60, -0.1332047592)); } //Green if (calcTemp <= 66) { _color.g = (byte)(99.4708025861 * Math.Log(calcTemp) - 161.1195681661); } else { _color.g = (byte)(288.1221695283 * Math.Pow(calcTemp - 60, -0.0755148492)); } //Blue if (calcTemp >= 66) { _color.b = 255; } else if (calcTemp <= 19) { _color.b = 0; } else { _color.b = (byte)(138.5177312231 * Math.Log(calcTemp - 10) - 305.0447927307); } _color.a = 255; byte spikes = (byte)(starInfo.SpectralType + 4); float spikeheight = 100; float spikeDepth = 50; double arc = (2 * Math.PI) / spikes; double startAngle = 1.5708 - arc / 2; List <PointD> shapePoints = new List <PointD>(); for (int i = 0; i < spikes; i++) { var a1 = arc * i; double x1 = (0 * Math.Cos(a1) - spikeheight * Math.Sin(a1)); double y1 = (0 * Math.Sin(a1) + spikeheight * Math.Cos(a1)); var p1 = new PointD() { X = x1, Y = y1 }; var a2 = a1 + arc * 0.5; double x2 = (0 * Math.Cos(a2) - spikeDepth * Math.Sin(a2)); double y2 = (0 * Math.Sin(a2) + spikeDepth * Math.Cos(a2)); var p2 = new PointD() { X = x2, Y = y2 }; shapePoints.Add(p1); shapePoints.Add(p2); /* * this was an attempt at making slightly nicer looking stars using an elipsed curve instead of just straight lines. couldnt get it working though * the idea was make an arc, then rotate it. * List<SDL.SDL_Point> points = new List<SDL.SDL_Point>(); * points.AddRange(CreatePrimitiveShapes.CreateArc(32, 0, 32 - spikeDepth, 32 + spikeDepth, startAngle, arc, 32)); //32 segments is probilby way overkill maybe adjust this by the camera zoom level? * //rotate it at i * arc; * var a = arc * i; * for (int i2 = 0; i2 < points.Count; i2++) * { * int x = (int)(points[i2].x * Math.Cos(a) - points[i2].y * Math.Sin(a)); * int y = (int)(points[i2].x * Math.Sin(a) + points[i2].y * Math.Cos(a)); * points[i2] = new SDL.SDL_Point() { x = x, y = y }; * } * shapePoints.AddRange(points); * startAngle += arc; */ } shapePoints.Add(shapePoints[0]); //ensure the last point is the same as the first, so it joins up. List <Shape> shapes = new List <Shape>(); shapes.Add(new Shape() { Color = _color, Points = shapePoints.ToArray() }); Shapes.AddRange(shapes); }