plus() public method

public plus ( Vec vec ) : Vec
vec Vec
return Vec
Esempio n. 1
0
        ButtonStateVar.DragRezult onStartDragL(Vec posScreen)
        {
            switch (mInsert)
            {
                case Insert.Line:
                    {
                        Vec world = mTimeSpace.getWorldFromScreen(posScreen);
                        Line line = new Line(world, world.plus(new Vec(20, 20)), Color.Black);
                        insert(line);
                        mInsert = Insert.None;

                        return new ButtonStateVar.DragRezult(
                            delegate(Vec posScreenNew)
                            {
                                Vec world2 = mTimeSpace.getWorldFromScreen(posScreenNew);
                                line.mPos1 = world2;
                                Invalidate();
                            },
                            null,
                            null);

                    }
                case Insert.LineLight:
                    {
                        Vec world = mTimeSpace.getWorldFromScreen(posScreen);
                        Line line = new Line(world, world.plus(new Vec(20, 20)), Color.Orange);
                        mTimeSpace.add(line);
                        mInsert = Insert.None;
                        Invalidate();

                        return new ButtonStateVar.DragRezult(
                            delegate(Vec posScreenNew)
                            {
                                Vec delta = posScreenNew.minus(posScreen);
                                delta.lightCorect();
                                Vec world2 = mTimeSpace.getWorldFromScreen(posScreen.plus(delta));
                                line.mPos1 = world2;
                                Invalidate();
                            },
                            null,
                            null);
                    }
                case Insert.Invariant:
                    {
                        mInsert = Insert.None;
                        Invalidate();

                        return new ButtonStateVar.DragRezult(
                            delegate(Vec posScreenNew)
                            {
                                Invalidate();
                            },
                            delegate(Vec posScreenNew)
                            {
                                Invalidate();
                            },
                            delegate(Vec posScreenNew, DrawInfo di)
                            {
                                Pen pen = new Pen(Color.LimeGreen);
                                pen.Width = 1;
                                di.drawLine(pen, posScreen, posScreenNew);

                                Vec world = mTimeSpace.getWorldFromScreen(posScreen);
                                Vec worldNew = mTimeSpace.getWorldFromScreen(posScreenNew);
                                double invariant = mTimeSpace.getInvariant(world, worldNew) / (GRID*GRID);
                                di.drawText(invariant.ToString(), posScreenNew.plus(new Vec(10, -10)));
                            });
                    }
                default:
                    return new ButtonStateVar.DragRezult(true);
            }
        }
Esempio n. 2
0
        ButtonStateVar.DragRezult onStartDragL(Vec posScreen)
        {
            switch (mInsert)
            {
            case Insert.Line:
            {
                Vec  world = mTimeSpace.getWorldFromScreen(posScreen);
                Line line  = new Line(world, world.plus(new Vec(20, 20)), Color.Black);
                insert(line);
                mInsert = Insert.None;

                return(new ButtonStateVar.DragRezult(
                           delegate(Vec posScreenNew)
                    {
                        Vec world2 = mTimeSpace.getWorldFromScreen(posScreenNew);
                        line.mPos1 = world2;
                        Invalidate();
                    },
                           null,
                           null));
            }

            case Insert.LineLight:
            {
                Vec  world = mTimeSpace.getWorldFromScreen(posScreen);
                Line line  = new Line(world, world.plus(new Vec(20, 20)), Color.Orange);
                mTimeSpace.add(line);
                mInsert = Insert.None;
                Invalidate();

                return(new ButtonStateVar.DragRezult(
                           delegate(Vec posScreenNew)
                    {
                        Vec delta = posScreenNew.minus(posScreen);
                        delta.lightCorect();
                        Vec world2 = mTimeSpace.getWorldFromScreen(posScreen.plus(delta));
                        line.mPos1 = world2;
                        Invalidate();
                    },
                           null,
                           null));
            }

            case Insert.Invariant:
            {
                mInsert = Insert.None;
                Invalidate();

                return(new ButtonStateVar.DragRezult(
                           delegate(Vec posScreenNew)
                    {
                        Invalidate();
                    },
                           delegate(Vec posScreenNew)
                    {
                        Invalidate();
                    },
                           delegate(Vec posScreenNew, DrawInfo di)
                    {
                        Pen pen = new Pen(Color.LimeGreen);
                        pen.Width = 1;
                        di.drawLine(pen, posScreen, posScreenNew);

                        Vec world = mTimeSpace.getWorldFromScreen(posScreen);
                        Vec worldNew = mTimeSpace.getWorldFromScreen(posScreenNew);
                        double invariant = mTimeSpace.getInvariant(world, worldNew) / (GRID * GRID);
                        di.drawText(invariant.ToString(), posScreenNew.plus(new Vec(10, -10)));
                    }));
            }

            default:
                return(new ButtonStateVar.DragRezult(true));
            }
        }