public void DrawString(View view, string text, int size, ColorInt c, int x = 0, int y = 0)
 {
     if (Fonts[size] != null)
     {
         Fonts[size].DrawString(view, text, c, x, y);
     }
 }
 public void DrawCharacter(View view, int chr, int size, ColorInt c, int x = 0, int y = 0)
 {
     if (Fonts[size] != null)
     {
         Fonts[size].DrawCharacter(view, chr, c, x, y);
     }
 }
 public void DrawCharacterWithBackground(View view, int chr, int size, ColorInt c, ColorInt d, int x = 0, int y = 0)
 {
     if (Fonts[size] != null)
     {
         Fonts[size].DrawCharacterWithBackground(view, chr, c, d, x, y);
     }
 }
Example #4
0
        /// <summary>
        /// Gets colors, bold, but not font properties.
        /// </summary>
        public TStyles(AuScintilla sci)
        {
            BackgroundColor = ColorInt.SwapRB(sci.Call(SCI_STYLEGETBACK));

            TStyle _Get(EToken tok)
            {
                int  color = ColorInt.SwapRB(sci.Call(SCI_STYLEGETFORE, (int)tok));
                bool bold  = 0 != sci.Call(SCI_STYLEGETBOLD, (int)tok);

                return(new TStyle(color, bold));
            }

            Comment      = _Get(EToken.Comment);
            String       = _Get(EToken.String);
            StringEscape = _Get(EToken.StringEscape);
            Number       = _Get(EToken.Number);
            Punctuation  = _Get(EToken.Punctuation);
            Operator     = _Get(EToken.Operator);
            Keyword      = _Get(EToken.Keyword);
            Namespace    = _Get(EToken.Namespace);
            Type         = _Get(EToken.Type);
            Function     = _Get(EToken.Function);
            LocalVar     = _Get(EToken.LocalVar);
            Parameter    = _Get(EToken.Parameter);
            Field        = _Get(EToken.Field);
            Constant     = _Get(EToken.Constant);
            EnumMember   = _Get(EToken.EnumMember);
            Label        = _Get(EToken.Label);
            Preprocessor = _Get(EToken.Preprocessor);
            Excluded     = _Get(EToken.Excluded);
            XmlDocText   = _Get(EToken.XmlDocText);
            XmlDocTag    = _Get(EToken.XmlDocTag);

            LineNumber = _Get(EToken.LineNumber);
        }
 public void Sub(ref ColorInt c)
 {
     r -= c.r;
     g -= c.g;
     b -= c.b;
     a -= c.a;
 }
 public void SetMulDiv(ref ColorInt c, int mul, int div)
 {
     r = (c.r * mul) / div;
     g = (c.g * mul) / div;
     b = (c.b * mul) / div;
     a = (c.a * mul) / div;
 }
 public void DrawStringWithBackground(View view, string text, int size, ColorInt c, ColorInt d, int x = 0, int y = 0)
 {
     if (Fonts[size] != null)
     {
         Fonts[size].DrawStringWithBackground(view, text, c, d, x, y);
     }
 }
