コード例 #1
0
ファイル: App.cs プロジェクト: Zaid-Ajaj/Demos
        public static void Main()
        {
            var settings = new Options();

            var calculator = new Mandelbrot(settings);

            var drawer = new Drawer(settings, calculator);
        }
コード例 #2
0
ファイル: Proxy.cs プロジェクト: CSF-VSU/SpacePewPew
 private Proxy()
 {
     Manager = LayoutManager.GetManager();
     IsLocked = false;
     _game = Game.Instance();
     _drawer = Drawer.Instance();
     _keyController = new KeyController();
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Beansy/NickLevelDesigner
 public Form1()
 {
     InitializeComponent();
     this.PictureBoxHeight = pictureBox1.Height;
     this.PictureBoxWidth = pictureBox1.Width;
     this.pictureBoxTheseus.Image = this.theseus;
     this.pictureBoxMinotaur.Image = this.minotaur;
     myMouseHandler = new MouseHandler();
     drawer = new Drawer();
     mapBuilder = new MapBuilder();
 }
コード例 #4
0
 public WorldController()
 {
     Bitmap map = new Bitmap(1000, 700);
     Graphics g = Graphics.FromImage(map);
     g.FillRectangle(new SolidBrush(Color.White), 0, 0, map.Width, map.Height);
     g.Dispose();
     drawer = new Drawer("C:\\Users\\André\\Desktop\\map.png"); //Loading the map and drawer
     car = new Car(55, 30); //L = C*0.55
     car.X = 100;
     car.Y = 100;
     drawer.AddDrawable(car); //Adding car to the drawable list
     fis = new FIS();
     pso = new PSOHandler(500, 1000);
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: hedigerf/dotnetcourse
 public Program()
 {
     this.BackColor = System.Drawing.Color.White;
     this.BackgroundImage = new System.Drawing.Bitmap("..\\..\\Starsbg.jpg");
     this.ClientSize = new System.Drawing.Size(1000, 1000);
     Timer timer = new Timer();
     timer.Enabled = true;
     timer.Interval = 50;
     timer.Tick += tick;
     Planet jupiter = new Planet("jupiter", 200, 200, 50, 50, 40);
     Planet mars = new Planet("mars", 500, 100, 0, 100, 20);
     Spaceship enterpise = new Spaceship("enterprise",400,400,200,200,10);
     drawers += jupiter.Draw;
     drawers += mars.Draw;
     drawers += enterpise.Draw;
 }
コード例 #6
0
ファイル: ArrowDrawer.cs プロジェクト: cohama/Conta
        /// <summary>
        /// 新しいベクトル描画マネージャを作成します。
        /// </summary>
        /// <param name="g">グラフィックデバイス</param>
        /// <param name="arrow">矢印の設定オブジェクト</param>
        /// <param name="MaxValue">データの最大値</param>
        public ArrowDrawer( Graphics g, VectorSetting arrow, double MaxValue, double MinValue )
        {
            this.Arrow = arrow;
            this.G = g;

            this.maxValue = MaxValue;
            this.minValue = MinValue;
            this.refValue = arrow.ReferredLength;
            this.unitLength = 500/20.0;
            this.magnitude = this.Arrow.Length/100.0/this.refValue*this.unitLength*2;
            this.tipMagnitude = this.Arrow.TipLength/100.0*this.magnitude;
            this.halfTipAngle = arrow.TipAngle/180.0*Math.PI/2.0;
            this.tan_halfTipAngle = Math.Tan( this.halfTipAngle );
            this.linePen = new Pen( arrow.LineColor, arrow.LineWidth );
            this.innerBrush = new SolidBrush( arrow.InnerColor );

            switch( arrow.TipType )
            {
                case TipType.FillTriangle:
                    this.arrowDrawer = this.drawTrAnglArrow;
                    break;
                case TipType.LineTip:
                    this.arrowDrawer = this.drawLineArrow;
                    break;
                default:
                    throw new NotImplementedException();
            }
            if( arrow.FixTipSize )
            {
                this.pointCalculator = this.calcFixPoints;
            }
            else
            {
                this.pointCalculator = this.calcVarPoints;
            }
            if( arrow.Colorful )
            {
                this.lineColorSetter = this.setColorfulColor;
                this.innerColorSetter = this.setColorfulColor;
            }
            else
            {
                this.lineColorSetter = this.setFixedPenColor;
                this.innerColorSetter = this.setFixedBrushColor;
            }
        }
コード例 #7
0
        public void TestConcurrentRepeatedDraw()
        {
            int threads = 4;
            TestHelpers.InMethod();

            SetupScene(false);

            List<Drawer> drawers = new List<Drawer>();

            for (int i = 0; i < threads; i++)
            {
                Drawer d = new Drawer(this, i);
                drawers.Add(d);
                Console.WriteLine("Starting drawer {0}", i);
                Util.FireAndForget(o => d.Draw(), null, "VectorRenderModuleStressTests.TestConcurrentRepeatedDraw");
            }

            Thread.Sleep(10 * 60 * 1000);

            drawers.ForEach(d => d.Ready = false);
            drawers.ForEach(d => Console.WriteLine("Drawer {0} drew {1} textures", d.Number, d.Pass + 1));
        }
コード例 #8
0
ファイル: Vectorgram.cs プロジェクト: cohama/Conta
        public void DrawTo( Image img, ColorContour contour, FieldSettings field )
        {
            if( !contour.HasVectorData )
            {
                throw new InvalidOperationException( "ベクトルデータはありません" );
            }
            Graphics g = Graphics.FromImage( img );
            Pen p = new Pen( field.Arrow.LineColor );
            Brush b = new SolidBrush( field.Arrow.InnerColor );
            PointF origin = new PointF( (float)contour.BmpMargin, (float)contour.BmpMargin );
            float unitX = (float)(contour.BmpWidth - 2*contour.BmpMargin -1) / (contour.XNum - 1);
            float unitY = (float)(contour.BmpHeight- 2*contour.BmpMargin -1) / (contour.YNum - 1);

            Drawer d = new Drawer( g, field );

            for( int i=0; i<contour.XNum; i++ )
            {
                for( int j=0; j<contour.YNum; j++ )
                {
                    SizeF pt1 = new SizeF( i*unitX, (contour.YNum-1-j)*unitY );
                    d.DrawArrow( origin + pt1, contour.scrData[i][j], contour.uData[i][j], contour.vData[i][j] );
                }
            }
        }
コード例 #9
0
ファイル: Game.cs プロジェクト: CSF-VSU/SpacePewPew
 public void Init(Drawer drawer)
 {
     Manager = new FileManager();
 }
コード例 #10
0
    void FixedUpdate()
    {
        //Algorithm based on
        //http://www.cs.toronto.edu/~dt/siggraph97-course/cwr87/
        //http://www.red3d.com/cwr/boids/

        //Bird is affected by 3 base forses:
        // cohesion
        // separation + collisionAvoidance
        // alignmentForce

        var sepForce  = new BoidTools.SeparationForce(sts);
        var collAvoid = new BoidTools.CollisionAvoidanceForce(sts, sepForce.Calc(sts.OptDistance));

        //Geometric center of visible birds
        var centeroid = Vector3.zero;

        var collisionAvoidance = Vector3.zero;
        var avgSpeed           = Vector3.zero;
        var neighbourCount     = 0;

        //Store it as an optimization
        var direction = transform.rotation * Vector3.forward;
        var curPos    = transform.position;

        foreach (var vis in Physics.OverlapSphere(curPos, sts.ViewRadius))
        {
            var      visPos = vis.transform.position;
            Boid     boid;
            ITrigger trigger;

            if ((boid = vis.GetComponent <Boid>()) != null) //Birds processing
            {
                Vector3 separationForce;

                if (!sepForce.Calc(curPos, visPos, out separationForce))
                {
                    continue;
                }

                collisionAvoidance += separationForce;
                ++neighbourCount;
                centeroid += visPos;
                avgSpeed  += boid.velocity;
            }
            else if ((trigger = vis.GetInterface <ITrigger>()) != null)
            {
                if (GetComponent <Collider>().bounds.Intersects(vis.bounds))
                {
                    trigger.OnTouch(this);
                }
            }
            else //Obstacles processing
            {
                BoidTools.CollisionAvoidanceForce.Force force;
                if (collAvoid.Calc(curPos, direction, vis, out force))
                {
                    collisionAvoidance += force.dir;

                    if (dbgSts.enableDrawing && dbgSts.obstaclesAvoidanceDraw)
                    {
                        Drawer.DrawRay(force.pos, force.dir, dbgSts.obstaclesAvoidanceColor);
                    }
                }
            }
        }

        if (neighbourCount > 0)
        {
            //Cohesion force. It makes united formula with BoidTools.SeparationForce
            centeroid = centeroid / neighbourCount - curPos;

            //Spherical shape of flock looks unnatural, so let's scale it along y axis
            centeroid.y *= sts.VerticalPriority;

            //Difference between current bird speed and average speed of visible birds
            avgSpeed = avgSpeed / neighbourCount - velocity;
        }

        var positionForce   = (1.0f - sts.AligmentForcePart) * sts.SpeedMultipliyer * (centeroid + collisionAvoidance);
        var alignmentForce  = sts.AligmentForcePart * avgSpeed / Time.deltaTime;
        var attractionForce = CalculateAttractionForce(sts, curPos, velocity);
        var totalForce      = sts.TotalForceMultipliyer * (positionForce + alignmentForce + attractionForce);

        var newVelocity = (1 - sts.Inertness) * (totalForce * Time.deltaTime) + sts.Inertness * velocity;

        velocity = CalcNewVelocity(sts.MinSpeed, velocity, newVelocity, direction);

        var rotation = CalcRotation(sts.InclineFactor, velocity, totalForce);

        if (MathTools.IsValid(rotation))
        {
            gameObject.transform.rotation = rotation;
        }

        /////////////////////////////////////////////////////////////
        // Debug drawing
        /////////////////////////////////////////////////////////////
        if (dbgSts.enableDrawing)
        {
            if (dbgSts.velocityDraw)
            {
                Drawer.DrawRay(curPos, velocity, dbgSts.velocityColor);
            }

            if (dbgSts.positionForceDraw)
            {
                Drawer.DrawRay(curPos, positionForce, dbgSts.positionForceColor);
            }

            if (dbgSts.alignmentForceDraw)
            {
                Drawer.DrawRay(curPos, alignmentForce, dbgSts.alignmentForceColor);
            }

            if (dbgSts.cohesionForceDraw)
            {
                Drawer.DrawRay(curPos, centeroid, dbgSts.cohesionForceColor);
            }

            if (dbgSts.collisionsAvoidanceForceDraw)
            {
                Drawer.DrawRay(curPos, collisionAvoidance, dbgSts.collisionsAvoidanceForceColor);
            }

            if (dbgSts.attractionForceDraw)
            {
                Drawer.DrawRay(curPos, attractionForce, dbgSts.attractionForceColor);
            }

            if (dbgSts.totalForceDraw)
            {
                Drawer.DrawRay(curPos, totalForce, dbgSts.totalForceColor);
            }
        }
    }
コード例 #11
0
ファイル: Scaffold.cs プロジェクト: Clancey/FlutterSharp
        public Scaffold(AppBar appbar = null, FloatingActionButton floatingActionButton = null, Drawer drawer = null, Widget body = null)
        {
            var s = GetBackingStruct <ScaffoldStruct>();

            s.AppBar = this.appbar = appbar;
            s.FloatingActionButton = this.floatingActionButton = floatingActionButton;
            s.Drawer = this.drawer = drawer;
            s.Body   = this.body = body;
        }
コード例 #12
0
ファイル: GuitarProperties.cs プロジェクト: fearog/axecalc
 void DrawSaddleScrew( Drawer d, Vec2 vIntonationPoint )
 {
     if( m_eSaddleStyle == SaddleStyles.Hardtail )
     {
         d.DrawLine( "SaddleScrews", new Vec2( vIntonationPoint.x - 27, vIntonationPoint.y + 1.45 ), new Vec2( vIntonationPoint.x - 11.4, vIntonationPoint.y + 1.45 ) );
         d.DrawLine( "SaddleScrews", new Vec2( vIntonationPoint.x - 27, vIntonationPoint.y - 1.45 ), new Vec2( vIntonationPoint.x - 11.4, vIntonationPoint.y - 1.45 ) );
         d.DrawLine( "SaddleScrews", new Vec2( vIntonationPoint.x - 11.4, vIntonationPoint.y + 1.45 ), new Vec2( vIntonationPoint.x - 11.4, vIntonationPoint.y - 1.45 ) );
         d.DrawLine( "SaddleScrews", new Vec2( vIntonationPoint.x - 27, vIntonationPoint.y + 2.65 ), new Vec2( vIntonationPoint.x - 27, vIntonationPoint.y - 2.65 ) );
         d.DrawLine( "SaddleScrews", new Vec2( vIntonationPoint.x - 27, vIntonationPoint.y + 2.65 ), new Vec2( vIntonationPoint.x - 27, vIntonationPoint.y - 2.65 ) );
         d.DrawLine( "SaddleScrews", new Vec2( vIntonationPoint.x - 28.73, vIntonationPoint.y + 2.65 ), new Vec2( vIntonationPoint.x - 28.73, vIntonationPoint.y - 2.65 ) );
         d.DrawLine( "SaddleScrews", new Vec2( vIntonationPoint.x - 27, vIntonationPoint.y + 2.65 ), new Vec2( vIntonationPoint.x - 28.73, vIntonationPoint.y + 2.65 ) );
         d.DrawLine( "SaddleScrews", new Vec2( vIntonationPoint.x - 27, vIntonationPoint.y - 2.65 ), new Vec2( vIntonationPoint.x - 28.73, vIntonationPoint.y - 2.65 ) );
     }
 }
コード例 #13
0
        public override void Tick()
        {
            try
            {
                if (DebugSettings.noAnimals && RaceProps.Animal)
                {
                    Destroy();
                }
                else if (!Downed)
                {
                    if (Find.TickManager.TicksGame % 250 == 0)
                    {
                        TickRare();
                    }

                    if (Spawned)
                    {
                        pather.PatherTick();
                    }

                    Drawer.DrawTrackerTick();
                    health.HealthTick();
                    records.RecordsTick();
                    if (Spawned)
                    {
                        stances.StanceTrackerTick();
                    }

                    if (Spawned)
                    {
                        verbTracker.VerbsTick();
                    }

                    if (Spawned)
                    {
                        natives.NativeVerbsTick();
                    }

                    if (equipment != null)
                    {
                        equipment.EquipmentTrackerTick();
                    }

                    if (apparel != null)
                    {
                        apparel.ApparelTrackerTick();
                    }

                    if (Spawned)
                    {
                        jobs.JobTrackerTick();
                    }

                    if (!Dead)
                    {
                        carryTracker.CarryHandsTick();
                    }

                    if (skills != null)
                    {
                        skills.SkillsTick();
                    }

                    if (inventory != null)
                    {
                        inventory.InventoryTrackerTick();
                    }
                }

                if (needs != null && needs.food != null && needs.food.CurLevel <= 0.95f)
                {
                    needs.food.CurLevel = 1f;
                }

                if (needs != null && needs.joy != null && needs.joy.CurLevel <= 0.95f)
                {
                    needs.joy.CurLevel = 1f;
                }

                if (needs != null && needs.beauty != null && needs.beauty.CurLevel <= 0.95f)
                {
                    needs.beauty.CurLevel = 1f;
                }

                if (needs != null && needs.comfort != null && needs.comfort.CurLevel <= 0.95f)
                {
                    needs.comfort.CurLevel = 1f;
                }

                if (needs != null && needs.rest != null && needs.rest.CurLevel <= 0.95f)
                {
                    needs.rest.CurLevel = 1f;
                }

                if (needs != null && needs.mood != null && needs.mood.CurLevel <= 0.45f)
                {
                    needs.mood.CurLevel = 0.5f;
                }

                if (!setZombie)
                {
                    mindState.mentalStateHandler.neverFleeIndividual = true;
                    setZombie = ReanimatedPawnUtility.Zombify(this);
                    //ZombieMod_Utility.SetZombieName(this);
                }

                if (Downed || health.Downed || health.InPainShock)
                {
                    var damageInfo = new DamageInfo(DamageDefOf.Blunt, 9999, 1f, -1f, this);
                    damageInfo.SetHitPart(health.hediffSet.GetBrain());
                    //damageInfo.SetPart(new BodyPartDamageInfo(this.health.hediffSet.GetBrain(), false, HediffDefOf.Cut));
                    TakeDamage(damageInfo);
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #14
0
ファイル: PolyCollision.cs プロジェクト: scucmgame/Box2DSharp
        /// <inheritdoc />
        protected override void PostStep()
        {
            if (Input.GetKeyDown(KeyCode.A))
            {
                _positionB.X -= 0.1f;
            }

            if (Input.GetKeyDown(KeyCode.D))
            {
                _positionB.X += 0.1f;
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                _positionB.Y -= 0.1f;
            }

            if (Input.GetKeyDown(KeyCode.W))
            {
                _positionB.Y += 0.1f;
            }

            if (Input.GetKeyDown(KeyCode.Q))
            {
                _angleB += 0.1f * Settings.Pi;
            }

            if (Input.GetKeyDown(KeyCode.E))
            {
                _angleB -= 0.1f * Settings.Pi;
            }

            _transformB.Set(_positionB, _angleB);
            var manifold = new Manifold();

            CollisionUtils.CollidePolygons(ref manifold, _polygonA, _transformA, _polygonB, _transformB);
            var worldManifold = new WorldManifold();

            worldManifold.Initialize(manifold, _transformA, _polygonA.Radius, _transformB, _polygonB.Radius);
            DrawString($"point count = {manifold.PointCount}");
            {
                var color = Color.FromArgb(230, 230, 230);
                var v     = new Vector2[Settings.MaxPolygonVertices];
                for (var i = 0; i < _polygonA.Count; ++i)
                {
                    v[i] = MathUtils.Mul(_transformA, _polygonA.Vertices[i]);
                }

                Drawer.DrawPolygon(v, _polygonA.Count, color);

                for (var i = 0; i < _polygonB.Count; ++i)
                {
                    v[i] = MathUtils.Mul(_transformB, _polygonB.Vertices[i]);
                }

                Drawer.DrawPolygon(v, _polygonB.Count, color);
            }

            for (var i = 0; i < manifold.PointCount; ++i)
            {
                Drawer.DrawPoint(worldManifold.Points[i], 4.0f, Color.FromArgb(230, 77, 77));
            }
        }
コード例 #15
0
ファイル: ActionGame.cs プロジェクト: havri/ActionGame
 /// <summary>
 /// Prepares the game for its initialization.
 /// </summary>
 private void PreInitialize()
 {
     contentRepository = new ContentRepository(this);
     if (running)
     {
         camera = new Camera(this);
     #if debug
         debug = new Debug(this);
     #endif
         drawer = new Drawer(this, settings.ScreenSize.Width, settings.ScreenSize.Height);
         soundPlayer = new SoundPlayer(this);
         Components.Clear();
         Components.Add(camera);
         Components.Add(drawer);
     #if degub
         //Components.Add(debug);
     #endif
     }
 }
コード例 #16
0
 void Awake()
 {
     ThisDrawer = new Drawer(OutterDrawer, gameObject);
 }
コード例 #17
0
        public void PaintChartLine(CartesianChart cc)
        {
            Drawer pen = new Drawer(cc);

            pen.DrawLinerChart(Threat.Data.Select(x => x.Damage).ToArray(), "Основные данные");
        }
コード例 #18
0
ファイル: DistanceTest.cs プロジェクト: scucmgame/Box2DSharp
        /// <inheritdoc />
        protected override void PostStep()
        {
            if (Input.GetKeyDown(KeyCode.A))
            {
                _positionB.X -= 0.1f;
            }

            if (Input.GetKeyDown(KeyCode.D))
            {
                _positionB.X += 0.1f;
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                _positionB.Y -= 0.1f;
            }

            if (Input.GetKeyDown(KeyCode.W))
            {
                _positionB.Y += 0.1f;
            }

            if (Input.GetKeyDown(KeyCode.Q))
            {
                _angleB += 0.1f * Settings.Pi;
            }

            if (Input.GetKeyDown(KeyCode.E))
            {
                _angleB -= 0.1f * Settings.Pi;
            }

            _transformB.Set(_positionB, _angleB);

            var input = new DistanceInput();
            input.ProxyA.Set(_polygonA, 0);
            input.ProxyB.Set(_polygonB, 0);
            input.TransformA = _transformA;
            input.TransformB = _transformB;
            input.UseRadii = true;
            var cache = new SimplexCache();
            DistanceAlgorithm.Distance(out var output, ref cache, input);

            DrawString($"distance = {output.Distance}");

            DrawString($"iterations = {output.Iterations}");

            {
                var color = Color.FromArgb(230, 230, 230);
                var v = new Vector2[Settings.MaxPolygonVertices];
                for (var i = 0; i < _polygonA.Count; ++i)
                {
                    v[i] = MathUtils.Mul(_transformA, _polygonA.Vertices[i]);
                }

                Drawer.DrawPolygon(v, _polygonA.Count, color);

                for (var i = 0; i < _polygonB.Count; ++i)
                {
                    v[i] = MathUtils.Mul(_transformB, _polygonB.Vertices[i]);
                }

                Drawer.DrawPolygon(v, _polygonB.Count, color);
            }

            var x1 = output.PointA;
            var x2 = output.PointB;

            var c1 = Color.FromArgb(255, 0, 0);
            Drawer.DrawPoint(x1, 4.0f, c1);

            var c2 = Color.FromArgb(255, 255, 0);
            Drawer.DrawPoint(x2, 4.0f, c2);
        }
コード例 #19
0
ファイル: GeometryUtils.cs プロジェクト: LABSIM/APOLLON
 private static bool TryGetDrawer(out Drawer drawer)
 {
     drawer = Drawer.UnityDebugDrawer;
     return(true);
 }
コード例 #20
0
        static void Main(string[] args)
        {
            //选择是否要保存文件
            Console.WriteLine("请选择您想要的函数模式(输入数字选择模式):");
            Console.WriteLine("*******************************************");
            Console.WriteLine("1--打印控制台输出     2--不打印控制台输出");
            Console.WriteLine("*******************************************");
            int firstChoose = Convert.ToInt32(Console.ReadLine());

            //打印控制台输出
            while (firstChoose == 1)
            {
                Console.WriteLine("请输入创建文件的名称");

                //给变量赋值
                string FirstPath = Console.ReadLine();
                string Path      = FirstPath + ".txt";
                string Content   = DateTime.Now.ToString();
                string AllPath   = Environment.CurrentDirectory + "\\" + Path;

                //创建写入器
                StreamWriter streamWriter = new StreamWriter(AllPath, false);
                //创建对象
                FileController fileController = new FileController();
                //创建文件
                fileController.CreateFile(Path, Content, streamWriter);


                while (true)
                {
                    //建立选择模式
                    //streamWriter.WriteLine("请选择您想要的函数模式(输入数字选择模式):");
                    Console.WriteLine("请选择您想要的函数模式(输入数字选择模式):");
                    Console.WriteLine("*******************************************");
                    Console.WriteLine("1--字符三角形     2--背靠背字符三角形");
                    Console.WriteLine("3--字符菱形       4--交替字符倒三角形");
                    Console.WriteLine("5--输出文件信息   6--保存控制台输出文件");
                    Console.WriteLine("*******************************************");
                    int choose1 = Convert.ToInt32(Console.ReadLine());

                    //字符三角形
                    while (choose1 == 1)
                    {
                        Console.WriteLine("请输入字符三角形的行数和值(每输入一个按Enter以继续):");
                        streamWriter.WriteLine("请输入字符三角形的行数和值(每输入一个按Enter以继续):");
                        try
                        {
                            int line = Convert.ToInt32(Console.ReadLine());
                            streamWriter.WriteLine("行数为" + line);
                            string value = Convert.ToString(Console.ReadLine());
                            streamWriter.WriteLine("字符为" + value);
                            Drawer drawer = new Drawer();
                            drawer.characterTriangle(line, value, streamWriter);
                        }
                        catch (FormatException e)
                        {
                            Console.WriteLine("Exception caught: {0}", e);
                            streamWriter.WriteLine("Exception caught: {0}", e);
                        }
                        Console.ReadKey();
                        break;
                    }

                    //背靠背字符三角形
                    while (choose1 == 2)
                    {
                        try
                        {
                            Console.WriteLine("请输入背靠背字符三角形的行数和值(每输入一个按Enter以继续):");
                            streamWriter.WriteLine("请输入背靠背字符三角形的行数和值(每输入一个按Enter以继续):");
                            int line = Convert.ToInt32(Console.ReadLine());
                            streamWriter.WriteLine("行数为" + line);
                            string value = Convert.ToString(Console.ReadLine());
                            streamWriter.WriteLine("字符为" + value);
                            Drawer drawer = new Drawer();
                            drawer.backCharacterTriangle(line, value, streamWriter);
                        }
                        catch (FormatException e)
                        {
                            Console.WriteLine("Exception caught: {0}", e);
                            streamWriter.WriteLine("Exception caught: {0}", e);
                        }
                        Console.ReadKey();
                        break;
                    }

                    //字符菱形
                    while (choose1 == 3)
                    {
                        try
                        {
                            Console.WriteLine("请输入字符菱形的行数和值(每输入一个按Enter以继续):");
                            streamWriter.WriteLine("请输入字符菱形的行数和值(每输入一个按Enter以继续):");
                            int line = Convert.ToInt32(Console.ReadLine());
                            streamWriter.WriteLine("行数为" + line);
                            string value = Convert.ToString(Console.ReadLine());
                            streamWriter.WriteLine("字符为" + value);
                            Drawer drawer = new Drawer();
                            drawer.characterPrismatic(line, value, streamWriter);
                        }
                        catch (FormatException e)
                        {
                            Console.WriteLine("Exception caught: {0}", e);
                            streamWriter.WriteLine("Exception caught: {0}", e);
                        }
                        Console.ReadKey();
                        break;
                    }

                    //交替字符倒三角行
                    while (choose1 == 4)
                    {
                        try
                        {
                            Console.WriteLine("请输入交替字符倒三角形的行数和值(每输入一个按Enter以继续):");
                            streamWriter.WriteLine("请输入交替字符倒三角形的行数和值(每输入一个按Enter以继续):");
                            int line = Convert.ToInt32(Console.ReadLine());
                            streamWriter.WriteLine("行数为" + line);
                            string value = Convert.ToString(Console.ReadLine());
                            streamWriter.WriteLine("字符为" + value);
                            Drawer drawer = new Drawer();
                            drawer.alternateInvertedTriangle(line, value, streamWriter);
                        }
                        catch (FormatException e)
                        {
                            Console.WriteLine("Exception caught: {0}", e);
                            streamWriter.WriteLine("Exception caught: {0}", e);
                        }
                        Console.ReadKey();
                        break;
                    }

                    //输出文件信息
                    while (choose1 == 5)
                    {
                        //输出创建文件信息
                        fileController.FileMessage(Path, Content, streamWriter);
                        Console.ReadKey();
                        break;
                    }

                    //保存控制台输出信息进入文件
                    while (choose1 == 6)
                    {
                        fileController.WriteFile(Path, streamWriter, AllPath);
                        Console.ReadKey();
                        break;
                    }
                }
            }

            //不打印控制台输出
            while (firstChoose == 2)
            {
                //建立选择模式
                Console.WriteLine("请选择您想要的函数模式(输入数字选择模式):");
                Console.WriteLine("*******************************************");
                Console.WriteLine("1--字符三角形     2--背靠背字符三角形");
                Console.WriteLine("3--字符菱形       4--交替字符倒三角形");
                Console.WriteLine("5--结束程序");
                Console.WriteLine("*******************************************");
                int choose2 = Convert.ToInt32(Console.ReadLine());

                //给变量赋值
                string FirstPath = Console.ReadLine();
                string Path      = FirstPath + ".txt";
                string Content   = DateTime.Now.ToString();
                string AllPath   = Environment.CurrentDirectory + "\\" + Path;

                //创建写入器
                StreamWriter streamWriter = new StreamWriter(AllPath, false);


                //字符三角形
                while (choose2 == 1)
                {
                    Console.WriteLine("请输入字符三角形的行数和值(每输入一个按Enter以继续):");
                    try
                    {
                        int    line   = Convert.ToInt32(Console.ReadLine());
                        string value  = Convert.ToString(Console.ReadLine());
                        Drawer drawer = new Drawer();
                        drawer.characterTriangle(line, value, streamWriter);
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine("Exception caught: {0}", e);
                    }
                    Console.WriteLine("若运行结束,保存文件请按5");
                    Console.ReadKey();
                    break;
                }

                //背靠背字符三角形
                while (choose2 == 2)
                {
                    try
                    {
                        Console.WriteLine("请输入背靠背字符三角形的行数和值(每输入一个按Enter以继续):");
                        int    line   = Convert.ToInt32(Console.ReadLine());
                        string value  = Convert.ToString(Console.ReadLine());
                        Drawer drawer = new Drawer();
                        drawer.backCharacterTriangle(line, value, streamWriter);
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine("Exception caught: {0}", e);
                    }
                    Console.ReadKey();
                    break;
                }

                //字符菱形
                while (choose2 == 3)
                {
                    try
                    {
                        Console.WriteLine("请输入字符菱形的行数和值(每输入一个按Enter以继续):");
                        int    line   = Convert.ToInt32(Console.ReadLine());
                        string value  = Convert.ToString(Console.ReadLine());
                        Drawer drawer = new Drawer();
                        drawer.characterPrismatic(line, value, streamWriter);
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine("Exception caught: {0}", e);
                    }
                    Console.ReadKey();
                    break;
                }

                //交替字符倒三角行
                while (choose2 == 4)
                {
                    try
                    {
                        Console.WriteLine("请输入交替字符倒三角形的行数和值(每输入一个按Enter以继续):");
                        int    line   = Convert.ToInt32(Console.ReadLine());
                        string value  = Convert.ToString(Console.ReadLine());
                        Drawer drawer = new Drawer();
                        drawer.alternateInvertedTriangle(line, value, streamWriter);
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine("Exception caught: {0}", e);
                    }
                    Console.ReadKey();
                    break;
                }

                //结束程序
                while (choose2 == 5)
                {
                    Console.WriteLine("程序将在三秒后退出");
                    System.Threading.Thread.Sleep(3000);
                    Environment.Exit(0);
                }
            }
        }
コード例 #21
0
 public Form1()
 {
     InitializeComponent();
     drawer = new Drawer(pictureBox1);
 }
コード例 #22
0
ファイル: GuitarProperties.cs プロジェクト: fearog/axecalc
        void DrawFretMarker( Drawer d, Line2[] fretLines, int iFretNumber, bool bDouble = false )
        {
            if( fretLines.Length < iFretNumber )
                return;

            Line2 fret1 = fretLines[ iFretNumber - 1 ];
            Line2 fret2 = fretLines[ iFretNumber ];

            Line2 newLine = new Line2( ( fret1.v1 + fret2.v1 ) * 0.5, ( fret1.v2 + fret2.v2 ) * 0.5 );
            if( m_eMarkerStyle == MarkerStyle.Centred )
            {
                if( !bDouble )
                {
                    Vec2 vCentre = newLine.origin + newLine.direction * ( newLine.distance / 2 );
                    d.DrawCircle( "FretMarkers", vCentre, m_dDotRadius );
                }
                else
                {
                    Vec2 vCentre1 = newLine.origin + newLine.direction * ( newLine.distance * 1 / 4 );
                    Vec2 vCentre2 = newLine.origin + newLine.direction * ( newLine.distance * 3 / 4 );
                    d.DrawCircle( "FretMarkers", vCentre1, m_dDotRadius );
                    d.DrawCircle( "FretMarkers", vCentre2, m_dDotRadius );

                }
            }
            else if( m_eMarkerStyle == MarkerStyle.Edge || m_eMarkerStyle == MarkerStyle.OpposingEdges )
            {
                if( m_eMarkerStyle == MarkerStyle.OpposingEdges && iFretNumber > 12 )
                    newLine = new Line2( newLine.v2, newLine.v1 );

                d.DrawCircle( "FretMarkers", newLine.origin + newLine.direction * ( m_dDotEdgeSpacing + m_dDotRadius ), m_dDotRadius );
                if( bDouble )
                {
                    d.DrawCircle( "FretMarkers", newLine.origin + newLine.direction * ( m_dDotEdgeSpacing*2 + m_dDotRadius*3 ), m_dDotRadius );
                }
            }
            else if( m_eMarkerStyle == MarkerStyle.SquareBlocks )
            {

            }
        }
コード例 #23
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

              // Set our view from the "main" layout resource
              SetContentView(Resource.Layout.activity_sample_dark_toolbar);

              var toolbar = this.FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
              this.SetSupportActionBar(toolbar);

              // Create a few sample profile
              // NOTE you have to define the loader logic too. See the CustomApplication for more details

              var profile = new ProfileDrawerItem().WithName("Mike Penz").WithEmail("*****@*****.**").WithIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460");
              var profile2 = new ProfileDrawerItem().WithName("Bernat Borras").WithEmail("*****@*****.**").WithIcon(Uri.Parse("https://avatars3.githubusercontent.com/u/887462?v=3&s=460"));
              var profile3 = new ProfileDrawerItem().WithName("Max Muster").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile2));
              var profile4 = new ProfileDrawerItem().WithName("Felix House").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile3));
              var profile5 = new ProfileDrawerItem().WithName("Mr. X").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile4)).WithIdentifier(4);
              var profile6 = new ProfileDrawerItem().WithName("Batman").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile5));

              headerResult = new AccountHeaderBuilder()
            .WithActivity(this)
            .WithHeaderBackground(Resource.Drawable.header)
            .AddProfiles(
              profile,
              profile2,
              profile3,
              profile4,
              profile5,
              profile6,
              //don't ask but google uses 14dp for the add account icon in gmail but 20dp for the normal icons (like manage account)
              new ProfileSettingDrawerItem().WithName("Add Account").WithDescription("Add new GitHub Account").WithIcon(new IconicsDrawable(this, GoogleMaterial.Icon.GmdAdd)
            .PaddingDp(5).ColorRes(Resource.Color.material_drawer_primary_text)).WithIdentifier(PROFILE_SETTING),
              new ProfileSettingDrawerItem().WithName("Manage Account").WithIcon(GoogleMaterial.Icon.GmdSettings)
            )
            .WithOnAccountHeaderListener(this)
            .WithSavedInstance(savedInstanceState)
            .Build();

              var item1 = new PrimaryDrawerItem();
              item1.WithName(Resource.String.drawer_item_compact_header);
              item1.WithIcon(GoogleMaterial.Icon.GmdWbSunny);
              item1.WithIdentifier(1);
              item1.WithCheckable(false);

              var item2 = new PrimaryDrawerItem();
              item2.WithName(Resource.String.drawer_item_action_bar);
              item2.WithIcon(FontAwesome.Icon.FawHome);
              item2.WithIdentifier(2);
              item2.WithCheckable(false);

              var item3 = new PrimaryDrawerItem();
              item3.WithName(Resource.String.drawer_item_multi_drawer);
              item3.WithIcon(FontAwesome.Icon.FawGamepad);
              item3.WithIdentifier(3);
              item3.WithCheckable(false);

              var item4 = new PrimaryDrawerItem();
              item4.WithName(Resource.String.drawer_item_non_translucent_status_drawer);
              item4.WithIcon(FontAwesome.Icon.FawEye);
              item4.WithIdentifier(4);
              item4.WithCheckable(false);

              var item5 = new PrimaryDrawerItem();
              item5.WithDescription("A more complex sample");
              item5.WithName(Resource.String.drawer_item_complex_header_drawer);
              item5.WithIcon(GoogleMaterial.Icon.GmdAdb);
              item5.WithIdentifier(5);
              item5.WithCheckable(false);

              var item6 = new PrimaryDrawerItem();
              item6.WithName(Resource.String.drawer_item_simple_fragment_drawer);
              item6.WithIcon(GoogleMaterial.Icon.GmdStyle);
              item6.WithIdentifier(6);
              item6.WithCheckable(false);

              var item7 = new PrimaryDrawerItem();
              item7.WithName(Resource.String.drawer_item_embedded_drawer_dualpane);
              item7.WithIcon(GoogleMaterial.Icon.GmdBatteryChargingFull);
              item7.WithIdentifier(7);
              item7.WithCheckable(false);

              var item8 = new PrimaryDrawerItem();
              item8.WithName(Resource.String.drawer_item_fullscreen_drawer);
              item8.WithIcon(GoogleMaterial.Icon.GmdStyle);
              item8.WithIdentifier(8);
              item8.WithCheckable(false);

              var item9 = new PrimaryDrawerItem();
              item9.WithName(Resource.String.drawer_item_custom_container_drawer);
              item9.WithIcon(GoogleMaterial.Icon.GmdMyLocation);
              item9.WithIdentifier(9);
              item9.WithCheckable(false);

              var item10 = new SecondaryDrawerItem();
              item10.WithName(Resource.String.drawer_item_open_source);
              item10.WithIcon(FontAwesome.Icon.FawGithub);
              item10.WithIdentifier(20);
              item10.WithCheckable(false);

              var item11 = new SecondaryDrawerItem();
              item11.WithName(Resource.String.drawer_item_contact);
              item11.WithIcon(GoogleMaterial.Icon.GmdFormatColorFill);
              item11.WithIdentifier(10);
              item11.WithTag("Bullhorn");

              var item12 = new SwitchDrawerItem();
              item12.WithName("Switch");
              item12.WithIcon(Octicons.Icon.OctTools);
              item12.WithChecked(true);
              item12.WithOnCheckedChangeListener(this);

              var item13 = new SwitchDrawerItem();
              item13.WithName("Switch2");
              item13.WithIcon(Octicons.Icon.OctTools);
              item13.WithChecked(true);
              item13.WithOnCheckedChangeListener(this);

              var item14 = new ToggleDrawerItem();
              item14.WithName("Toggle");
              item14.WithIcon(Octicons.Icon.OctTools);
              item14.WithChecked(true);
              item14.WithOnCheckedChangeListener(this);

              result = new DrawerBuilder()
            .WithActivity(this)
            .WithToolbar(toolbar)
            .WithAccountHeader(headerResult) //set the AccountHeader we created earlier for the header
            .AddDrawerItems(
              item1,
              item2,
              item3,
              item4,
              item5,
              item6,
              item7,
              item8,
              item9,
              new SectionDrawerItem().WithName(Resource.String.drawer_item_section_header),
              item10,
              item11,
              new DividerDrawerItem(),
              item12,
              item13,
              item14
            ) // add the items we want to use With our Drawer
            .WithOnDrawerItemClickListener(this)
            .WithSavedInstance(savedInstanceState)
            .WithShowDrawerOnFirstLaunch(true)
            .Build();

              if (savedInstanceState == null) {
            // set the selection to the item with the identifier 10
            result.SetSelectionByIdentifier(10, false);

            //set the active profile
            headerResult.SetActiveProfile(profile3);
              }
        }
