Esempio n. 1
0
        private void buttonInstances_Click(object sender, EventArgs e)
        {
            //GraphicsWindow.Show();
            Primitive win = new Primitive();

            for (int i = 0; i < 3; i++)
            {
                win[i] = LDWindows.Create();
                GraphicsWindow.Title = i.ToString();
                //Shapes.AddEllipse(100, 100);
            }
            LDWindows.CurrentID = win[0];
            Primitive ball = Shapes.AddEllipse(100, 100);

            LDWindows.CurrentID = win[1];
            Shapes.AddEllipse(100, 100);
            GraphicsWindow.BackgroundColor = "Red";
            GraphicsWindow.Hide();
            LDWindows.CurrentID = 0;
            GraphicsWindow.Show();
            LDWindows.CurrentID = win[0];
            Shapes.Move(ball, 200, 200);
            LDWindows.CurrentID = 0;
            Shapes.Move(ball, 300, 300);
            //LDWindow.Hide(win[0]);
            //LDWindow.Close(win[1]);
            //Program.Delay(5000);
            //LDWindow.Hide(win[2]);
        }
Esempio n. 2
0
 static void Main(string[] args)
 {
     GraphicsWindow.Show();
     Turtle.PenName("Red");
     (1000).Times(i =>
     {
         Turtle.Forward(6);
         Turtle.Right(i * 7);
     });
 }
Esempio n. 3
0
        static void Main()
        {
            GraphicsWindow.Show();

            GraphicsWindow.MouseDown += () =>
            {
                Coloring(10, 10);
                Paint(550, 50, 10);
            };
            Paint(50, 50, 10);
        }
Esempio n. 4
0
        private void buttonDialogs_Click(object sender, EventArgs e)
        {
            int i;

            GraphicsWindow.Show();
            Primitive items  = "";
            Primitive images = "";

            for (i = 1; i <= 5; i++)
            {
                items[i]  = "Item " + i;
                images[i] = "C:\temp\test.jpg";
            }
            LDDialogs.AddRightClickMenu(items, images);

            TextWindow.WriteLine(System.Windows.Media.RenderCapability.Tier >> 16);
            Primitive a1 = LDArray.Create(1000);

            Shapes.AddEllipse(50, 50);
            FormPropertyGrid grid = new FormPropertyGrid();

            grid.Display("_mainCanvas");
            Primitive properties = grid.GetProperties("_mainCanvas");

            for (i = 1; i <= SBArray.GetItemCount(properties); i++)
            {
                TextWindow.WriteLine(properties[i]);
            }

            grid.SetProperty("_mainCanvas.Children.Ellipse1.Opacity", 0.5);

            Primitive font     = LDDialogs.Font("");
            Primitive font2    = LDDialogs.Font(font);
            Primitive fileName = LDDialogs.OpenFile("Small Basic File (*.sb) |*.sb", "");

            LDUtilities.Version();
            GraphicsWindow.Show();
            TextWindow.WriteLine(LDDialogs.Calendar(LDDateTime.Add(LDDateTime.Now(), 7))); //Now + 7 days
            //LDUtilities.PauseUpdates();
            LDDialogs.Wait("Please wait for a few seconds while I draw something...", LDColours.SetOpacity(LDColours.Violet, 200));
            double start = Clock.ElapsedMilliseconds;

            i = 1;
            while (Clock.ElapsedMilliseconds < start + 5000)
            {
                Primitive ball = Shapes.AddEllipse(20, 20);
                Shapes.Move(ball, SBMath.GetRandomNumber(GraphicsWindow.Width) - 10, SBMath.GetRandomNumber(GraphicsWindow.Height) - 10);
                LDDialogs.ToolTip(ball, "Ball " + i++);
                SBProgram.Delay(100);
            }
            //LDUtilities.ResumeUpdates();
            LDDialogs.EndWait();
        }
