Example #1
0
        public void AddText(string text, Pigment pigment = null)
        {
            string[] words = Explode(text);

            foreach (string word in words)
            {
                if (!string.IsNullOrEmpty(word))
                {
                    if ((currVirtualPos + Canvas.TextLength(word) >= LineLength) &&
                        (word[0] != '\n'))
                    {
                        buffer.Enqueue(new Atom('\n'));
                        currVirtualPos = 0;
                    }

                    foreach (char c in word)
                    {
                        buffer.Enqueue(new Atom(c, pigment));
                        currVirtualPos++;

                        if (c == '\n')
                        {
                            currVirtualPos = 0;
                        }
                    }

                    if (currVirtualPos != 0)
                    {
                        buffer.Enqueue(new Atom(' ', pigment));
                        currVirtualPos++;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Prints a frame border around the canvas, with an optional centered title.
        /// </summary>
        public void PrintFrame(string title, Pigment pigment = null)
        {
            if (pigment != null)
            {
                SetPigment(pigment);
            }

            if (string.IsNullOrEmpty(title))
            {
                Console.printFrame(0, 0,
                                   Size.Width, Size.Height,
                                   false);
            }
            else
            {
                Console.printFrame(0, 0,
                                   Size.Width, Size.Height,
                                   false,
                                   TCODBackgroundFlag.Set,
                                   title);
            }

            if (pigment != null)
            {
                SetPigment(_defaultPigment);
            }
        }
Example #3
0
        /// <summary>
        /// Prints the specified string at the given coordinates.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="text"/> is
        /// null</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified position is outside of this Canvas region</exception>
        public void PrintString(int x, int y, string text, Pigment pigment = null)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            if (x < 0 || x >= Size.Width)
            {
                throw new ArgumentOutOfRangeException("x", "The specified x coordinate is invalid.");
            }

            if (y < 0 || y >= Size.Height)
            {
                throw new ArgumentOutOfRangeException("y", "The specified y coordinate is invalid.");
            }

            if (pigment != null)
            {
                SetPigment(pigment);
            }

            //Console.print(x, y, text);
            Print(x, y, text);

            if (pigment != null)
            {
                SetPigment(_defaultPigment);
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            PovScene scene = new PovScene()
            {
                Name = "Droid"
            };

            PovEngine        engine  = new PovEngine(@"c:\Program Files\POV-Ray\v3.7\bin\pvengine64.exe", @"e:\tmp");
            PovEngineOptions options = new PovEngineOptions()
            {
                Height = 480, Width = 640, PreviewStartSize = 32, PreviewEndSize = 16, PauseWhenDone = true
            };

            var mainPigment      = new Pigment(_White);
            var decoPigmentMinor = new Pigment(_Gray20);
            var decoPigmentMajor = new Pigment(_Orange);

            var droid = new DroidObject(mainPigment, decoPigmentMajor, decoPigmentMinor);

            droid.AddModifiers(new Pigment(new PovColor(1, 0, 0)));

            scene.Add(
                new Camera()
            {
                Location = _V(0, 1.5, 4), LookAt = new PovVector(0, 1, 0)
            },
                new Light(),
                new Plane().AddModifiers(new Pigment(_Green))
                );
            scene.Add(droid);
            var(path, process) = engine.Render(scene, options);
            process.WaitForExit();
            Process.Start(@"C:\Program Files (x86)\XnView\xnview.exe", @"e:\tmp\droid.png");
        }
    private void GainPigment(Pigment pigmentColor)
    {
        if (colorsObtained.Contains(pigmentColor))
        {
            return;
        }

        colorsObtained.Add(pigmentColor);
        CycleMenu.instance.AddToMenu(pigmentColor);
        pigmentIndex = colorsObtained.Count - 1;

        if (colorsObtained.Count == 1)
        {
            Invoke("UsePigment", 0.1f);
        }
        else
        {
            AudioManager.instance.PlaySound("New_Color");
        }

        if (colorsObtained.Count == 2)
        {
            //PigmentViewer.instance.ShowArrows();
        }
    }
Example #6
0
 public Hexagon(Pigment hexagon1, Pigment hexagon2, Pigment hexagon3)
 {
     this.AllowNormal = false;
     this.Hexagon1    = hexagon1;
     this.Hexagon2    = hexagon2;
     this.Hexagon3    = hexagon3;
 }
Example #7
0
 protected override void DrawFrame(Pigment pigment = null)
 {
     if (this.Size.Width > 2 && this.Size.Height > 2)
     {
         Canvas.PrintFrame(string.IsNullOrEmpty(Title) ? null : Title, pigment);
     }
 }
Example #8
0
 protected override void DrawFrame(Pigment pigment = null)
 {
     if (this.Size.Width > 2 && this.Size.Height > 2)
     {
         Canvas.PrintFrame(_useSmallVersion ? Title : null, pigment);
     }
 }
Example #9
0
 /// <summary>
 /// Draw a frame around the control border.  If the <paramref name="pigment"/> is null,
 /// the frame will drawn with the Canvas' current default pigment.
 /// </summary>
 protected override void DrawFrame(Pigment pigment = null)
 {
     if (this.Size.Width > 2 && this.Size.Height > 2)
     {
         Canvas.PrintFrame(_title, pigment);
     }
 }
Example #10
0
        public void TestPigment2()
        {
            var c       = new PovColor("White", 1, 1, 1);
            var pigment = new Pigment("myPigment", c);

            Check.That(pigment.Name).IsEqualTo("myPigment");
            Check.That(pigment.Color).IsEqualTo(c);
        }
Example #11
0
 public Square(Pigment item1, Pigment item2, Pigment item3, Pigment item4)
 {
     this.AllowNormal = false;
     this.Item1       = item1;
     this.Item2       = item2;
     this.Item3       = item3;
     this.Item4       = item4;
 }
Example #12
0
        public void TestPigmentPovCode()
        {
            var c       = new PovColor("White", 1, 1, 1);
            var pigment = new Pigment("myPigment", c);
            var povCode = pigment.ToPovCode();

            Check.That(povCode).IsEqualTo("pigment {\n color White\n}");
        }
Example #13
0
 //gets called when pigment button is clicked
 public void pigment_selected(Pigment p)
 {
     //set currently displayed color
     color_picker_ui.set_color(p.get_color());
     //update pigment information view
     //pigment_name.text = p.name;
     // pigment_text.text = p.description;
 }
Example #14
0
 /// <summary>
 /// Prints the specified string within the given Rect.  The text is aligned
 /// both horizontally and vertically with the specified alignments.
 /// If the text length is larger than the field width, then the text will be trimmed to fit.
 /// The field width and height must be equal to or greater than 1, or an exception will
 /// be thrown.
 /// </summary>
 /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="text"/> is
 /// null</exception>
 /// <exception cref="System.ArgumentOutOfRangeException">
 /// Thrown when the specified <paramref name="rect"/> is outside of this Canvas region</exception>
 /// <exception cref="System.ArgumentOutOfRangeException">
 /// Thrown when the width or height of the rect is less than 1</exception>
 public void PrintStringAligned(Rectangle rect, string text, HorizontalAlignment hAlign,
                                VerticalAlignment vAlign, Pigment pigment = null)
 {
     PrintStringAligned(rect.TopLeft.X, rect.TopLeft.Y,
                        text,
                        hAlign, vAlign,
                        rect.Size,
                        pigment);
 }
Example #15
0
        public void TestDeclarePigmentPovCode()
        {
            var c       = new PovColor("White", 1, 1, 1);
            var pigment = new Pigment(c);
            var dec     = new DeclareElement("myPigment", pigment);
            var povCode = dec.ToPovCode();

            Check.That(povCode).IsEqualTo("#declare myPigment = pigment {\n color White\n};");
        }
Example #16
0
        public void TestPigment()
        {
            var pigment = new Pigment();

            Check.That(pigment.Name).IsNull();
            var c = new PovColor(0, 0, 0);

            Check.That(pigment.Color).IsEqualTo(c);
        }
Example #17
0
        /// <summary>
        /// Sets the default pigment for this Canvas.  If no other pigment is specified
        /// for drawing operations, this pigment is used.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">Thrown if <paramref name="pigment"/>
        /// is null</exception>
        public void SetDefaultPigment(Pigment pigment)
        {
            if (pigment == null)
            {
                throw new ArgumentNullException("pigment");
            }

            _defaultPigment = pigment;
            SetPigment(pigment);
        }
Example #18
0
 public void TogglePigment(Pigment pigment)
 {
     foreach (ToggleableObject obj in toggleableObjects)
     {
         if (obj.pigmentColor.Equals(pigment.pigmentColor))
         {
             obj.Toggle();
         }
     }
 }
Example #19
0
        public void AddText(string text, Color foreground)
        {
            if (foreground == null)
            {
                throw new ArgumentNullException("foreground");
            }

            Pigment pigment = DetermineMainPigment().ReplaceForeground(foreground);

            AddText(text, pigment);
        }
Example #20
0
 public Cubic(Pigment xFront, Pigment yFront, Pigment zFront, Pigment xBack,
              Pigment yBack, Pigment zBack)
 {
     this.AllowNormal = false;
     this.XFront      = xFront;
     this.YFront      = yFront;
     this.ZFront      = zFront;
     this.XBack       = xBack;
     this.YBack       = yBack;
     this.ZBack       = zBack;
 }
Example #21
0
        public void TestSphereWithPigment()
        {
            var sphere   = new Sphere();
            var whiteCol = new PovColor(1, 1, 1);
            var pigment  = new Pigment(whiteCol);

            sphere.AddModifiers(pigment);
            var povCode = sphere.ToPovCode();

            Check.That(povCode).IsEqualTo("sphere {\n < 0, 0, 0>, 1\n\npigment {\n color rgb < 1, 1, 1>\n}\n}");
        }
Example #22
0
        public void TestBoxWithPigment()
        {
            var box      = new Box();
            var whiteCol = new PovColor(1, 1, 1);
            var pigment  = new Pigment(whiteCol);

            box.AddModifiers(pigment);
            var povCode = box.ToPovCode();

            Check.That(povCode).IsEqualTo("box {\n < 0, 0, 0>, < 1, 1, 1>\n\npigment {\n color rgb < 1, 1, 1>\n}\n}");
        }
Example #23
0
 public FProgressBar()
 {
     SetStyle((ControlStyles)8198, true);
     Colors = new Pigment[] {
         new Pigment("Border", 214, 214, 216),
         new Pigment("Backcolor1", 247, 247, 251),
         new Pigment("Backcolor2", 239, 239, 242),
         new Pigment("Highlight", 100, 255, 255, 255),
         new Pigment("Forecolor", 224, 224, 224),
         new Pigment("Gloss", 130, 255, 255, 255)
     };
 }
Example #24
0
        /// <summary>
        /// Construct a Canvas object of the given size.
        /// </summary>
        /// <exception cref="System.ArgumentOutOfRangeException">Thrown when the specified
        /// <paramref name="size"/> is larger than the screen size</exception>
        public Canvas(Size size)
        {
            if (size.Width > Application.ScreenSize.Width ||
                size.Height > Application.ScreenSize.Height)
            {
                throw new ArgumentOutOfRangeException("size", "The specified size must be equal to or smaller than the screen size");
            }

            _defaultPigment = new Pigment(0xffffff, 0x000000);
            Console         = new TCODConsole(size.Width, size.Height);
            Size            = size;
        }
Example #25
0
        public DroidBody(Pigment mainPigment, Pigment decoPigmentMajor, Pigment decoPigmentMinor)
        {
            // Main Body
            Add(new Sphere()
            {
                Radius = rBody
            });

            // Sides
            var ring = new CsgDifference(
                new Cylinder {
                BasePoint = _Zero, CapPoint = rBody * _Z, Radius = rOutterSide
            }
                )
                       .Add(new Cylinder {
                BasePoint = _Zero, CapPoint = (rBody + 0.1) * _Z, Radius = rInnerSide
            })
            ;

            Local(nameof(ring), ring);
            var bidule = new Prism {
                Height1 = 0, Height2 = rBody
            }.Add(-0.1, 0).Add(-0.05, 0.2).Add(0.05, 0.2).Add(0.1, 0).TranslateZ(-rInnerSide).RotateX(90);

            Local(nameof(bidule), bidule);
            var side = new CsgUnion().Add(
                ring,
                bidule.Obj().RotateZ(0 * 90),
                bidule.Obj().RotateZ(1 * 90),
                bidule.Obj().RotateZ(2 * 90),
                bidule.Obj().RotateZ(3 * 90)
                )
            ;

            Local(nameof(side), side);
            var sides = new CsgUnion().Add(
                side.Obj().RotateY(0 * 90),
                side.Obj().RotateY(1 * 90),
                side.Obj().RotateY(2 * 90),
                side.Obj().RotateY(3 * 90),
                side.Obj().RotateY(3 * 90),
                side.Obj().RotateX(90),
                side.Obj().RotateX(-90))
            ;

            Add(new CsgIntersection().Add(new Sphere {
                Radius = rBody * 1.0001
            }).Add(sides).AddModifiers(decoPigmentMajor));
            this.TranslateY(rBody);
            AddModifiers(mainPigment);
        }
Example #26
0
 public FButton()
 {
     SetStyle((ControlStyles)8198, true);
     Colors = new Pigment[] {
         new Pigment("Border", 254, 133, 0),
         new Pigment("Backcolor", 247, 247, 251),
         new Pigment("Highlight", 255, 197, 19),
         new Pigment("Gradient1", 255, 175, 12),
         new Pigment("Gradient2", 255, 127, 1),
         new Pigment("Text Color", Color.White),
         new Pigment("Text Shadow", 30, 0, 0, 0)
     };
     Font = new Font("Verdana", 8);
 }
Example #27
0
 public FTheme()
 {
     SetStyle((ControlStyles)8198, true);
     Pigment[] C = new Pigment[] {
         new Pigment("Border", Color.Black),
         new Pigment("Frame", 47, 47, 50),
         new Pigment("Border Highlight", 15, 255, 255, 255),
         new Pigment("Side Highlight", 6, 255, 255, 255),
         new Pigment("Shine", 20, 255, 255, 255),
         new Pigment("Shadow", 38, 38, 40),
         new Pigment("Backcolor", 247, 247, 251),
         new Pigment("Transparency", Color.Fuchsia)
     };
 }
Example #28
0
        public DroidObject(Pigment mainPigment, Pigment decoPigmentMajor, Pigment decoPigmentMinor)
        {
            Head = new DroidHead(mainPigment, decoPigmentMajor, decoPigmentMinor);
            Body = new DroidBody(mainPigment, decoPigmentMajor, decoPigmentMinor);

            Comment("*****************\nHead\n***********************");
            Add(
                Head
                .TranslateY(Body.Height.Value * 0.97)
                );
            Comment("*****************\nBody\n***********************");
            Add(
                Body
                );
        }
Example #29
0
        protected internal override void OnSettingUp()
        {
            base.OnSettingUp();

            int  fieldWidth = NumberEntryTemplate.CalculateFieldWidth(MaximumValue, MinimumValue);
            Size fieldSize  = new Size(fieldWidth, 1);

            if (BarPigment == null)
            {
                BarPigment = DetermineMainPigment();
            }

            _valueBar = new VerticalValueBar(new VerticalValueBarTemplate()
            {
                TopLeftPos    = this.LocalToScreen(new Point(0, 0)),
                Length        = this.Size.Height - 2,
                MaximumValue  = this.MaximumValue,
                MinimumValue  = this.MinimumValue,
                StartingValue = this.CurrentValue,
                BarPigment    = this.BarPigment,
            });

            _topButton = new EmitterButton(new EmitterButtonTemplate()
            {
                HasFrameBorder     = false,
                Label              = Char.ToString((char)libtcod.TCODSpecialCharacter.ArrowNorthNoTail),
                TopLeftPos         = this.LocalToScreen(new Point(0, 0)),
                StartEmittingDelay = SpinDelay,
                Speed              = SpinSpeed
            });

            _bottomButton = new EmitterButton(new EmitterButtonTemplate()
            {
                HasFrameBorder     = false,
                Label              = Char.ToString((char)libtcod.TCODSpecialCharacter.ArrowSouthNoTail),
                TopLeftPos         = this.LocalToScreen(new Point(0, 0).Shift(0, Size.Height - 1)),
                StartEmittingDelay = SpinDelay,
                Speed              = SpinSpeed
            });

            _valueBar.MouseMoved += valueBar_MouseMoved;

            _valueBar.MouseButtonDown += valueBar_MouseButtonDown;

            _topButton.Emit    += topButton_Emit;
            _bottomButton.Emit += bottomButton_Emit;
        }
Example #30
0
        /// <summary>
        /// Sets the pigment of a single character at the given coordinates.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">Thrown when pigment is null</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified <paramref name="position"/> is outside of this Canvas region</exception>
        public void SetCharPigment(Point position, Pigment pigment)
        {
            if (pigment == null)
            {
                throw new ArgumentNullException("pigment");
            }

            if (position.X < 0 || position.X >= Size.Width)
            {
                throw new ArgumentOutOfRangeException("position", "The specified x coordinate is invalid.");
            }

            if (position.Y < 0 || position.Y >= Size.Width)
            {
                throw new ArgumentOutOfRangeException("position", "The specified y coordinate is invalid.");
            }

            SetCharPigment(position.X, position.Y, pigment);
        }
Example #31
0
        public void AddText(string text,Pigment pigment=null)
        {
            string[] words = Explode(text);

            foreach (string word in words)
            {
                if (!string.IsNullOrEmpty(word))
                {
                    if ((currVirtualPos + Canvas.TextLength(word) >= LineLength) &&
                        (word[0] != '\n'))
                    {
                        buffer.Enqueue(new Atom('\n'));
                        currVirtualPos = 0;
                    }

                    foreach (char c in word)
                    {
                        buffer.Enqueue(new Atom(c,pigment));
                        currVirtualPos++;

                        if (c == '\n')
                            currVirtualPos = 0;
                    }

                    if (currVirtualPos != 0)
                    {
                        buffer.Enqueue(new Atom(' ',pigment));
                        currVirtualPos++;
                    }
                }
            }
        }
Example #32
0
 public Atom(char c,Pigment pigment=null)
 {
     this.c = c;
     this.pigment = pigment;
 }