コード例 #24
0
ファイル: GuitarProperties.cs プロジェクト: fearog/axecalc
        void DrawPickupBobbin( Drawer d, Line2 centreLine, double dStringSpacing, double dWidth )
        {
            // polepiece positions
            Vec2 vStartSpot = ( centreLine.v1 + centreLine.v2 ) * 0.5 - centreLine.direction * ( m_iStringCount - 1 ) * 0.5 * dStringSpacing;
            Vec2 vEndSpot = vStartSpot + centreLine.direction * dStringSpacing * ( m_iStringCount - 1 );
            Line2 trueCentreLine = new Line2( vStartSpot, vEndSpot );
            for( int i = 0; i < m_iStringCount; ++i )
            {
                Vec2 vSpot = vStartSpot + centreLine.direction * dStringSpacing * i;
                d.DrawCircle( "Pickups", vSpot, 2.5 );
            }

            // outline
            Line2 left = trueCentreLine.offset( dWidth / 2, Vec2.left );
            Line2 right = trueCentreLine.offset( dWidth / 2, Vec2.right );
            //Line2 perpendicular = trueCentreLine.perpendicular( Vec2.right );
            //	perpendicular.v1 = left.v1;
            d.DrawLine( "Pickups", left );
            d.DrawLine( "Pickups", right );

            double dAngle = 180 * left.direction.angleBetween( Vec2.down ) / Math.PI;
            d.DrawArc( "Pickups", trueCentreLine.v1, dWidth / 2, dAngle, 180 + dAngle );
            d.DrawArc( "Pickups", trueCentreLine.v2, dWidth / 2, 180 + dAngle, dAngle );
        }