Example #8
0
        private Thing MostLikelyPoint(PointPlus p1, ColorInt theColor)
        {
            Thing retVal = null;

            if (UKSPoints == null)
            {
                return(null);
            }
            Angle closestTheta = Rad(180);

            foreach (Thing t in UKSPoints)
            {
                if (t.ReferencedBy.Count > 0)
                {
                    Segment s = SegmentFromUKSThing(t.ReferencedBy[0].T);
                    if (s == null)
                    {
                        continue;
                    }
                    if (s.theColor == theColor)
                    {
                        if (t.V is PointPlus p)
                        {
                            Angle deltaAngle = Abs(p.Theta - p1.Theta);
                            if (deltaAngle < closestTheta)
                            {
                                closestTheta = deltaAngle;
                                retVal       = t;
                            }
                        }
                    }
                }
            }
            return(retVal);
        }
 // Token: 0x06000063 RID: 99 RVA: 0x0000360C File Offset: 0x0000180C
 public override void Initialize(TerrainCompProperties props)
 {
     base.Initialize(props);
     this.Color           = this.Props.glowColor;
     this.GlowRadius      = this.Props.glowRadius;
     this.OverlightRadius = this.Props.overlightRadius;
 }
        protected override void DrawStyle(Style style, float opacity)
        {
            base.DrawStyle(style, opacity);

            var texture = Gui.Renderer.GetTexture(Texture);

            if (texture < 0)
            {
                return;
            }

            if (ColorByTint)
            {
                Color = style.Tint;
            }

            var color = Color;

            if (Tint != -1)
            {
                color = ColorInt.Blend(Tint, color);
            }

            color = ColorInt.FromArgb(opacity, color);

            if (TextureRect.IsEmpty())
            {
                var texsize = Gui.Renderer.GetTextureSize(texture);
                TextureRect = new Rectangle(Point.Zero, texsize);
            }

            //bool atlas = SpriteBatch.AutoAtlas;

            //if (ExcludeFromAtlas)
            //    SpriteBatch.AutoAtlas = false;

            if (Tiling == TextureMode.Grid || Tiling == TextureMode.GridRepeat)
            {
                SliceTexture(texture, Tiling, TextureRect, Grid, opacity, color);
            }
            else if (Tiling == TextureMode.Stretch)
            {
                Gui.Renderer.DrawTexture(texture, Location.X + Inset.Left, Location.Y + Inset.Top, Size.X - (Inset.Left + Inset.Right), Size.Y - (Inset.Top + Inset.Bottom), TextureRect, color);
            }
            else if (Tiling == TextureMode.Center)
            {
                var center   = Location + Size / 2;
                var rectsize = new Point(TextureRect.Width, TextureRect.Height);
                var pos      = center - rectsize / 2;

                Gui.Renderer.DrawTexture(texture, pos.X, pos.Y, rectsize.X, rectsize.Y, TextureRect, color);
            }
            else
            {
                RepeatTexture(texture, Location, TextureRect, Tiling, opacity, color);
            }

            //if (ExcludeFromAtlas)
            //    SpriteBatch.AutoAtlas = atlas;
        }
Example #11
0
        private void SetGlow(ColorInt glowColor, float glowRadius)
        {
            // new glower
            CompGlower myThingComp = new CompGlower();

            myThingComp.parent = parent;
            CompProperties_Glower compProps = new CompProperties_Glower
            {
                // setting props
                glowColor  = glowColor,
                glowRadius = glowRadius
            };

            // init
            myThingComp.Initialize(compProps);

            // applying to map
            Map     myMap = parent.Map;
            IntVec3 myPos = parent.Position;

            myMap.mapDrawer.MapMeshDirty(myPos, MapMeshFlag.Things);
            myMap.glowGrid.RegisterGlower(myThingComp);

            // removing old glow
            // AZAAAAARG
            UnsetGlow();

            // remembering what you did last summer
            glowComp = myThingComp;
        }
 static void AddColor(ref Color32 c, ref ColorInt t)
 {
     c.r = (byte)Mathf.Clamp(c.r + t.r, 0, 255);
     c.g = (byte)Mathf.Clamp(c.g + t.g, 0, 255);
     c.b = (byte)Mathf.Clamp(c.b + t.b, 0, 255);
     c.a = (byte)Mathf.Clamp(c.a + t.a, 0, 255);
 }
        // Replace the comp props with a new one with different values
        // must replace comp props as comps share props for things of the
        // same class.  We need to make a unique copy for the building.
        public void                         ChangeColor(ColorInt color)
        {
            // Get glower
            var glower = CompGlower;

            // New glower properties
            var newProps = new CompProperties_Glower();

            if (newProps == null)
            {
                CCL_Log.Error("CompColoredLight unable to create new CompProperties!", parent.def.defName);
                return;
            }

            // Set the new properties values
            newProps.compClass  = typeof(CompGlower);
            newProps.glowColor  = color;
            newProps.glowRadius = lightRadius;

            // Initialize comp with new properties
            glower.Initialize(newProps);

            // Update glow grid
            //glower.UpdateLit(); <-- Only works if the light changes state (on<->off)
            Find.GlowGrid.MarkGlowGridDirty(parent.Position);
        }