Esempio n. 5
0
        static void Sierpinsky()
        {
            var Vertices = new Tuple <int, int>[] { new Tuple <int, int>(0, 600), new Tuple <int, int>(300, 0), new Tuple <int, int>(600, 600) };
            var p        = new Tuple <int, int>(300, 300);

            GraphicsWindow.Show();
            for (int i = 0; i < 100000; i++)
            {
                GraphicsWindow.SetPixel(p.Item1, p.Item2, "Black");
                var v = Pick(Vertices);
                p = new Tuple <int, int>((p.Item1 + v.Item1) / 2, (p.Item2 + v.Item2) / 2);
            }
        }
        static void Main(string[] args)
        {
            GraphicsWindow.Show();



            GraphicsWindow.SetPixel(10, 10, "red");

            int x1 = 312, y1 = 10,
                x2 = 10, y2 = 430,
                x3 = 610, y3 = 430
            ;

            GraphicsWindow.SetPixel(x1, y1, "red");
            GraphicsWindow.SetPixel(x2, y2, "red");
            GraphicsWindow.SetPixel(x3, y3, "red");

            int size = 1;

            GraphicsWindow.DrawEllipse(x1 - size / 2, y1 - size / 2, size, size);
            GraphicsWindow.DrawEllipse(x2 - size / 2, y2 - size / 2, size, size);
            GraphicsWindow.DrawEllipse(x3 - size / 2, y3 - size / 2, size, size);
            Random random = new Random();

            GraphicsWindow.MouseDown += () =>
            {
                int x = x1, y = y1;
                for (int i = 0; i < 10000; i++)
                {
                    switch (random.Next(3))
                    {
                    case 0: x = (x + x1) / 2; y = (y + y1) / 2; break;

                    case 1: x = (x + x2) / 2; y = (y + y2) / 2; break;

                    case 2: x = (x + x3) / 2; y = (y + y3) / 2; break;
                    }
                    //GraphicsWindow.DrawEllipse(x - size / 2, y - size / 2, size, size);
                    GraphicsWindow.SetPixel(x, y, "red");
                }



                //GraphicsWindow.DrawEllipse(
                //    x: GraphicsWindow.MouseX - size / 2 ,
                //    y: GraphicsWindow.MouseY - size / 2,
                //    width: size,
                //    height: size);
            };
        }
Esempio n. 7
0
            public void setActive()
            {
                InvokeHelper ret = delegate
                {
                    try
                    {
                        GraphicsWindow.Show();
                        window.Activate();
                    }
                    catch (Exception ex)
                    {
                        Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                    }
                };

                FastThread.Invoke(ret);
            }
Esempio n. 8
0
        /// <summary>
        /// Create a chart control.
        /// The current GraphicsWindow.BackgroundColor will be used for the background.
        /// The current GraphicsWindow.PenColor and Font properties will be used for the label text.
        /// For Example:
        /// GraphicsWindow.FontName = "Segoe UI"
        /// GraphicsWindow.FontBold = "False"
        /// </summary>
        /// <param name="width">The width of the chart.</param>
        /// <param name="height">The height of the chart.</param>
        /// <returns>The chart shape name.</returns>
        public static Primitive AddChart(Primitive width, Primitive height)
        {
            GraphicsWindow.Show();
            Type   GraphicsWindowType = typeof(GraphicsWindow);
            Type   ShapesType         = typeof(Shapes);
            Canvas _mainCanvas;
            Dictionary <string, UIElement> _objectsMap;
            string chartName;

            try
            {
                MethodInfo method = GraphicsWindowType.GetMethod("VerifyAccess", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase);
                method.Invoke(null, new object[] { });

                method    = ShapesType.GetMethod("GenerateNewName", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase);
                chartName = method.Invoke(null, new object[] { "Control" }).ToString();

                _mainCanvas = (Canvas)GraphicsWindowType.GetField("_mainCanvas", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);
                _objectsMap = (Dictionary <string, UIElement>)GraphicsWindowType.GetField("_objectsMap", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);

                InvokeHelperWithReturn ret = new InvokeHelperWithReturn(delegate
                {
                    try
                    {
                        Chart chart            = new Chart(width, height);
                        chart.Name             = chartName;
                        _objectsMap[chartName] = chart;
                        _mainCanvas.Children.Add(chart);
                        return(chartName);
                    }
                    catch (Exception ex)
                    {
                        Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                        return("");
                    }
                });
                return(FastThread.InvokeWithReturn(ret).ToString());
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                return("");
            }
        }