コード例 #25
0
ファイル: GuitarProperties.cs プロジェクト: fearog/axecalc
 void DrawSaddle( Drawer d, Vec2 vIntonationPoint )
 {
     if( m_currentSaddlePrefab != null )
         d.DrawPrefab( vIntonationPoint, m_currentSaddlePrefab );
 }
コード例 #26
0
        public static void ShowGarmonic(LiveCharts.Wpf.CartesianChart cc, LiveCharts.Wpf.CartesianChart cc2, double[] data, string count = "15")
        {
            int           g    = Convert.ToInt32(count);
            List <double> coef = new List <double>();

            for (int i = 0; i < data.Length; i++)
            {
                coef.Add(data[i]);
            }
            double[] U   = new double[coef.Count];
            double   a01 = 0;

            for (int i = 0; i < coef.Count; i++)
            {
                a01 += Convert.ToDouble(coef[i]);
            }
            a01 /= coef.Count;
            double[] ak1     = new double[coef.Count / 2];
            double[] bk1     = new double[coef.Count / 2];
            int      costilI = 0;
            int      costilJ = 0;

            for (int i = 0; i < ak1.Length; i++)
            {
                costilI++;
                for (int j = 0; j < coef.Count; j++)
                {
                    costilJ++;
                    ak1[i] += coef[j] * Math.Cos(2 * Math.PI * (costilI) * costilJ / coef.Count);
                    bk1[i] += coef[j] * Math.Sin(2 * Math.PI * (costilI) * costilJ / coef.Count);
                }
                ak1[i] *= 2;
                ak1[i] /= coef.Count;
                bk1[i] *= 2;
                bk1[i] /= coef.Count;
            }
            double[,] arr_x = new double[(coef.Count / 2), coef.Count];
            int costilsukaI = 0;
            int costilsukaJ = 0;

            for (int i = 0; i < (coef.Count / 2); i++)
            {
                costilsukaI++;
                for (int j = 0; j < coef.Count; j++)
                {
                    costilsukaJ++;
                    if (costilsukaI < 2)
                    {
                        arr_x[i, j] = a01 + (ak1[1] * Math.Cos(2 * Math.PI * 1 * 1 / coef.Count) + bk1[1] * Math.Sin(2 * Math.PI * 1 * 1 / coef.Count)) /* + + */ + 0;
                    }
                    else
                    {
                        arr_x[i, j] = (ak1[i] * Math.Cos(2 * Math.PI * costilsukaI * costilsukaJ / coef.Count) + bk1[i] * Math.Sin(2 * Math.PI * costilsukaI * costilsukaJ / coef.Count)) /* + + */;
                    }
                }
            }
            double[] values = new double[coef.Count];
            for (int i = 0; i < values.Length; i++)
            {
                for (int c = 0; c < g; c++)
                {
                    try
                    {
                        values[i] += arr_x[c, i];
                    }
                    catch
                    {
                        continue;
                    }
                }
            }
            Drawer pen = new Drawer(cc);

            pen.DrawLinerChart(values, "Сезонная компонента");
            for (int i = 0; i < values.Length; i++)
            {
                values[i] = Math.Abs(values[i] - data[i]);
            }
            Drawer pen2 = new Drawer(cc2);

            pen2.DrawLinerChart(values, "Случайная компонента");
        }