Example #14
0
        public void changeColourTest()
        {
            // new glower
            CompGlower myThingComp = new CompGlower();

            myThingComp.parent = this.parent;
            CompProperties_Glower compProps = new CompProperties_Glower();

            // color init
            curIndex = ((curIndex + 1) > 7) ? (0) : (curIndex + 1);
            newcolor = colors[curIndex];

            // setting props
            compProps.glowColor  = newcolor;
            compProps.glowRadius = glowRadius;
            // init
            myThingComp.Initialize(compProps);

            // applying to map
            Map     myMap = parent.Map;
            IntVec3 myPos = parent.Position;

            myMap.mapDrawer.MapMeshDirty(myPos, MapMeshFlag.Things);
            myMap.glowGrid.RegisterGlower(myThingComp);

            // removing old glow
            parent.AllComps.Remove(glowComp);
            myMap.glowGrid.DeRegisterGlower(glowComp);

            // remembering what you did last summer
            glowComp = myThingComp;
        }
Example #15
0
        public GameCondition_VolcanicWinter()
        {
            ColorInt colorInt = new ColorInt(0, 0, 0);

            this.VolcanicWinterColors = new SkyColorSet(colorInt.ToColor, Color.white, new Color(0.6f, 0.6f, 0.6f), 0.65f);
            base..ctor();
        }
Example #16
0
 // Token: 0x06000063 RID: 99 RVA: 0x0000360C File Offset: 0x0000180C
 public override void Initialize(TerrainCompProperties props)
 {
     base.Initialize(props);
     Color           = Props.glowColor;
     GlowRadius      = Props.glowRadius;
     OverlightRadius = Props.overlightRadius;
 }
Example #17
0
        protected override void DrawText(Style style, float opacity)
        {
            if (_isDirty)
            {
                UpdateText(style);
            }

            if (_lines.Count == 0)
            {
                return;
            }

            int   font;
            Point p1, p2, size;

            foreach (var line in _lines)
            {
                foreach (var element in line.Elements)
                {
                    if (element.Linebreak)
                    {
                        continue;
                    }

                    font = Gui.Renderer.GetFont(element.Font);
                    size = element.Size;
                    p2   = element.Position + Location;

                    element.Rectangle = new Rectangle(p2, size);

                    if (!element.Rectangle.Intersects(ClipRect))
                    {
                        continue;
                    }

                    if (element.IsControl)
                    {
                        continue;
                    }

                    if (element.IsLink)
                    {
                        Gui.Renderer.DrawBox(p2.X, p2.Y + size.Y, size.X - 1, 1, ColorInt.FromArgb(opacity, ColorInt.FromArgb(opacity, element.Color.HasValue ? (int)element.Color : style.TextColor)));
                    }

                    //if (element.IsLink && element.Href == ActiveHref)
                    //    Gui.Renderer.DrawBox(p2.x, p2.y, size.x - 1, size.y, ColorInt.FromArgb(opacity, LinkColor));

                    if (UseTextColor)
                    {
                        Gui.Renderer.DrawText(element.Text, p2.X, p2.Y, font, ColorInt.FromArgb(opacity, TextColor));
                    }
                    else
                    {
                        Gui.Renderer.DrawText(element.Text, p2.X, p2.Y, font, ColorInt.FromArgb(opacity, element.Color.HasValue ? (int)element.Color : style.TextColor));
                    }
                }
            }
        }
Example #18
0
 IEnumerator ColorFadeAnimation()
 {
     while (true)
     {
         _contextMessageBackground.Color = ColorInt.Blend(_contextMessageBackground.Color, _targetBackgroundColor, 0.80f);
         yield return(null);
     }
 }
Example #19
0
 public override void SpawnSetup()
 {
     base.SpawnSetup();
     this.Glower    = base.GetComp <CompGlower>();
     this.powerComp = base.GetComp <CompPowerTrader>();
     ChangeColour(this.green);
     CurrentColour = this.green;
 }
Example #20
0
 public override void SpawnSetup()
 {
     base.SpawnSetup();
     this.Glower = base.GetComp<CompGlower>();
     this.powerComp = base.GetComp<CompPowerTrader>();
     ChangeColour(this.green);
     CurrentColour = this.green;
 }
 public static void DrawMenuSectionColor(Rect rect, int thiccness, ColorInt colorBG, ColorInt colorBorder)
 {
     GUI.color = colorBG.ToColor;
     GUI.DrawTexture(rect, BaseContent.WhiteTex);
     GUI.color = colorBorder.ToColor;
     Widgets.DrawBox(rect, thiccness);
     GUI.color = Color.white;
 }