Esempio n. 9
0
        private void buttonWeather_Click(object sender, EventArgs e)
        {
            GraphicsWindow.Show();
            LDControls.AddBrowser(200, 200, "http://smallbasic.com");
            string result = LDNetwork.HighScore("MyGame", "Steve", 1000);

            TextWindow.WriteLine(result);

            Primitive forecast = LDWeather.Forecast("Rhodes");

            for (int i = 1; i <= SBArray.GetItemCount(forecast); i++)
            {
                TextWindow.WriteLine(forecast[i]);
            }
            TextWindow.WriteLine(LDWeather.Location);
            TextWindow.WriteLine(LDWeather.Conditions);
            TextWindow.WriteLine(LDWeather.TempC);
            TextWindow.WriteLine(LDWeather.TempF);
            TextWindow.WriteLine(LDWeather.WindDirection);
            TextWindow.WriteLine(LDWeather.WindSpeed);
            TextWindow.WriteLine(LDWeather.Humidity);
        }
Esempio n. 10
0
            public Win(int _id)
            {
                id = _id;
                if (id > 0)
                {
                    mCreateWindow.Invoke(null, new object[] { });
                    GraphicsWindow.Show();
                }
                else
                {
                    bool _windowCreated = (bool)GraphicsWindowType.GetField("_windowCreated", BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
                    if (!_windowCreated)
                    {
                        GraphicsWindow.Show();
                        GraphicsWindow.Hide();
                    }
                }
                InvokeHelper ret = delegate
                {
                    try
                    {
                        window            = (Window)GraphicsWindowType.GetField("_window", BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
                        window.Activated += new EventHandler(ActivatedHandler);
                        FieldInfo[] fields = GraphicsWindowType.GetFields(BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.NonPublic);
                        foreach (FieldInfo i in fields)
                        {
                            obj.Add(GraphicsWindowType.GetField(i.Name, BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.NonPublic).GetValue(null));
                        }
                    }
                    catch (Exception ex)
                    {
                        Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                    }
                };

                FastThread.Invoke(ret);
            }
Esempio n. 11
0
        // Szierpinsky Triangle
        static void Szierpinsky()
        {
            GraphicsWindow.Show();
            int x = 100, y = 100;
            var Rnd = new Random();

            for (int i = 0; i < 100000; i++)
            {
                GraphicsWindow.SetPixel(x, y, "Black");
                var r = Rnd.Next(1, 30);
                if (r < 10)
                {
                    Move(ref x, ref y, 100, 500);
                }
                else if (r < 20)
                {
                    Move(ref x, ref y, 600, 500);
                }
                else
                {
                    Move(ref x, ref y, 350, 100);
                }
            }
        }
Esempio n. 12
0
        public static void UI(string FilePath, decimal Ping, string Title, string CopyrightDate, string ProductID)
        {
            int StackPointer = Stack.Add("EULA.UI()");

            GraphicsWindow.Show();
            GraphicsWindow.Left  = Desktop.Width / 3;
            GraphicsWindow.Top   = Desktop.Height / 4;
            GraphicsWindow.Title = Title + "EULA";

            LDControls.RichTextBoxReadOnly = true;
            string EulaTextBox = LDControls.AddRichTextBox(600, 350);

            LDControls.RichTextBoxReadOnly = false;
            Controls.Move(EulaTextBox, 10, 10);
            string CNTS = System.IO.File.ReadAllText(FilePath).Replace("<date>", CopyrightDate).Replace("<product>", ProductID);

            if (Ping == -1)             // DEV //TODO
            {
                Events.LogMessage(Language.Localization["Failed Load Online EULA"], Language.Localization["Error"]);
            }

            if (string.IsNullOrWhiteSpace(CNTS))             //TODO
            {
                System.Environment.Exit(2);
            }

            LDControls.RichTextBoxSetText(EulaTextBox, CNTS, false);
            CheckBox = LDControls.AddCheckBox("I have read and agree to this EULA.");
            Accept   = Controls.AddButton("Accept", 235, 390);
            Decline  = Controls.AddButton("Decline", 315, 390);
            Controls.Move(CheckBox, 190, 365);
            Controls.SetSize(Accept, 70, 30);
            Controls.SetSize(Decline, 70, 30);
            Controls.ButtonClicked += Handler;
            Stack.Exit(StackPointer);
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            Primitive[] enemies = new Primitive[10];
            GraphicsWindow.Show();
            var P = Shapes.AddRectangle(100, 20);

            Shapes.Move(P, 0, GraphicsWindow.Height - 20);
            GraphicsWindow.MouseMove += () =>
            {
                Shapes.Move(P, GraphicsWindow.MouseX - 50, GraphicsWindow.Height - 20);
            };
            GraphicsWindow.BrushColor = "yellow";
            var S     = Shapes.AddEllipse(20, 20);
            int x     = 2;
            int y     = 2;
            int stepx = 2;
            int stepy = 2;

            Mouse.HideCursor();
            var F = GraphicsWindow.Width / 10;

            for (int f = 0; f < 10; f++)
            {
                enemies[f] = Shapes.AddRectangle(F, 20);
                Shapes.Move(enemies[f], f * (F), 0);
            }

            Timer.Interval = 1;
            Timer.Tick    += () =>
            {
                Shapes.Move(S, x, y);
                x += stepx;
                y += stepy;
                if (x >= GraphicsWindow.Width - 20)
                {
                    stepx = -stepx;
                }
                //if (y >= GraphicsWindow.Height - 20)
                //{
                //    stepy = -stepy;
                // }
                if (x < 0)
                {
                    stepx = -stepx;
                }
                if (y < 0)
                {
                    stepy = -stepy;
                }
                var mx = GraphicsWindow.MouseX;
                var my = GraphicsWindow.Height - 40;
                if (((x >= mx - 50) && (x <= mx + 50)) && (y >= my))
                {
                    stepy = -stepy;
                }

                if ((x = Shapes.GetLeft(enemies[S])) && (y == Shapes.GetTop(enemies[P])))
                {
                }


                if (y > GraphicsWindow.Height)
                {
                    // Sound.PlayAndWait(" рингтон Sad trombone - Грустный тромбон.mp3");
                    Microsoft.SmallBasic.Library.Program.End();
                }
            };
        }
Esempio n. 14
0
        private void buttonTest_Click(object sender, EventArgs e)
        {
            Primitive shp = Microsoft.SmallBasic.Library.Controls.AddButton("Button", 10, 10);

            LDShapes.ReSize(shp, 100, 100);
            LDShapes.ReSize(shp, 200, 200);

            Primitive xx = LDFastArray.Add();

            LDFastArray.Set(xx, "1 2 3", 24);
            FieldInfo _primitive = typeof(Primitive).GetField("_primitive", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.Instance);
            Primitive aa         = "1 23 45";
            string    bb         = (string)_primitive.GetValue(aa);
            Primitive sb         = "1=1\\=\"hello\"\\;2\\=1\\;3\\=2\\;;2=1\\=3\\;2\\=test\\;3\\=3\\;;";
            Primitive arr        = LDFastArray.CreateFromValues(sb);
            Primitive sb1        = LDFastArray.ToArray(arr);

            Primitive a = LDFastArray.Add();

            LDFastArray.Set2D(a, 2, 5, 10);
            LDFastArray.Set2D(a, 2, 2, 20);
            LDFastArray.Set2D(a, 1, 8, 30);
            LDFastArray.Collapse(a);
            Primitive b = LDFastArray.ToArray(a);

            Primitive img = Microsoft.SmallBasic.Library.ImageList.LoadImage("https://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/STS120LaunchHiRes-edit1.jpg/153px-STS120LaunchHiRes-edit1.jpg");
            Primitive x1  = LDImage.Copy(img);

            LDImage.EffectCharcoal(x1);



            Primitive image = LDImage.NewImage(100, 100, "Red");

            LDImage.OpenWorkingImage(image);
            Primitive xml  = LDxml.Open("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\sample.xml");
            Primitive data = LDxml.ToArray();

            LDxml.FromArray(data);
            LDxml.Save("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\sample1.xml");
            Primitive txt = Microsoft.SmallBasic.Library.File.ReadContents("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\txt.txt");

            LDSearch.GetProof(txt, "");
            LDSearch.GetWeb("bill gates");
            return;

            //TextWindow.Show();
            //LDTextWindow.SetColours("Pink", "Orange");
            //TextWindow.WriteLine("Hello World");

            LDPhysics.ReadJson("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\LDPysics.json", 1, "False", "False", 0, 0);

            LDWaveForm.PlayWave(256, 1000, "0=-1;1=1;5=0;");

            Primitive shape = Shapes.AddRectangle(100, 100);

            LDEffect.Bloom(shape, "");
            Program.Delay(1000);

            LDControls.AddDataView(GraphicsWindow.Width, GraphicsWindow.Height, "1=Hello;2=World;");

            //string _urlTemplate = "https://api.flickr.com/services/rest/?sort=interestingness-desc&safe_search=1&license=1,2,3,4,5,6,7&api_key=";
            //string _picUrlTemplate = "http://farm{0}.static.flickr.com/{1}/{2}_{3}.jpg";
            byte[] array = Convert.FromBase64String("MWY5ZmI5ODE4Mjk2NzAwNTgwYmYzMzQwMjc5MzQ2YjY=");
            //_urlTemplate += Encoding.UTF8.GetString(array, 0, array.Length);
            TextWindow.WriteLine(Encoding.UTF8.GetString(array, 0, array.Length));

            Primitive rtb = LDControls.AddRichTextBox(100, 100);

            LDControls.RichTextBoxSetText(rtb, "Hello", "True");
            LDCall.Compile("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\testinclude.sb");
            Primitive include = LDCall.Include("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\testinclude.exe");

            TextWindow.WriteLine(include);

            LDUtilities.FixFlickr();//FCClipboard.GetText
            LDCall.CallAsync("SmallBasicLibrary.dll", "Microsoft.SmallBasic.Library", "Flickr", "GetRandomPicture", "Car");

            string      tempFileName = Path.GetTempFileName();
            Stream      stream       = null;
            Stream      stream2      = null;
            WebResponse webResponse  = null;

            try
            {
                string     url        = "https://a75b9da71f50095fc4dc527d860da4427f274b07.googledrive.com/host/0B9s0FFxEQDb6T3VUdEw3QTJDS1E/efecast00.mp3";
                Uri        uri        = new Uri(url);
                WebRequest webRequest = WebRequest.Create(url);
                webResponse = webRequest.GetResponse();
                stream      = System.IO.File.Open(tempFileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
                byte[] buffer = new byte[16384];
                long   num    = webResponse.ContentLength;
                stream2 = webResponse.GetResponseStream();
                int readCount = stream2.Read(buffer, 0, 16384);
                while (readCount > 0L)
                {
                    stream.Write(buffer, 0, readCount);
                    readCount = stream2.Read(buffer, 0, 16384);
                }
            }
            catch (Exception ex)
            {
                TextWindow.WriteLine(ex.Message);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
                if (stream2 != null)
                {
                    stream2.Close();
                }
                if (webResponse != null)
                {
                    webResponse.Close();
                }
            }

            LDGraphicsWindow.SetFontFromFile("C:\\temp\\04b.ttf");
            TextWindow.Show();
            //Primitive source = "class Evaluator { public static function Eval(expr : String) : String { return eval(expr); } }";
            //LDInline.IncludeJScript(source,"","");
            //Primitive result = LDInline.Call("Eval","5+3");
            //TextWindow.WriteLine(result);

            //TextWindow.Hide();
            Primitive x = LDMath.Evaluate("1e6 + 6/4");
            Primitive y = LDMath.Evaluate2("1e6 + 6/4");

            //TextWindow.Hide();
            TextWindow.WriteLine("HERE " + x + " :" + y);

            LDImage.LoadSVG("C:\\temp\\snowtitle.svg");
            TextWindow.WriteLine(LDNetwork.LAN(1000));

            GraphicsWindow.Show();
            LDText.GetWidth("Hello World");

            Primitive server = LDServer.Start("True");

            LDClient.Connect(server, "True");
            LDClient.SendMessage("Hello1");
            LDClient.SendMessage("World1");
            LDServer.Disconnect("Client1");
            LDClient.Connect(server, "True");
            LDClient.SendMessage("Hello3");
            LDClient.SendMessage("World3");

            GraphicsWindow.Show();
            LDGraphicsWindow.FloodFill(200, 100, "#5588ee");
            //Program.Delay(1000000);
            //Primitive languages = LDTranslate.Languages();
            //Primitive indices = SBArray.GetAllIndices(languages);
            //for (int i = 1; i <= SBArray.GetItemCount(languages); i++)
            //{
            //    TextWindow.WriteLine(indices[i] + " : " + languages[indices[i]]);
            //}
            //Primitive result = LDTranslate.Translate("Hello World", "", "de");
            //TextWindow.WriteLine(result);

            //TextWindow.WriteLine(GraphicsWindow.FontName);
            //GraphicsWindow.DrawText(10, 10, "Hello World");
            //Primitive result = LDGraphicsWindow.SetFontFromFile("C:\\Users\\Public\\Documents\\SmallBasic\\steve\\WWFlakes.ttf");
            //TextWindow.WriteLine(GraphicsWindow.FontName);
            //GraphicsWindow.DrawText(10, 50, "Hello World");

            //PrivateFontCollection fntColl = new PrivateFontCollection();
            //fntColl.AddFontFile("C:\\Users\\Public\\Documents\\SmallBasic\\steve\\WWFlakes.ttf");
            //buttonTest.Font = new Font(fntColl.Families[0], 16, FontStyle.Regular);

            //LDDictionary.GetDefinition("Car");
        }
Esempio n. 15
0
        private void buttonShapes_Click(object sender, EventArgs e)
        {
            GraphicsWindow.Show();
            LDScrollBars.Rasterize    = "True";
            GraphicsWindow.MouseDown += OnMouseDown;
            LDScrollBars.Add(GraphicsWindow.Width, 10000);
            int       cogRadius    = 100;
            int       cogNumTeeth  = 10;
            int       cogToothSize = 10;
            Primitive cog          = Shapes.AddEllipse(2 * cogRadius, 2 * cogRadius);
            Primitive points       = "";
            Primitive point        = "";

            LDPhysics.AddMovingShape(cog, 0.5, 0.8, 1);
            for (int i = 1; i <= 1; i++)
            {
                double angle       = (i - 1) / cogNumTeeth * 2 * SBMath.Pi;
                double innerSector = 0.7 / cogNumTeeth * 2 * SBMath.Pi;
                double outerSector = 0.5 / cogNumTeeth * 2 * SBMath.Pi;
                point["X"] = cogRadius + cogRadius * SBMath.Cos(angle);
                point["Y"] = cogRadius + cogRadius * SBMath.Sin(angle);
                points[1]  = point;
                point["X"] = cogRadius + cogRadius * SBMath.Cos(angle + innerSector);
                point["Y"] = cogRadius + cogRadius * SBMath.Sin(angle + innerSector);
                points[2]  = point;
                point["X"] = cogRadius + (cogRadius + cogToothSize) * SBMath.Cos(angle + outerSector);
                point["Y"] = cogRadius + (cogRadius + cogToothSize) * SBMath.Sin(angle + outerSector);
                points[3]  = point;
                point["X"] = cogRadius + (cogRadius + cogToothSize) * SBMath.Cos(angle + innerSector - outerSector);
                point["Y"] = cogRadius + (cogRadius + cogToothSize) * SBMath.Sin(angle + innerSector - outerSector);
                points[4]  = point;
                Primitive tooth = LDShapes.AddPolygon(points);
                LDPhysics.AddMovingShape(tooth, 0.5, 0.8, 1);
                //LDPhysics.GroupShapes(cog, tooth);
            }

            LDPhysics.DoTimestep();

            Primitive ball = Shapes.AddEllipse(100, 50);

            //Shapes.Move(ball, 112, 112);
            //Shapes.Zoom(ball, 1, 1);
            //Shapes.Rotate(ball, -60);
            Shapes.Move(ball, 100, 112);
            //Shapes.Zoom(ball, 1.2, 1);
            //Shapes.Rotate(ball, -60);

            Primitive gradient = "";

            gradient[1] = "Red";
            gradient[2] = "Yellow";
            gradient[3] = "Blue";
            Primitive brush = LDShapes.BrushGradient(gradient, "H");

            LDShapes.BrushShape(ball, brush);

            LDUtilities.GWCapture("C:\\temp\\test.jpg", "False");

            Primitive rect = Shapes.AddRectangle(60, 60);

            Shapes.Move(rect, 25, 95);
            Shapes.Zoom(rect, 1.5, 1);
            Shapes.Rotate(rect, 45);
            //Shapes.Move(rect, 75, 75);
            //Shapes.Zoom(rect, 1.5, 1);
            //Shapes.Rotate(rect, 45);

            TextWindow.WriteLine(LDShapes.Overlap(ball, rect));
            //TextWindow.WriteLine(LDShapes.Overlap(rect, ball));

            Primitive image1 = Shapes.AddImage("C:\\temp\\test2.jpg");

            Shapes.Move(image1, 100, 100);
            TextWindow.WriteLine(LDShapes.Overlap(ball, image1));

            //LDShapes.AnimatedGifInterval = 0;
            Primitive gifShape = LDShapes.AddAnimatedGif("http://www.animatedgif.net//animals//birds//batana1_e0.gif", "True");

            Shapes.Move(gifShape, 100, 300);
            Primitive rectangle = Shapes.AddRectangle(100, 100);

            LDShapes.BrushColour(rectangle, "Red");
            Primitive img    = SBImageList.LoadImage("C:\\temp\\test.jpg");
            Primitive img2   = "C:\\temp\\test2.jpg";
            Primitive button = SBControls.AddButton("TEST", 100, 100);

            SBControls.SetSize(button, 50, 50);
            Primitive image = Shapes.AddImage(img);

            LDShapes.ReSize(image, 50, 50);
            LDShapes.Centre(image, 400, 25);
            SBProgram.Delay(1000);
            LDShapes.SetImage(image, img2);
            LDShapes.SetImage(button, img);
            SBProgram.Delay(1000);
            LDShapes.AnimationInterval = 0;
            LDShapes.AnimationSet(gifShape, LDShapes.AnimationCount(gifShape) / 3);
            SBProgram.Delay(1000);
            LDShapes.AnimationInterval = 50;
            LDShapes.AnimationPause(gifShape);
            SBProgram.Delay(2000);
            Shapes.HideShape(gifShape);
            LDShapes.AnimationResume(gifShape);
            SBProgram.Delay(2000);
            Shapes.ShowShape(gifShape);
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            GraphicsWindow.Show();
            var p = Shapes.AddRectangle(100, 20);

            Shapes.Move(p, 0, GraphicsWindow.Height - 20);
            GraphicsWindow.MouseMove += () => { Shapes.Move(p, GraphicsWindow.MouseX - 50, GraphicsWindow.Height - 20); };
            Primitive[] enemies = new Primitive[20];
            GraphicsWindow.BrushColor = "Gray";
            var c = Shapes.AddEllipse(20, 20);

            Timer.Interval = 10;
            int circleX = GraphicsWindow.Width / 2, circleY = GraphicsWindow.Height / 2, stepx = 2, stepy = 2, my = GraphicsWindow.Height - 40, mx = GraphicsWindow.MouseX;
            int enemyWidth = GraphicsWindow.Width / 10 - 5;

            Mouse.HideCursor();
            GraphicsWindow.BrushColor = "Red";
            for (int i = 0; i < 10; i++)
            {
                enemies[i] = Shapes.AddRectangle(enemyWidth, 20);
                Shapes.Move(enemies[i], i * (GraphicsWindow.Width / 10), 30);
            }
            for (int i = 0; i < 10; i++)
            {
                enemies[i] = Shapes.AddRectangle(enemyWidth, 20);
                Shapes.Move(enemies[i], i * (GraphicsWindow.Width / 10), 55);
            }

            Timer.Tick += () =>
            {
                my = GraphicsWindow.Height - 40;
                mx = GraphicsWindow.MouseX;
                Shapes.Move(c, circleX += stepx, circleY += stepy);
                if (circleX >= GraphicsWindow.Width - 20)
                {
                    stepx = -stepx;
                }
                if (circleX <= 0)
                {
                    stepx = 4;
                }
                if ((circleX >= mx - 50 && circleX <= mx + 50) && (circleY >= my))
                {
                    stepy = -stepy;
                }
                if (circleY <= 0)
                {
                    stepy = 4;
                }
                if (circleY > GraphicsWindow.Height)
                {
                    Sound.PlayAndWait("1.mp3");
                    Microsoft.SmallBasic.Library.Program.End();
                }
                for (int i = 0; i < 10; i++)
                {
                    if ((circleX + 10 >= Shapes.GetLeft(enemies[i])) && (circleY <= Shapes.GetTop(enemies[i]) + 20) && (circleX <= Shapes.GetLeft(enemies[i]) + enemyWidth))
                    {
                        Shapes.Move(enemies[i], 9999, 9999);
                        stepy = -stepy;
                    }
                }
            };
        }
Esempio n. 17
0
        static void Main(string[] args)
        {
            GraphicsWindow.Show();

            GraphicsWindow.MouseDown += GraphicsWindow_MouseDown;
        }