コード例 #27
0
ファイル: GuitarProperties.cs プロジェクト: fearog/axecalc
        //---------------------------------------------------------------------
        public void Draw( Drawer d )
        {
            d.AddLayer( "Scale", Color.FromArgb( 255, 255, 255, 255 ) );
            d.AddLayer( "FretCentres", Color.FromArgb( 255, 0, 192, 192 ) );
            d.AddLayer( "Fretwire", Color.FromArgb( 255, 192, 192, 192 ) );
            d.AddLayer( "StringCenterLines", Color.FromArgb( 255, 255, 255, 255 ) );
            d.AddLayer( "Strings", Color.FromArgb( 255, 255, 255, 255 ) );
            d.AddLayer( "FretBoard", Color.FromArgb( 255, 255, 255, 255 ) );
            d.AddLayer( "Saddles", Color.FromArgb( 255, 255, 255, 0 ) );
            d.AddLayer( "SaddleScrews", Color.FromArgb( 255, 255, 192, 0 ) );

            // find out what strings we need
            double[] stringWidths = new double[ m_iStringCount ];
            double[] stringCompensations = new double[ m_iStringCount ];
            for( int i = 0; i < m_iStringCount; ++i )
            {
                double dResultantTension = 0;
                StringInfo s = GetIdealString( i, ref dResultantTension );
                stringWidths[ i ] = s.m_dDiameter * 25.4;
                stringCompensations[ i ] = GetRequiredCompensation( i, m_dStringHeightAt12th );
            }

            RectangleF extents = RoughExtents;
            double fMaxScale = Math.Max( m_fBassScaleLength, m_fTrebleScaleLength );

            d.SetLimits( extents.Left, extents.Top, extents.Right, extents.Bottom );

            // draw centreline & lines showing the scale points for the two scales
            d.DrawLine( "Scale", -30, 0, fMaxScale + 30, 0 );
            //	d.DrawLine( "Scale", 0, TotalBridgeStringSpacing / 2 + 30, 0, -TotalBridgeStringSpacing / 2 - 30 );
            //	if( m_fBassScaleLength != m_fTrebleScaleLength )
            //		d.DrawLine( "Scale", scaleTrebleOffset, TotalBridgeStringSpacing / 2 + 30, scaleTrebleOffset, -TotalBridgeStringSpacing / 2 - 30 );

            // find fret locations
            Line2[] fretLines = new Line2[ m_iFretCount + 1 ];
            for( int i = 0; i < m_iFretCount + 1; ++i )
            {
                fretLines[ i ] = GetFretLine( i );
            }
            /*
            # do constant-spacing based string spacing, to take each string's thickness into account
            #spacingLeft = TotalNutStringSpacing + stringWidths[ 0 ] / 2 + stringWidths[ stringCount - 1 ] / 2
            #for i in range( stringCount ):
            #    spacingLeft -= stringWidths[ i ]
            #spacingBetweenStrings = spacingLeft / ( stringCount - 1.0 )

            #positionUpto = 0
            #stringPositions = list()
            #for i in range( stringCount ):
            #    stringPositions.append( positionUpto / TotalNutStringSpacing )
            #    print( "string %i nut position %.3f" % (i, positionUpto ))
            #    if( i != stringCount - 1 ):
            #        positionUpto += stringWidths[ i ] / 2
            #        positionUpto += spacingBetweenStrings
            #        positionUpto += stringWidths[ i + 1 ] / 2
            */

            // properly figure out the fretboard outlines, taking into account zero fret, etc etc etc...
            Line2 zeroFretLine = new Line2( fretLines[ 0 ] );
            Line2 nutLineLeft;
            if( !m_bZeroFret )
                nutLineLeft = zeroFretLine;
            else
                nutLineLeft = zeroFretLine.offset( m_dZeroFretNutOffset, Vec2.right );
            Line2 nutLineRight = nutLineLeft.offset( m_dNutWidth, Vec2.right );
            Line2 fbEndLine = new Line2( fretLines[ m_iFretCount ] );
            Line2 fret12Line = fretLines[ 12 ];

            Vec2 bassLine0 = new Vec2( 0, 0 );
            Vec2 bassLine12th = new Vec2( 0, 0 );
            zeroFretLine.intersectInfinite( new Line2( 0, FretboardWidthAtNut / 2, 100, FretboardWidthAtNut / 2 ), ref bassLine0 );
            fretLines[ 12 ].intersectInfinite( new Line2( 0, FretboardWidthAt12th / 2, 100, FretboardWidthAt12th / 2 ), ref bassLine12th );

            Line2 fbBassLine = new Line2( bassLine0, bassLine12th ); //new Line2( //stringTopEdges[ 0 ].offset( edgeOfFretboardSpacing, Vec2.up );
            Line2 fbTrebleLine = fbBassLine.mirror( new Line2( 0, 0, 1, 0 ) ); //stringBottomEdges[ m_iStringCount - 1 ].offset( edgeOfFretboardSpacing, Vec2.down );
            fbEndLine.v1.x -= 8;
            fbEndLine.v2.x -= 8;
            nutLineLeft.trimToInfinite( fbBassLine, Vec2.down );
            nutLineLeft.trimToInfinite( fbTrebleLine, Vec2.up );
            nutLineRight.trimToInfinite( fbBassLine, Vec2.down );
            nutLineRight.trimToInfinite( fbTrebleLine, Vec2.up );
            fbEndLine.trimToInfinite( fbBassLine, Vec2.down );
            fbEndLine.trimToInfinite( fbTrebleLine, Vec2.up );
            fbBassLine.trimToInfinite( fbEndLine, Vec2.right );
            fbBassLine.trimToInfinite( nutLineRight, Vec2.left );
            fbTrebleLine.trimToInfinite( fbEndLine, Vec2.right );
            fbTrebleLine.trimToInfinite( nutLineRight, Vec2.left );

            // draw fretboard
            d.DrawLine( "FretBoard", nutLineLeft );
            d.DrawLine( "FretBoard", nutLineRight );
            d.DrawLine( "FretBoard", fbEndLine );
            d.DrawLine( "FretBoard", fbBassLine );
            d.DrawLine( "FretBoard", fbEndLine );
            d.DrawLine( "FretBoard", fbTrebleLine );

            // draw frets
            for( int i = 0; i <= m_iFretCount; ++i )
            {
                if( i == 0 && !m_bZeroFret )
                    continue;

                Line2 fret = fretLines[ i ];
                fret.extendToInfinite( fbBassLine );
                fret.extendToInfinite( fbTrebleLine );
                d.DrawLine( "FretCentres", fret );

                // fretwire
                Line2 fretRight = fret.offset( m_dFretwireWidth / 2, Vec2.right );
                fretRight.trimToInfinite( fbBassLine, Vec2.down );
                fretRight.trimToInfinite( fbTrebleLine, Vec2.up );
                d.DrawLine( "Fretwire", fretRight );
                Line2 fretLeft = fret.offset( m_dFretwireWidth / 2, Vec2.left );
                fretLeft.trimToInfinite( fbBassLine, Vec2.down );
                fretLeft.trimToInfinite( fbTrebleLine, Vec2.up );
                d.DrawLine( "Fretwire", fretLeft );

                // put a little ellipse at the end to make it purty
                //d.DrawEllipseArc( "Fretwire", fretLeft.v2, fretRight.v2, 0.5, fretLeft.v2, fretRight.v2 );
            }

            // draw strings
            Line2[] stringLines = new Line2[ m_iStringCount ];
            Vec2[] saddleSpots = new Vec2[ m_iStringCount ];
            double dMaxSaddleX = -10000000.0f;
            double dMinSaddleX = 10000000.0f;

            for( int i = 0; i < m_iStringCount; ++i )
            {
                stringLines[ i ] = GetStringLine( i );
                stringLines[ i ].trimToInfinite( nutLineRight, Vec2.left );

                // calculate the estimated string intonation point
                saddleSpots[ i ] = stringLines[ i ].v1 + stringLines[ i ].direction * -stringCompensations[ i ];
                saddleSpots[ i ].y = stringLines[ i ].v1.y;
                dMaxSaddleX = Math.Max( dMaxSaddleX, saddleSpots[ i ].x );
                dMinSaddleX = Math.Min( dMinSaddleX, saddleSpots[ i ].x );

                // extend the string out to the saddle
                Line2 saddleLine = new Line2( saddleSpots[ i ].x, saddleSpots[ i ].y + 5.0f, saddleSpots[ i ].x, saddleSpots[ i ].y - 5.0f );
                stringLines[ i ].extendToInfinite( saddleLine );

                Line2 topEdge = stringLines[ i ].offset( stringWidths[ i ] / 2.0, Vec2.up );
                Line2 bottomEdge = stringLines[ i ].offset( stringWidths[ i ] / 2.0, Vec2.down );
                topEdge.trimToInfinite( nutLineRight, Vec2.left );
                bottomEdge.trimToInfinite( nutLineRight, Vec2.left );
                d.DrawLine( "StringCenterLines", stringLines[ i ] );
                d.DrawLine( "Strings", topEdge );
                d.DrawLine( "Strings", bottomEdge );

                //d.DrawLine( "Saddles", saddleLine );
            }

            // figure out where the saddle screw should go, based on its max adjustment
            //double dMaxSaddleAdjustment = 8.5;
            //double dAdjustmentRangeNeeded = dMaxSaddleX - dMinSaddleX;
            // DrawSaddleScrew will draw at the centre of the adjustment, so figure out an X that keeps everything close to the middle range

            // draw saddles & saddle screws
            for( int i = 0; i < m_iStringCount; ++i )
            {
                DrawSaddle( d, saddleSpots[ i ] );

                // draw min & max compensation points
                Vec2 minSaddleSpot = GetStringLine( i ).v1 + GetStringLine( i ).direction * -GetRequiredCompensation( i, m_dMinStringHeightAt12th );
                minSaddleSpot.y = saddleSpots[ i ].y;
                Vec2 maxSaddleSpot = GetStringLine( i ).v1 + GetStringLine( i ).direction * -GetRequiredCompensation( i, m_dMaxStringHeightAt12th );
                maxSaddleSpot.y = saddleSpots[ i ].y;

                //DrawSaddle( d, minSaddleSpot );
                //DrawSaddle( d, maxSaddleSpot );

                if( m_fBassScaleLength == m_fTrebleScaleLength )
                {
                    Vec2 screwSpot = new Vec2( saddleSpots[ i ].x, saddleSpots[ i ].y );
                    screwSpot.x = ( dMinSaddleX + dMaxSaddleX ) * 0.5;
                    DrawSaddleScrew( d, screwSpot );
                }
                else
                {
                    DrawSaddleScrew( d, saddleSpots[ i ] );
                }
            }

            d.AddLayer( "FretMarkers", Color.FromArgb( 255, 255, 255, 255 ) );
            //d.DrawCircle( "FretMarkers", new Vec2( 0, 0 ), 4 );
            DrawFretMarker( d, fretLines, 3 );
            DrawFretMarker( d, fretLines, 5 );
            DrawFretMarker( d, fretLines, 7 );
            DrawFretMarker( d, fretLines, 9 );
            DrawFretMarker( d, fretLines, 12, true );
            DrawFretMarker( d, fretLines, 15 );
            DrawFretMarker( d, fretLines, 17 );
            DrawFretMarker( d, fretLines, 19 );
            DrawFretMarker( d, fretLines, 21 );
            DrawFretMarker( d, fretLines, 24, true );

            // draw pickup positions
            DrawPickup( d, m_bridgePickup );
            DrawPickup( d, m_middlePickup );
            DrawPickup( d, m_neckPickup );

            /*			# draw some comparison pickup positions
            fStratNeckPos = 6.375 / 25.5
            fStratMiddlePos = 3.875 / 25.5
            fStratBridgePos = 1.625 / 25.5
            fStratBridgeBassPos = 1.815 / 25.5
            fStratBridgeTreblePos = 1.435 / 25.5
            fJBNeckPos = 6 / 34.0
            fJBBridgePos = 2.13 / 34.0
            fPRSNeckPos = 148 / 635.0
            fPRSBridgePos = 43 / 635.0

            fNewNeckPos1 = interpolate( 1/3.0, fJBNeckPos, fPRSNeckPos )
            fNewNeckPos2 = interpolate( 2/3.0, fJBNeckPos, fPRSNeckPos )

            writeScalePos( f, fStratNeckPos, "StratPickups", bridgeStringLine, nutStringLine )
            writeScalePos( f, fStratMiddlePos, "StratPickups", bridgeStringLine, nutStringLine )
            writeAngledScalePos( f, fStratBridgeBassPos, fStratBridgeTreblePos, "StratPickups", bridgeStringLine, nutStringLine )
            writeScalePos( f, fJBNeckPos, "JBPickups", bridgeStringLine, nutStringLine )
            writeScalePos( f, fJBBridgePos, "JBPickups", bridgeStringLine, nutStringLine )
            writeScalePos( f, fPRSNeckPos, "PRSPickups", bridgeStringLine, nutStringLine )
            writeScalePos( f, fPRSBridgePos, "PRSPickups", bridgeStringLine, nutStringLine )
            writeScalePos( f, fNewNeckPos1, "TristanPickups", bridgeStringLine, nutStringLine )
            writeScalePos( f, fNewNeckPos2, "TristanPickups", bridgeStringLine, nutStringLine )
            */
        }