Example #22
0
        public MapCondition_CorruptiveDrone()
        {
            ColorInt colorInt  = new ColorInt(240, 141, 74);
            ColorInt colorInt2 = new ColorInt(254, 245, 176);
            ColorInt colorInt3 = new ColorInt(170, 95, 60);

            this.CorruptiveDroneColors = new SkyColorSet(colorInt.ToColor, colorInt2.ToColor, colorInt3.ToColor, 1.0f);
        }
Example #23
0
 public void DrawString(View view, string text, ColorInt c, int x = 0, int y = 0)
 {
     char[] chars = text.ToCharArray();
     for (int i = 0; i < chars.Length; i++)
     {
         DrawCharacter(view, chars[i], c, x + (Width + Spacing) * i, y);
     }
 }
Example #24
0
        unsafe void _DrawText(string s, int x, int y, ColorInt color, int from, int len)
        {
            var col = color.ToBGR(); if (col != _color)

                Api.SetTextColor(_hdc, _color = col);

            fixed(char *p = s) Api.TextOut(_hdc, x, y, p + from, len);
        }
Example #25
0
 public void FactoryEnumAutoGetKey()
 {
     foreach (ColorEnum v in Enum.GetValues(typeof(ColorEnum)))
     {
         var color = ColorInt.Factory(v);
         Assert.Equal(color.Key, v);
     }
 }
Example #26
0
    //rejected. Too simple, and nobody would find and use.
    ///// <summary>
    ///// Converts to int.
    ///// Can be used like <c>0xff123456.ToInt()</c> instead of <c>unchecked((int)0xff123456)</c>.
    ///// </summary>
    //public static int ToInt(this uint t) => unchecked((int)t);

    ///// <summary>
    ///// Converts to System.Drawing.Color.
    ///// Can be used like <c>0xff123456.ToColor_()</c> instead of <c>Color.FromArgb(unchecked((int)0xff123456))</c>.
    ///// </summary>
    ///// <param name="t"></param>
    ///// <param name="makeOpaque">Add 0xff000000.</param>
    //internal static System.Drawing.Color ToColor_(this uint t, bool makeOpaque = true)
    //	=> System.Drawing.Color.FromArgb(unchecked((int)(t | (makeOpaque ? 0xff000000 : 0))));

    /// <summary>
    /// Converts to System.Drawing.Color. Makes opaque (alpha 0xff).
    /// Can be used like <c>0x123456.ToColor_()</c> instead of <c>Color.FromArgb(unchecked((int)0xff123456))</c>.
    /// </summary>
    internal static System.Drawing.Color ToColor_(this int t, bool bgr = false)
    {
        if (bgr)
        {
            t = ColorInt.SwapRB(t);
        }
        return(System.Drawing.Color.FromArgb(unchecked (0xff << 24 | t)));
    }
Example #27
0
        private void FindBinocularBoundaries()
        {
            boundaries.Clear();
            int start = 0;

            for (int i = 0; i < LBoundaries.Count; i++)
            {
                for (int j = start; j < RBoundaries.Count; j++)
                {
                    ColorInt cLL = LBoundaries[i].colorL;
                    ColorInt cLR = LBoundaries[i].colorR;
                    ColorInt cRL = RBoundaries[j].colorL;
                    ColorInt cRR = RBoundaries[j].colorR;
                    if (cLL == cRL || cLR == cRR)
                    {
                        //find distance and error
                        int       l1             = LBoundaries[i].direction;
                        int       r1             = RBoundaries[j].direction;
                        PointPlus leftPoint      = FindDepth(l1, r1);
                        PointPlus leftPointError = FindDepth(l1 - 1, r1);
                        float     error          = leftPointError.R - leftPoint.R;
                        if (error < 0)
                        {
                            break;
                        }
                        leftPoint.Conf = error;

                        PointPlus pp = new PointPlus()
                        {
                            R = leftPoint.R, Theta = leftPoint.Theta, Conf = leftPoint.Conf
                        };
                        //if both sides of the point match...this creates two boundaries, one for each color
                        if (cLL == cRL)
                        {
                            BinocularBoundary bb = new BinocularBoundary()
                            {
                                p        = leftPoint,
                                theColor = cLL,
                                changed  = LBoundaries[i].changed,
                            };
                            boundaries.Add(bb);
                        }
                        if (cLR == cRR)
                        {
                            BinocularBoundary bb = new BinocularBoundary()
                            {
                                p        = pp,
                                theColor = cLR,
                                changed  = LBoundaries[i].changed,
                            };
                            boundaries.Add(bb);
                        }
                        start = j;
                        break;
                    }
                }
            }
        }
Example #28
0
        float GetAngleFromTexture(Area a)
        {
            int start  = (int)GetNeuronFromDirection(a.PL.Theta, na.Width);
            int end    = (int)GetNeuronFromDirection(a.PR.Theta, na.Width);
            int first  = 0;
            int last   = 0;
            int lCount = 0;
            int rCount = 0;

            for (int i = start; i < end; i++)
            {
                ColorInt color = na.GetNeuronAt(i, 0).LastChargeInt;
                if (color != a.theColor && first == 0)
                {
                    continue;
                }
                if (first == 0)
                {
                    first = i;
                }
                if (color == System.Windows.Media.Colors.AliceBlue)
                {
                    lCount++;
                }
                else if (lCount > 0)
                {
                    break;
                }
            }
            for (int i = end - 1; i >= start; i--)
            {
                ColorInt color = na.GetNeuronAt(i, 0).LastChargeInt;
                if (color != a.theColor && last == 0)
                {
                    continue;
                }
                if (last == 0)
                {
                    last = i;
                }
                if (color == System.Windows.Media.Colors.AliceBlue)
                {
                    rCount++;
                }
                else if (rCount > 0)
                {
                    break;
                }
            }
            float retVal = 1;

            if (Abs(lCount - rCount) > 0)
            {
                retVal  = (float)lCount / (float)rCount;
                retVal *= (float)(last - first) / (float)(end - start); //correction because texture is not at the end of the segment
            }
            return(retVal);
        }
Example #29
0
        private void DrawPoint(BitmapBuffer writeableBmp, ControlPoint p, ColorInt color)
        {
            var x1 = p.X - PointSizeHalf;
            var y1 = p.Y - PointSizeHalf;
            var x2 = p.X + PointSizeHalf;
            var y2 = p.Y + PointSizeHalf;

            writeableBmp.DrawRectangle(x1, y1, x2, y2, color);
        }
Example #30
0
        public static Color IntToColour(ColorInt col)
        {
            float r = (float)col.r / 255f;
            float g = (float)col.g / 255f;
            float b = (float)col.b / 255f;
            float a = (float)1f;

            return new Color(r, g, b, a);
        }
Example #31
0
        public static Color IntToColour(ColorInt col)
        {
            float r = (float)col.r / 255f;
            float g = (float)col.g / 255f;
            float b = (float)col.b / 255f;
            float a = (float)1f;

            return(new Color(r, g, b, a));
        }
Example #32
0
        public void SetColor(Color col, bool refresh = true)
        {
            CurrentColInt = new ColorInt(col);

            if (refresh)
            {
                Color.RGBToHSV(CurrentCol, out hue, out sat, out val);
            }
        }
Example #33
0
        //provides a new Compglower
        public static CompGlower newCompGlower(ThingWithComps parent, ColorInt glowColour, float glowRadius)
        {
            CompGlower Comp_NewGlower = new CompGlower();
            Comp_NewGlower.parent = parent;


            CompProperties CompProp_New = new CompProperties();
            CompProp_New.compClass = typeof(CompGlower);
            CompProp_New.glowColor = glowColour;
            CompProp_New.glowRadius = glowRadius;

            Comp_NewGlower.Initialize(CompProp_New);

            return Comp_NewGlower;
        }