コード例 #28
0
        void OnGUI()
        {
            if (position.width != oldPosition.width && Event.current.type == EventType.Layout)
            {
                drawers     = null;
                oldPosition = position;
            }

            using (new GUILayout.HorizontalScope()) {
                if (GUILayout.Toggle(tab == Tab.Styles, "Styles", GUI.skin.FindStyle("Tab first")) && tab != Tab.Styles)
                {
                    tab     = Tab.Styles;
                    drawers = null;
                }

                if (GUILayout.Toggle(tab == Tab.Textures, "Textures", GUI.skin.FindStyle("Tab last")) && tab != Tab.Textures)
                {
                    tab      = Tab.Textures;
                    textures = null;
                    drawers  = null;
                }
            }


            string newSearch = GUILayout.TextField(search);

            if (newSearch != search)
            {
                search  = newSearch;
                drawers = null;
            }


            if (drawers == null)
            {
                drawers = new List <Drawer>();

                var nameStyle = GUI.skin.FindStyle("MiniToolbarButton");

                var normalText = new GUIContent("normal");
                var activeText = new GUIContent("active");

                float x = PADDING_X;
                float y = PADDING_Y;

                float maxHeight = 0;

                string searchLow = search.ToLower();


                switch (tab)
                {
                case Tab.Styles:

                    foreach (GUIStyle style in GUI.skin.customStyles)
                    {
                        if (searchLow != "" && !style.name.ToLower().Contains(searchLow))
                        {
                            continue;
                        }

                        var drawer = new Drawer();

                        var size = style.CalcSize(normalText);
                        if (size.x < 8)
                        {
                            size.x = 80;
                        }
                        if (size.y < 8)
                        {
                            size.y = 40;
                        }

                        var nameSize = nameStyle.CalcSize(new GUIContent(style.name));

                        var width = Mathf.Max(
                            nameSize.x,
                            size.x * 2
                            ) + 16;

                        var height = nameSize.y + size.y + PADDING_X * 2;

                        if (x + width > position.width - SCROLL_W - PADDING_X && x > PADDING_X)
                        {
                            x         = PADDING_X;
                            y        += maxHeight + PADDING_Y * 2;
                            maxHeight = height;
                        }

                        maxHeight = Mathf.Max(maxHeight, height);

                        drawer.rect = new Rect(x, y, width, height);

                        drawer.draw = () => {
                            EditorGUILayout.SelectableLabel(style.name, nameStyle, GUILayout.Height(16));

                            using (new GUILayout.HorizontalScope()) {
                                drawer.active =
                                    GUILayout.Toggle(drawer.active, normalText, style, GUILayout.Width(width / 2));
                                GUILayout.Toggle(true, activeText, style, GUILayout.Width(width / 2));
                            }
                        };

                        x += width + PADDING_X * 2;

                        drawers.Add(drawer);
                    }

                    break;


                case Tab.Textures:

                    if (textures == null)
                    {
                        textures = Resources.FindObjectsOfTypeAll <Texture2D>().ToList();
                        textures.Sort((a, b) => System.String.Compare(a.name, b.name, System.StringComparison.OrdinalIgnoreCase));
                    }

                    foreach (var texture in textures)
                    {
                        if (FILTER_TEXTURE_NAMES.Contains(texture.name))
                        {
                            continue;
                        }
                        if (searchLow != "" && !texture.name.ToLower().Contains(searchLow))
                        {
                            continue;
                        }

                        var drawer = new Drawer();

                        var buttonSize = GUI.skin.button.CalcSize(new GUIContent(texture.name));

                        var width = Mathf.Max(
                            buttonSize.x,
                            texture.width
                            ) + 8;

                        var height = buttonSize.y + texture.height + 4;


                        if (x + width > position.width - SCROLL_W - PADDING_X && x > PADDING_X)
                        {
                            x         = PADDING_X;
                            y        += maxHeight + PADDING_Y * 2;
                            maxHeight = height;
                        }

                        maxHeight = Mathf.Max(maxHeight, height);

                        drawer.rect = new Rect(x, y, width, height);

                        drawer.draw = () => {
                            EditorGUILayout.SelectableLabel(texture.name, nameStyle, GUILayout.Height(16));

                            var clampW = Mathf.Min(texture.width, position.width - 16);
                            var clampH = Mathf.Min(texture.height, position.height - 16);

                            Rect textureRect = GUILayoutUtility.GetRect(
                                texture.width, texture.width, texture.height, texture.height,
                                GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false)
                                );

                            textureRect.x += 4;
                            textureRect.y += 3;

                            EditorGUI.DrawTextureTransparent(textureRect, texture);
                        };

                        x += width + PADDING_X * 2;

                        drawers.Add(drawer);
                    }

                    break;
                }

                maxY = y;
            }

            float top = EditorGUIUtility.singleLineHeight * 2 - 1;

            var scrollRect = new Rect(
                x: position.width - SCROLL_W,
                y: top,
                width: SCROLL_W,
                height: position.height - top
                );

            float contentHeight = position.height - top;                                                                        // 696

            scrollVal = GUI.VerticalScrollbar(scrollRect, scrollVal, contentHeight, 0, Mathf.Max(position.height - top, maxY)); // 585

            var area = new Rect(0, top, position.width - 16, contentHeight);

            using (new GUILayout.AreaScope(area)) {
                foreach (var drawing in drawers)
                {
                    var clampRect = drawing.rect;
                    clampRect.y -= scrollVal;

                    if (clampRect.y + clampRect.height > 0 && clampRect.y < contentHeight)
                    {
                        using (new GUILayout.AreaScope(clampRect, "", GUI.skin.FindStyle("grey_border"))) {
                            drawing.draw();
                        }
                    }
                }
            }
        }