Example #34
0
        //moved it to util for easier implementation with MAD
        public static void DestroyNCreateGlower(ThingWithComps parent, ColorInt glowColour, float glowRadius)
        {
            CompGlower oldGlower = null;
            CompPowerTrader pwrTrader = null;

            List<ThingComp> list = parent.GetComps();

            foreach (ThingComp comp in list)
            {
                if (typeof(CompGlower) == comp.GetType())
                {
                    if (oldGlower == null)
                    {
                        oldGlower = (CompGlower)comp;
                    }

                }
                if (typeof(CompPowerTrader) == comp.GetType())
                {
                    pwrTrader = (CompPowerTrader)comp;
                }
            }
            if (oldGlower != null)
            {

                Boolean isLitoldGlower = oldGlower.Lit;
                oldGlower.Lit = false;

                CompGlower newGlower = Util.newCompGlower(parent, glowColour, glowRadius);
                list.Remove(oldGlower);
                list.Add(newGlower);

                parent.SetComps(list);

                newGlower.Lit = false;
                updateMap(parent.Position);

                if (pwrTrader != null)
                {
                    if (isLitoldGlower && pwrTrader.PowerOn)
                    {
                        newGlower.Lit = true;
                    }
                }
            }

        }
Example #35
0
        // Replace the comp props with a new one with different values
        // must replace comp props as comps share props for things of the
        // same class.  We need to make a unique copy for the building.
        public void ChangeColor( ColorInt color )
        {
            // Get glower
            var glower = CompGlower;

            // New glower properties
            var newProps = new CompProperties_Glower();
            if( newProps == null )
            {
                CCL_Log.Error( "CompColoredLight unable to create new CompProperties!", parent.def.defName );
                return;
            }

            // Set the new properties values
            newProps.compClass = typeof( CompGlower );
            newProps.glowColor = color;
            newProps.glowRadius = lightRadius;

            // Initialize comp with new properties
            glower.Initialize( newProps );

            // Update glow grid
            //glower.UpdateLit(); <-- Only works if the light changes state (on<->off)
            Find.GlowGrid.MarkGlowGridDirty( parent.Position );
        }
        public void changeColor( ColorInt colour )
        {
            // Current lit state from base compGlower
            bool wasLit = oldGlower.Lit;

            // Turn off old glower
            oldGlower.Lit = false;

            // Turn off replaced glower
            if( compGlower != null )
            {
                // Current lit state from base replacement compGlower
                wasLit = compGlower.Lit;

                // Turn off replacement compGlower
                compGlower.Lit = false;
            }

            // New glower
            CompGlower newGlower = new CompGlower();
            if( newGlower == null )
            {
                Log.Message( parent.def.defName + " - Unable to create new compGlower!" );
                return;
            }
            newGlower.parent = parent;

            // Glower properties
            CompProperties newProps = new CompProperties();
            if( newProps == null )
            {
                Log.Message( parent.def.defName + " - Unable to create new compProperties!" );
                return;
            }
            newProps.compClass = typeof( CompGlower );
            newProps.glowColor = colour;
            newProps.glowRadius = lightRadius;

            // Add properties to glower
            newGlower.Initialize( newProps );

            // Fetch the comps list
            List<ThingComp> allComps = typeof( ThingWithComps ).GetField( "comps", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance ).GetValue( parent ) as List<ThingComp>;
            if( allComps == null )
            {
                Log.Message( parent.def.defName + " - Could not get list of comps!" );
                return;
            }

            // Remove default glower
            allComps.Remove( oldGlower );

            // Remove current glower
            if( compGlower != null )
            {
                allComps.Remove( compGlower );
            }

            // Add new glower
            allComps.Add( newGlower );
            compGlower = newGlower;

            // Store comps list
            typeof( ThingWithComps ).GetField( "comps", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance ).SetValue( parent, allComps );

            // Update glow grid
            compGlower.Lit = false;
            Find.GlowGrid.MarkGlowGridDirty( parent.Position );
            Find.MapDrawer.MapMeshDirty( parent.Position, MapMeshFlag.GroundGlow );
            Find.MapDrawer.MapMeshDirty( parent.Position, MapMeshFlag.Things );

            if( ( wasLit )&&( compPower.PowerOn ) )
            {
                // Turn it on if it the old glower was on
                compGlower.Lit = true;
            }
        }
 public colorName( string n, ColorInt v )
 {
     name = n;
     value = v;
 }
Example #38
0
 public void ChangeColour(ColorInt colour)
 {
     CurrentColour = colour;
     Util.DestroyNCreateGlower(this, colour, this.Glower.props.glowRadius);
 }