コード例 #29
0
ファイル: GuitarProperties.cs プロジェクト: fearog/axecalc
        void DrawPickup( Drawer d, PickupSettings p )
        {
            if( p.m_eType == PickupTypes.None )
                return;

            d.AddLayer( "PickupCentres", Color.FromArgb( 255, 128, 128 ) );
            d.AddLayer( "Pickups", Color.FromArgb( 255, 255, 255 ) );

            // centreline
            Line2 centreLine = GetCrossFretboardLine( p.m_dPosition );
            d.DrawLine( "PickupCentres", centreLine );

            if( p.m_eType == PickupTypes.Singlecoil )
            {
                DrawPickupBobbin( d, centreLine, p.m_dPerPoleStringSpacing, p.m_dBobbinWidth );
            }
            else if( p.m_eType == PickupTypes.Humbucker )
            {
                Line2 leftLine = centreLine.offset( p.m_dBobbinWidth / 2, Vec2.left );
                Line2 rightLine = centreLine.offset( p.m_dBobbinWidth / 2, Vec2.right );
                leftLine.trimToInfinite( bassStringLine, Vec2.down );
                leftLine.trimToInfinite( trebleStringLine, Vec2.up );
                rightLine.trimToInfinite( bassStringLine, Vec2.down );
                rightLine.trimToInfinite( trebleStringLine, Vec2.up );
                DrawPickupBobbin( d, leftLine, p.m_dPerPoleStringSpacing, p.m_dBobbinWidth );
                DrawPickupBobbin( d, rightLine, p.m_dPerPoleStringSpacing, p.m_dBobbinWidth );
            }
        }
コード例 #30
0
        public void UpdateGraphic()
        {
            if (Drawer?.pawn == null)
            {
                Graphic = null;
                return;
            }
            if (apparel.Wearer == null)
            {
                if (Drawer != null)
                {
                    Drawer.pawn = null;
                }
                Graphic = null;
                return;
            }
            if (Drawer.pawn != apparel.Wearer)
            {
                //    Log.Message("Old Wearer: "+ Drawer.pawn + "new Wearer: "+ apparel.Wearer);
                Drawer.pawn = apparel.Wearer;
            }
            Pawn   pawn   = Drawer.pawn;
            Shader shader = this.Shader;
            string path   = padTexPath;

            if (UseFactionTextures || UseVariableTextures)
            {
                bool notPlayer = pawn.Faction != null && (pawn.Faction != Faction.OfPlayer);
                if (notPlayer)
                {
                    FactionDefExtension ext = pawn.Faction.def.HasModExtension <FactionDefExtension>() ? pawn.Faction.def.GetModExtensionFast <FactionDefExtension>() : null;
                    bool factionTextures    = UseFactionTextures && ext?.factionTextureTag != null;
                    if (factionTextures)
                    {
                        //    Log.Message("using factionTextureTag " + ext.factionTextureTag);
                        for (int i = 0; i < Options.Count; i++)
                        {
                            if (Options[i].TexPath == ext.factionTextureTag)
                            {
                                Used = Options[i];
                                //    Log.Message("Found faction VariantTexture " + VariantTextures.Options[i].texPath);
                                break;
                            }
                        }
                    }
                    else
                    {
                        bool foundVar = false;
                        if (!Options.NullOrEmpty())
                        {
                            for (int i = 0; i < Options.Count; i++)
                            {
                                if (pawn.kindDef.apparelTags.Contains(Options[i].TexPath))
                                {
                                    Used     = Options[i];
                                    foundVar = true;
                                    //    Log.Message("Found KindDef VariantTexture " + VariantTextures.Options[i].texPath);
                                    break;
                                }
                            }
                            if (!foundVar)
                            {
                                Used = Options.RandomElement();
                            }
                        }
                    }
                }
                else
                {
                    if (UseFactionTextures)
                    {
                        //    Log.Message("UseFactionTextures");
                        //    CompColorableTwoFaction FC = Drawer.Colours as CompColorableTwoFaction;
                        if (Drawer.Colours is CompColorableTwoFaction FC)
                        {
                            //    Log.Message("FC != null");
                            if (FC.FactionDef != null)
                            {
                                //    //    Log.Message("FactionDef = " + FC.FactionDef.LabelCap);
                                FactionDefExtension e = FC.Extension;
                                if (e != null)
                                {
                                    //   Log.Message("FactionDefExtension != null");
                                    if (!Options.NullOrEmpty())
                                    {
                                        //    Log.Message("Options: " + Options.Count);
                                        for (int i = 0; i < Options.Count; i++)
                                        {
                                            //    Log.Message("checking " + e.factionTextureTag + " Vs " + Options[i].TexPath + " = " + (Options[i].TexPath == e.factionTextureTag));
                                            if (Options[i].TexPath == e.factionTextureTag)
                                            {
                                                Used = Options[i];
                                                //    //    Log.Message("Found faction VariantTexture " + Options[i].TexPath);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            //    Log.Message("FC == null");
                            List <FactionDef> factions = DefDatabase <FactionDef> .AllDefsListForReading;
                            //    Log.Message("UpdateGraphic() 4 1 B 1 1 B 2 factions: "+ factions.Count);
                            for (int i = 0; i < factions.Count; i++)
                            {
                                //    Log.Message("UpdateGraphic() 4 1 B 1 1 B 2 faction: " + i);
                                FactionDef f = factions[i];

                                //    Log.Message("UpdateGraphic() 4 1 B 1 1 B 2 faction: " + f);
                                FactionDefExtension e = f.HasModExtension <FactionDefExtension>() ? f.GetModExtensionFast <FactionDefExtension>() : null;
                                //    Log.Message("UpdateGraphic() 4 1 B 1 1 B 2 faction: " + (e == null));
                                if (e == null)
                                {
                                    //    Log.Message("e == null");
                                    continue;
                                }
                                if (e.factionTextureTag.NullOrEmpty())
                                {
                                    //    Log.Message("factionTextureTag == null");
                                    continue;
                                }

                                if (!Options.NullOrEmpty())
                                {
                                    //    Log.Message("UpdateGraphic() 4 1 B 1 1 A 1 1 1");
                                    //    Log.Message("Options: " + Options.Count);
                                    for (int ii = 0; ii < Options.Count; ii++)
                                    {
                                        //    Log.Message("checking " + e.factionTextureTag + " Vs " + Options[i].TexPath + " = " + (Options[i].TexPath == e.factionTextureTag));
                                        if (Options[ii].TexPath == e.factionTextureTag)
                                        {
                                            faction = f;
                                            //    //    Log.Message("Found faction VariantTexture " + Options[i].TexPath);
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                path = padTexPath + "/" + Used.TexPath;
            }

            string body    = bodyTypeString(pawn.story.bodyType);
            string testRot = "_";

            if (CheckPauldronRotation(Rot4.South))
            {
                testRot += "south";
            }
            else
            if (CheckPauldronRotation(Rot4.North))
            {
                testRot += "north";
            }
            else
            if (CheckPauldronRotation(Rot4.East))
            {
                testRot += "east";
            }
            else
            if (CheckPauldronRotation(Rot4.West))
            {
                testRot += "west";
            }
            else
            {
                testRot = "";
            }
            string    testpath = path + body + testRot;
            Texture2D tex      = ContentFinder <Texture2D> .Get(testpath, false);

            Graphic graphic;

            if (tex == null)
            {
                this.UpdateProps();
                path = padTexPath;
                if (UseFactionTextures || UseVariableTextures)
                {
                    path = padTexPath + "/" + this.DefaultOption.TexPath;
                }
            }
            path += body;
            Color color    = Drawer.mainColorFor(this);
            Color colorTwo = Drawer.secondaryColorFor(this);

            graphic = GraphicDatabase.Get <Graphic_Multi>(path, shader, size, color, colorTwo);
            if (Drawer.Colours is CompColorableTwoFaction factionColors)
            {
                Texture texture;
                if (factionColors.ActiveFaction)
                {
                    if (!factionColors.Extension.factionMaskTag.NullOrEmpty())
                    {
                        string msk = "m_" + factionColors.Extension.factionMaskTag;
                        texture = ContentFinder <Texture2D> .Get(graphic.path + "_east" + msk, false);

                        if (texture != null)
                        {
                            graphic.MatEast.SetTexture(ShaderPropertyIDs.MaskTex, texture);
                        }
                        graphic.MatEast.SetColor(ShaderPropertyIDs.ColorTwo, colorTwo);

                        texture = ContentFinder <Texture2D> .Get(graphic.path + "_west" + msk, false);

                        if (texture != null)
                        {
                            graphic.MatWest.SetTexture(ShaderPropertyIDs.MaskTex, texture);
                        }
                        graphic.MatWest.SetColor(ShaderPropertyIDs.ColorTwo, colorTwo);

                        texture = ContentFinder <Texture2D> .Get(graphic.path + "_south" + msk, false);

                        if (texture != null)
                        {
                            graphic.MatSouth.SetTexture(ShaderPropertyIDs.MaskTex, texture);
                        }
                        graphic.MatSouth.SetColor(ShaderPropertyIDs.ColorTwo, colorTwo);

                        texture = ContentFinder <Texture2D> .Get(graphic.path + "_north" + msk, false);

                        if (texture != null)
                        {
                            graphic.MatNorth.SetTexture(ShaderPropertyIDs.MaskTex, texture);
                        }
                        graphic.MatNorth.SetColor(ShaderPropertyIDs.ColorTwo, colorTwo);
                    }
                }
            }
            //    Log.Message(this.Label + " " + graphic.path + " Shader: " + graphic.Shader.name + "Colour: " + graphic.Color + " Colour: " + graphic.ColorTwo);

            /*
             * if (!this.Drawer.apparel.def.apparel.wornGraphicPath.NullOrEmpty())
             * {
             *  SetApparelColours();
             * }
             */
            Graphic = graphic;
        }
コード例 #31
0
ファイル: Hangman.cs プロジェクト: K-Pavlov/Telerik
    static void Main(string[] args)
    {
        //Class instances
        InfoGiver infoGive = new InfoGiver();
        Checker check = new Checker();
        Drawer draw = new Drawer();

        //Dynamic arrays cuz i'm cool
        List<char> usedLetters = new List<char>();
        List<char> letter = new List<char>();

        //5 lives is good ?
        int lives = 5;
        string word;
        //Games starts and runs while the user wants
        infoGive.giveUserInfo();
        while(true)
        {
            Console.WriteLine(
                "If you quit press Q if you wanna play press any other key!");

            ConsoleKeyInfo key = Console.ReadKey();
            Console.WriteLine();
            if (key.KeyChar == 'Q' || key.KeyChar == 'q')
            {
                Console.Clear();
                Console.WriteLine("Exiting the game");
                Thread.Sleep(1000);
                break;
            }
            else
            {
                Console.Clear();
                letter.Clear();
                usedLetters.Clear();

                lives = 5;

                word = infoGive.generateWords();
                letter.AddRange(draw.splitLetter(word));
                infoGive.giveWordExplanation(word);

                while (lives != 0)
                {
                    Console.Clear();
                    infoGive.giveWordExplanation(word);
                    draw.writeLives(lives);
                    Console.WriteLine(
                        "Give me a letter");
                    draw.drawUnderscores(usedLetters, letter);
                    if(!(usedLetters.Count == 0))
                    {
                    check.checkIfRightGuess(letter);
                    }
                    while (true)
                    {
                        if (check.checkInput(ref usedLetters) == true)
                        {
                            break;
                        }
                    }

                    if (!check.checkIfRightGuess(letter))
                    {
                        lives--;
                    }

                    if (check.checkIfWordIsGuessed(usedLetters, letter))
                    {
                        Console.Clear();
                        draw.drawUnderscores(usedLetters, letter);
                        Console.WriteLine(
                            "And you have guessed the word!");
                        break;
                    }

                    if (lives == 0)
                    {
                        draw.writeLives(lives);
                        Console.WriteLine(
                            "Sorry endgame");
                    }

                }
                Console.WriteLine();
            }
        }
    }
コード例 #32
0
ファイル: UserConsole.cs プロジェクト: ItsToms/DeadlyText
 public void Render(Drawer drawer)
 {
     drawer.Draw("Game Time: " + gametime, Color.White, new Position(0, 0));
     drawer.Draw("Console: " + input, Color.White, new Position(0, 24));
 }
コード例 #33
0
 public void OnMouseUp(Drawer drawer, MouseEvent mouseEvent)
 {
     Container.Resolve <IRepository>().Commit();
 }
コード例 #34
0
 /// <summary>
 /// Open the Drawer
 /// </summary>
 /// <param name="node"></param>
 private void OpenDrawer(ListNode node, Drawer type)
 {
     IsOpen     = true;
     NodeData   = node;
     DrawerType = type;
 }
コード例 #35
0
		static FlowProjectWindowObject() {

			FlowProjectWindowObject.drawer = new Drawer();
			EditorApplication.projectWindowItemOnGUI += FlowProjectWindowObject.drawer.OnProjectItemGUI;

		}
コード例 #36
0
ファイル: Camera.cs プロジェクト: yoship1639/MikuMikuWorld
        protected internal virtual void Draw(double deltaTime)
        {
            var objects     = MMW.FindGameObjects(o => true);
            var drawMeshDic = new Dictionary <Shader, Dictionary <Material, List <SubMeshData> > >();

            var animList  = new List <AAnimator>();
            var morphList = new List <AMorpher>();

            var clipDic  = new Dictionary <GameObject, bool>();
            var clipTask = Task.Factory.StartNew(() =>
            {
                foreach (var obj in objects)
                {
                    var mr = obj.GetComponent <MeshRenderer>();
                    if (mr == null || !mr.Enabled)
                    {
                        clipDic.Add(obj, true);
                        continue;
                    }

                    var clip = false;
                    var b    = mr.Mesh.Bounds;

                    var mvp = obj.Transform.WorldTransform * ViewProjection;
                    var min = new Vector4(b.Min, 1.0f) * mvp;
                    var max = new Vector4(b.Max, 1.0f) * mvp;
                    min    /= min.W;
                    max    /= max.W;

                    if (min.X < -1.2f && max.X < -1.2f)
                    {
                        clip = true;
                    }
                    if (min.X > 1.2f && max.X > 1.2f)
                    {
                        clip = true;
                    }
                    if (min.Y < -1.2f && max.Y < -1.2f)
                    {
                        clip = true;
                    }
                    if (min.Y > 1.2f && max.Y > 1.2f)
                    {
                        clip = true;
                    }
                    if (min.Z < -1.2f && max.Z < -1.2f)
                    {
                        clip = true;
                    }
                    if (min.Z > 1.2f && max.Z > 1.2f)
                    {
                        clip = true;
                    }

                    clipDic.Add(obj, clip);
                }
            });

            var animTasks    = new List <Task>();
            var findAnimTask = Task.Factory.StartNew(() =>
            {
                clipTask.Wait();
                foreach (var obj in objects)
                {
                    if (!obj.Enabled)
                    {
                        continue;
                    }
                    if (clipDic[obj])
                    {
                        continue;
                    }

                    var animator = obj.GetComponent <AAnimator>();
                    var morpher  = obj.GetComponent <AMorpher>();

                    if (animator != null && animator.Enabled)
                    {
                        animTasks.Add(Task.Run(() => animator.CalcTransform()));
                        animList.Add(animator);
                    }

                    if (morpher != null && morpher.Enabled)
                    {
                        animTasks.Add(Task.Run(() => morpher.CalcMorph()));
                        morphList.Add(morpher);
                    }
                }
            });

            if (MeshDraw)
            {
                Matrix4 proj;
                if (Orthographic)
                {
                    proj = Matrix4.CreateOrthographic(TargetTexture.Size.Width, TargetTexture.Size.Height, Near, Far);
                }
                proj = Matrix4.CreatePerspectiveFieldOfView(FoV, Aspect, Near, Far);

                sp.pointLights = null;
                sp.spotLights  = null;
                sp.camera      = this;
                sp.resolution  = new Vector2(TargetTexture.Size.Width, TargetTexture.Size.Height);
                sp.deltaTime   = deltaTime;
                sp.oldViewProj = sp.viewProj;
                sp.view        = View;
                sp.proj        = proj;
                sp.cameraPos   = GameObject.Transform.WorldPosition;
                sp.cameraDir   = WorldDirection;
                sp.dirLight    = MMW.DirectionalLight;
                var viewproj = sp.view * sp.proj;
                sp.viewProj        = viewproj;
                sp.viewInverse     = sp.view.Inverted();
                sp.projInverse     = sp.proj.Inverted();
                sp.viewProjInverse = sp.viewProj.Inverted();
                sp.environmentMap  = EnvironmentMap;

                // 描画準備
                clipTask.Wait();
                foreach (var obj in objects)
                {
                    if (!obj.Enabled)
                    {
                        continue;
                    }
                    if (clipDic[obj])
                    {
                        continue;
                    }

                    var renderers = obj.GetComponents <MeshRenderer>();
                    var animator  = obj.GetComponent <AAnimator>();
                    var morpher   = obj.GetComponent <AMorpher>();

                    var world    = obj.Transform.WorldTransform;
                    var oldWorld = obj.Transform.OldWorldTransfom;
                    foreach (var r in renderers)
                    {
                        if (!r.Enabled)
                        {
                            continue;
                        }
                        for (var i = 0; i < r.MaterialCount; i++)
                        {
                            var mat = r.GetMaterialAt(i);
                            if (!drawMeshDic.ContainsKey(mat.Shader))
                            {
                                drawMeshDic.Add(mat.Shader, new Dictionary <Material, List <SubMeshData> >());
                            }
                            if (!drawMeshDic[mat.Shader].ContainsKey(mat))
                            {
                                drawMeshDic[mat.Shader].Add(mat, new List <SubMeshData>());
                            }
                        }
                        foreach (var sm in r.Mesh.subMeshes)
                        {
                            var mat = r.GetMaterial(sm.materialIndex);
                            var smd = new SubMeshData()
                            {
                                SubMesh           = sm,
                                WorldTransform    = world,
                                OldWorldTransform = oldWorld,
                                Visible           = r.Visible,
                                CastShadow        = r.CastShadow,
                                GameObject        = obj,
                                Morpher           = morpher,
                                Animator          = animator,
                            };
                            drawMeshDic[mat.Shader][mat].Add(smd);
                        }
                    }
                }

                findAnimTask.Wait();
                foreach (var task in animTasks)
                {
                    task.Wait();
                }

                foreach (var a in animList)
                {
                    a.UpdateData();
                }
                foreach (var m in morphList)
                {
                    m.UpdateData();
                }

                // DoF,SSAO,MotionBlurを使う場合は深度マップを書き込む
                var dof        = GameObject.GetComponent <BokehDoF>();
                var ssao       = GameObject.GetComponent <SSAO>();
                var motionBlur = GameObject.GetComponent <MotionBlur>();
                if ((dof != null && dof.Enabled) || (ssao != null && ssao.Enabled) || (motionBlur != null && motionBlur.Enabled))
                {
                    RenderToDepthMap(depthRT, sp, drawMeshDic);
                    if (dof != null && dof.Enabled)
                    {
                        dof.DepthMap = depthRT.ColorDst0;
                    }
                    if (ssao != null && ssao.Enabled)
                    {
                        ssao.DepthMap = depthRT.ColorDst0;
                    }
                    if (motionBlur != null && motionBlur.Enabled)
                    {
                        motionBlur.DepthMap = depthRT.ColorDst0;
                    }
                }

                // エッジを描画する場合はカラーマップを書き込む
                var sobel = GameObject.GetComponent <SobelEdge>();
                if (sobel != null && sobel.Enabled)
                {
                    RenderToColorMap(colorRT, sp, drawMeshDic);
                    sobel.ColorTexture = colorRT.ColorDst0;
                }

                // モーションブラーをする場合は速度マップを書き込む
                if ((motionBlur != null && motionBlur.Enabled))
                {
                    RenderToVelocityMap(velocityRT, sp, drawMeshDic);
                    motionBlur.VelocityMap = velocityRT.ColorDst0;
                }

                // 影の準備
                if (ShadowMapping && MMW.Configuration.ShadowQuality != MMWConfiguration.ShadowQualityType.NoShadow)
                {
                    Vector3 lightDir = MMW.DirectionalLight.WorldDirection;
                    Vector3 center   = GameObject.Transform.WorldPosition;
                    Matrix4 view     = Matrix4.Identity;
                    Matrix4 projo    = Matrix4.Identity;

                    // render to far shadow depth map
                    {
                        view        = Matrix4.LookAt(Vector3.Zero, lightDir, Vector3.UnitY);
                        projo       = Matrix4.CreateOrthographic(240, 240, -150, 150);
                        sp.viewProj = view * projo;
                        if (prevLightDir != lightDir)
                        {
                            RenderToDepthMap(shadowDepthRT1, sp, drawMeshDic);
                        }
                        sp.shadowDepthBias1 = sp.viewProj * shadowDepthBias;
                        sp.shadowDepthMap1  = shadowDepthRT1.ColorDst0;
                    }

                    //  render to middle shadow depth map
                    {
                        view        = Matrix4.LookAt(center, center + lightDir, Vector3.UnitY);
                        projo       = Matrix4.CreateOrthographic(40, 40, -150, 150);
                        sp.viewProj = view * projo;
                        RenderToDepthMap(shadowDepthRT2, sp, drawMeshDic);
                        sp.shadowDepthBias2 = sp.viewProj * shadowDepthBias;
                        sp.shadowDepthMap2  = shadowDepthRT2.ColorDst0;
                    }

                    //  render to near shadow depth map
                    {
                        view        = Matrix4.LookAt(center, center + lightDir, Vector3.UnitY);
                        projo       = Matrix4.CreateOrthographic(10, 10, -80, 80);
                        sp.viewProj = view * projo;
                        RenderToDepthMap(shadowDepthRT3, sp, drawMeshDic);
                        sp.shadowDepthBias3 = sp.viewProj * shadowDepthBias;
                        sp.shadowDepthMap3  = shadowDepthRT3.ColorDst0;
                    }

                    sp.viewProj   = viewproj;
                    prevLightDir  = lightDir;
                    prevCameraPos = center;
                }
            }

            // レンダーターゲットをセット
            TargetTexture.Bind();
            GL.ClearColor(ClearColor);
            if (ClearFlag == ClearFlag.SolidColor)
            {
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
            }
            else if (ClearFlag == ClearFlag.DepthOnly)
            {
                GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
            }
            else if (ClearFlag == ClearFlag.SkyBox)
            {
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
                Drawer.DrawTextureCube(ClearSkyBox, GameObject.Transform.WorldDirectionZ, FoV, Aspect, SkyBoxColor, SkyBoxContrast, SkyBoxSaturation, SkyBoxBrightness);
            }

            // その他スクリプトの描画(メッシュ描画前)
            if (ScriptDraw)
            {
                //DrawScripts(objects, (float)deltaTime, c => c.GameObject.Layer < 16);
            }

            // メッシュ描画
            if (MeshDraw)
            {
                // ライト並び替えタスクが終わるまで待機
                //MMW.lightSortTask.Wait();

                DrawMeshes(sp, drawMeshDic);
            }

            // その他スクリプトの描画
            if (ScriptDraw)
            {
                //DrawScripts(objects, (float)deltaTime, c => c.GameObject.Layer >= 16);
            }

            // イメージエフェクトをかける
            var effects = GameObject.GetComponents <ImageEffect>();

            if (effects != null)
            {
                for (var i = 0; i < effects.Length; i++)
                {
                    if (!effects[i].Enabled)
                    {
                        continue;
                    }
                    effects[i].Draw(deltaTime);
                }
            }

            // UI層のゲームオブジェクトを描画
            if (UIDraw && layerMask.Get(GameObject.LayerUI))
            {
                //var objs = MMW.FindGameObjects((obj) => obj.Layer == GameObject.LayerUI && layerMask.Get(obj.Layer));
                //DrawScripts(objs, (float)deltaTime, c => true);
            }
        }