상속: MonoBehaviour
 public StatisticalLineAndShapeRenderer(bool linesVisible, bool shapesVisible)
   : base(linesVisible, shapesVisible)
 {
   StatisticalLineAndShapeRenderer andShapeRenderer = this;
   this.errorIndicatorPaint = (Paint) null;
   this.errorIndicatorStroke = (Stroke) null;
 }
예제 #2
0
 public XYLineAnnotation(double x1, double y1, double x2, double y2, Stroke stroke, Paint paint)
 {
   XYLineAnnotation xyLineAnnotation = this;
   if (stroke == null)
   {
     string str = "Null 'stroke' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else if (paint == null)
   {
     string str = "Null 'paint' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else
   {
     this.x1 = x1;
     this.y1 = y1;
     this.x2 = x2;
     this.y2 = y2;
     this.stroke = stroke;
     this.paint = paint;
   }
 }
예제 #3
0
 public ClipPath(double[] xValue, double[] yValue, bool clip, bool fillPath, bool drawPath)
 {
   int num1 = clip ? 1 : 0;
   int num2 = fillPath ? 1 : 0;
   int num3 = drawPath ? 1 : 0;
   base.\u002Ector();
   ClipPath clipPath = this;
   this.xValue = (double[]) null;
   this.yValue = (double[]) null;
   this.clip = true;
   this.drawPath = false;
   this.fillPath = false;
   this.fillPaint = (Paint) null;
   this.drawPaint = (Paint) null;
   this.drawStroke = (Stroke) null;
   this.composite = (Composite) null;
   this.xValue = xValue;
   this.yValue = yValue;
   this.clip = num1 != 0;
   this.fillPath = num2 != 0;
   this.drawPath = num3 != 0;
   this.fillPaint = (Paint) Color.gray;
   this.drawPaint = (Paint) Color.blue;
   this.drawStroke = (Stroke) new BasicStroke(1f);
   this.composite = (Composite) AlphaComposite.Src;
 }
예제 #4
0
 public LineBorder(Paint paint, Stroke stroke, RectangleInsets insets)
 {
   base.\u002Ector();
   LineBorder lineBorder = this;
   if (paint == null)
   {
     string str = "Null 'paint' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else if (stroke == null)
   {
     string str = "Null 'stroke' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else if (insets == null)
   {
     string str = "Null 'insets' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else
   {
     this.paint = paint;
     this.stroke = stroke;
     this.insets = insets;
   }
 }
예제 #5
0
 public MeterInterval(string label, Range range, Paint outlinePaint, Stroke outlineStroke, Paint backgroundPaint)
 {
   base.\u002Ector();
   MeterInterval meterInterval = this;
   if (label == null)
   {
     string str = "Null 'label' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else if (range == null)
   {
     string str = "Null 'range' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else
   {
     this.label = label;
     this.range = range;
     this.outlinePaint = outlinePaint;
     this.outlineStroke = outlineStroke;
     this.backgroundPaint = backgroundPaint;
   }
 }
예제 #6
0
 public PaintScaleLegend(PaintScale scale, ValueAxis axis)
 {
   PaintScaleLegend paintScaleLegend = this;
   if (axis == null)
   {
     string str = "Null 'axis' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else
   {
     this.scale = scale;
     this.axis = axis;
     this.axis.addChangeListener((AxisChangeListener) this);
     this.axisLocation = AxisLocation.__\u003C\u003EBOTTOM_OR_LEFT;
     this.axisOffset = 0.0;
     this.axis.setRange(scale.getLowerBound(), scale.getUpperBound());
     this.stripWidth = 15.0;
     this.stripOutlineVisible = true;
     this.stripOutlinePaint = (Paint) Color.gray;
     this.stripOutlineStroke = (Stroke) new BasicStroke(0.5f);
     this.backgroundPaint = (Paint) Color.white;
     this.subdivisions = 100;
   }
 }
 public XYPolygonAnnotation(double[] polygon, Stroke stroke, Paint outlinePaint, Paint fillPaint)
 {
   XYPolygonAnnotation polygonAnnotation = this;
   if (polygon == null)
   {
     string str = "Null 'polygon' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else
   {
     int length = polygon.Length;
     int num1 = 2;
     int num2 = -1;
     if ((num1 != num2 ? length % num1 : 0) != 0)
     {
       string str = "The 'polygon' array must contain an even number of items.";
       Throwable.__\u003CsuppressFillInStackTrace\u003E();
       throw new IllegalArgumentException(str);
     }
     else
     {
       this.polygon = (double[]) polygon.Clone();
       this.stroke = stroke;
       this.outlinePaint = outlinePaint;
       this.fillPaint = fillPaint;
     }
   }
 }
 public StackedXYAreaRenderer(int type, XYToolTipGenerator labelGenerator, XYURLGenerator urlGenerator)
   : base(type, labelGenerator, urlGenerator)
 {
   StackedXYAreaRenderer stackedXyAreaRenderer = this;
   this.shapePaint = (Paint) null;
   this.shapeStroke = (Stroke) null;
 }
예제 #9
0
 public StrokeSample(Stroke stroke)
 {
   base.\u002Ector();
   StrokeSample strokeSample = this;
   this.stroke = stroke;
   this.preferredSize = new Dimension(80, 18);
   this.setPreferredSize(this.preferredSize);
 }
예제 #10
0
 public static IBrush CreateBrush(Stroke stroke, string name, Dictionary<string, object> options)
 {
     // try and create the brush
     // if unable to instantiat, return LineBrush by default
     IBrush o = (ScriptableObject.CreateInstance(name) as IBrush) ?? ScriptableObject.CreateInstance<LineBrush>();
     o.Stroke = stroke;
     return o;
 }
예제 #11
0
 public CategoryMarker(IComparable key, Paint paint, Stroke stroke, Paint outlinePaint, Stroke outlineStroke, float alpha)
   : base(paint, stroke, outlinePaint, outlineStroke, alpha)
 {
   CategoryMarker categoryMarker = this;
   this.drawAsLine = false;
   this.key = key;
   this.setLabelOffsetType(LengthAdjustmentType.__\u003C\u003EEXPAND);
 }
예제 #12
0
 public StandardDialFrame()
 {
   StandardDialFrame standardDialFrame = this;
   this.backgroundPaint = (Paint) Color.gray;
   this.foregroundPaint = (Paint) Color.black;
   this.stroke = (Stroke) new BasicStroke(2f);
   this.radius = 0.95;
 }
예제 #13
0
 public DialCap()
 {
   DialCap dialCap = this;
   this.radius = 0.05;
   this.fillPaint = (Paint) Color.white;
   this.outlinePaint = (Paint) Color.black;
   this.outlineStroke = (Stroke) new BasicStroke(2f);
 }
예제 #14
0
 public IntervalMarker(double start, double end, Paint paint, Stroke stroke, Paint outlinePaint, Stroke outlineStroke, float alpha)
   : base(paint, stroke, outlinePaint, outlineStroke, alpha)
 {
   IntervalMarker intervalMarker = this;
   this.startValue = start;
   this.endValue = end;
   this.gradientPaintTransformer = (GradientPaintTransformer) null;
   this.setLabelOffsetType(LengthAdjustmentType.__\u003C\u003ECONTRACT);
 }
예제 #15
0
파일: TrackPen.cs 프로젝트: jawa0/jabarepo
    void Start()
    {
        prevMousePosition = new Vector3(-1.0f, -1.0f, -1.0f);

        strokes = new ArrayList();
        currentStroke = null;

        strokeMeshes = new ArrayList();
    }
예제 #16
0
 //Gets the edge corresponding to the given stroke
 public Edge getEdge(Stroke s)
 {
     for(int i=0; i<list.Count; i++)
     {
         Edge e = list[i] as Edge;
         if(e.strokeEquals(s))
             return e;
     }
     return null;
 }
예제 #17
0
 public XYErrorRenderer()
   : base(false, true)
 {
   XYErrorRenderer xyErrorRenderer = this;
   this.drawXError = true;
   this.drawYError = true;
   this.errorPaint = (Paint) null;
   this.errorStroke = (Stroke) null;
   this.capLength = 4.0;
 }
예제 #18
0
 public XYBoxAnnotation(double x0, double y0, double x1, double y1, Stroke stroke, Paint outlinePaint, Paint fillPaint)
 {
   XYBoxAnnotation xyBoxAnnotation = this;
   this.x0 = x0;
   this.y0 = y0;
   this.x1 = x1;
   this.y1 = y1;
   this.stroke = stroke;
   this.outlinePaint = outlinePaint;
   this.fillPaint = fillPaint;
 }
예제 #19
0
 public ArcDialFrame(double startAngle, double extent)
 {
   ArcDialFrame arcDialFrame = this;
   this.backgroundPaint = (Paint) Color.gray;
   this.foregroundPaint = (Paint) new Color(100, 100, 150);
   this.stroke = (Stroke) new BasicStroke(2f);
   this.innerRadius = 0.25;
   this.outerRadius = 0.75;
   this.startAngle = startAngle;
   this.extent = extent;
 }
 public MinMaxCategoryRenderer()
 {
   MinMaxCategoryRenderer categoryRenderer = this;
   this.plotLines = false;
   this.groupPaint = (Paint) Color.black;
   this.groupStroke = (Stroke) new BasicStroke(1f);
   this.minIcon = this.getIcon((Shape) new Arc2D.Double(-4.0, -4.0, 8.0, 8.0, 0.0, 360.0, 0), (Paint) null, (Paint) Color.black);
   this.maxIcon = this.getIcon((Shape) new Arc2D.Double(-4.0, -4.0, 8.0, 8.0, 0.0, 360.0, 0), (Paint) null, (Paint) Color.black);
   this.objectIcon = this.getIcon((Shape) new Line2D.Double(-4.0, 0.0, 4.0, 0.0), false, true);
   this.lastCategory = -1;
 }
예제 #21
0
 public CyclicNumberAxis(double period, double offset, string label)
   : base(label)
 {
   CyclicNumberAxis cyclicNumberAxis = this;
   this.advanceLineStroke = CyclicNumberAxis.DEFAULT_ADVANCE_LINE_STROKE;
   this.period = period;
   this.offset = offset;
   this.setFixedAutoRange(period);
   this.advanceLineVisible = true;
   this.advanceLinePaint = CyclicNumberAxis.__\u003C\u003EDEFAULT_ADVANCE_LINE_PAINT;
 }
예제 #22
0
    /**
     * Construct Java Graphics object which translates graphic calls in ppt Drawing layer.
     *
     * @param group           The shape group to write the graphics calls into.
     */
    public PPGraphics2D(ShapeGroup group){
        this._group = group;

        _transform = new AffineTransform();
        _stroke = new BasicStroke();
        _paint = Color.black;
        _font = new Font("Arial", Font.PLAIN, 12);
        _background = Color.black;
        _foreground = Color.white;
        _hints = new RenderingHints(null);
    }
예제 #23
0
파일: Painting.cs 프로젝트: ivlab/Paint3D
 public void StartNewStroke()
 {
     if (CurrentStroke == null)
     {
         CurrentStroke = new Stroke();
         strokes.Add(CurrentStroke);
         curIndex = strokes.Count - 1;
         CurrentStroke.Brush = BrushManager.CreateBrush(CurrentStroke, SelectedBrush, null);
         CurrentStroke.Brush.SetOptions(options[CurrentStroke.Brush.BrushName]);
     }
 }
예제 #24
0
 public RingPlot(PieDataset dataset)
   : base(dataset)
 {
   RingPlot ringPlot = this;
   this.separatorsVisible = true;
   this.separatorStroke = (Stroke) new BasicStroke(0.5f);
   this.separatorPaint = (Paint) Color.gray;
   this.innerSeparatorExtension = 0.2;
   this.outerSeparatorExtension = 0.2;
   this.sectionDepth = 0.2;
 }
 public CategoryPointerAnnotation(string label, IComparable key, double value, double angle)
   : base(label, key, value)
 {
   CategoryPointerAnnotation pointerAnnotation = this;
   this.angle = angle;
   this.tipRadius = 10.0;
   this.baseRadius = 30.0;
   this.arrowLength = 5.0;
   this.arrowWidth = 3.0;
   this.labelOffset = 3.0;
   this.arrowStroke = (Stroke) new BasicStroke(1f);
   this.arrowPaint = (Paint) Color.black;
 }
예제 #26
0
 public XYShapeRenderer()
 {
   XYShapeRenderer xyShapeRenderer = this;
   this.paintScale = (PaintScale) new LookupPaintScale();
   this.useFillPaint = false;
   this.drawOutlines = false;
   this.useOutlinePaint = true;
   this.guideLinesVisible = false;
   this.guideLinePaint = (Paint) Color.darkGray;
   this.guideLineStroke = (Stroke) new BasicStroke();
   this.setBaseShape((Shape) new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0));
   this.setAutoPopulateSeriesShape(false);
 }
 public XYPointerAnnotation(string label, double x, double y, double angle)
   : base(label, x, y)
 {
   XYPointerAnnotation pointerAnnotation = this;
   this.angle = angle;
   this.tipRadius = 10.0;
   this.baseRadius = 30.0;
   this.arrowLength = 5.0;
   this.arrowWidth = 3.0;
   this.labelOffset = 3.0;
   this.arrowStroke = (Stroke) new BasicStroke(1f);
   this.arrowPaint = (Paint) Color.black;
 }
예제 #28
0
 public ClipPath()
 {
   base.\u002Ector();
   ClipPath clipPath = this;
   this.xValue = (double[]) null;
   this.yValue = (double[]) null;
   this.clip = true;
   this.drawPath = false;
   this.fillPath = false;
   this.fillPaint = (Paint) null;
   this.drawPaint = (Paint) null;
   this.drawStroke = (Stroke) null;
   this.composite = (Composite) null;
 }
예제 #29
0
 public Edge(Node n1, Node n2, InkOverlay i, int weight)
 {
     //Keep track of the nodes its attached to
     this.a = n1;
     this.b = n2;
     this.weight = weight;
     color = DEFAULT;
     //Make sure the nodes contain this in their edges
     a.Edges.Add(this);
     b.Edges.Add(this);
     Point[] p = {a.CenterPoint,b.CenterPoint};
     //Draw a stroke connecting both nodes
     this.stroke = i.Ink.CreateStroke(p);
 }
예제 #30
0
 public Node(Stroke stroke)
 {
     this.stroke = stroke;
     this.id = stroke.Id;
     Rectangle r = stroke.GetBoundingBox();
     //Determine whether this node is a rectangle or not
     isRect = r.Width*Math.PI < StrokeManager.StrokeLength(stroke);
     centerPoint = new Point(r.X + r.Width/2, r.Y + r.Height/2);
     fillColor = DEFAULT;
     edges = new Edges();
     textColor = TEXT_DEFAULT;
     text = "";
     //Set initial distance to infinity (max int)
     distance = Int32.MaxValue;
 }
예제 #31
0
 public float GetMixError(Stroke stroke)
 {
     //Debug.Log(GetSlopeError(stroke));
     return(Mathf.Pow(GetError(stroke), 2.0f) * 100.0f + Mathf.Pow(GetSlopeError(stroke), 2.0f));
 }
예제 #32
0
        public void Draw(MatterHackers.Agg.Transform.ITransform Position, Graphics2D renderer)
        {
            double TextHeight = m_Position.y - 20;
            double Range      = (m_DataViewMaxY - m_DataViewMinY);
            VertexSourceApplyTransform TransformedLinesToDraw;
            Stroke StrockedTransformedLinesToDraw;

            RoundedRect BackGround = new RoundedRect(m_Position.x, m_Position.y - 1, m_Position.x + m_Width, m_Position.y - 1 + m_Height + 2, 5);
            VertexSourceApplyTransform TransformedBackGround = new VertexSourceApplyTransform(BackGround, Position);

            renderer.Render(TransformedBackGround, new RGBA_Bytes(0, 0, 0, .5));

            // if the 0 line is within the window than draw it.
            if (m_DataViewMinY < 0 && m_DataViewMaxY > 0)
            {
                m_LinesToDraw.remove_all();
                m_LinesToDraw.MoveTo(m_Position.x,
                                     m_Position.y + ((0 - m_DataViewMinY) * m_Height / Range));
                m_LinesToDraw.LineTo(m_Position.x + m_Width,
                                     m_Position.y + ((0 - m_DataViewMinY) * m_Height / Range));
                TransformedLinesToDraw         = new VertexSourceApplyTransform(m_LinesToDraw, Position);
                StrockedTransformedLinesToDraw = new Stroke(TransformedLinesToDraw);
                renderer.Render(StrockedTransformedLinesToDraw, new RGBA_Bytes(0, 0, 0, 1));
            }

            double MaxMax     = -999999999;
            double MinMin     = 999999999;
            double MaxAverage = 0;

            foreach (KeyValuePair <String, HistoryData> historyKeyValue in m_DataHistoryArray)
            {
                HistoryData history = historyKeyValue.Value;
                m_LinesToDraw.remove_all();
                MaxMax     = System.Math.Max(MaxMax, history.GetMaxValue());
                MinMin     = System.Math.Min(MinMin, history.GetMinValue());
                MaxAverage = System.Math.Max(MaxAverage, history.GetAverageValue());
                for (int i = 0; i < m_Width - 1; i++)
                {
                    if (i == 0)
                    {
                        m_LinesToDraw.MoveTo(m_Position.x + i,
                                             m_Position.y + ((history.GetItem(i) - m_DataViewMinY) * m_Height / Range));
                    }
                    else
                    {
                        m_LinesToDraw.LineTo(m_Position.x + i,
                                             m_Position.y + ((history.GetItem(i) - m_DataViewMinY) * m_Height / Range));
                    }
                }

                TransformedLinesToDraw         = new VertexSourceApplyTransform(m_LinesToDraw, Position);
                StrockedTransformedLinesToDraw = new Stroke(TransformedLinesToDraw);
                renderer.Render(StrockedTransformedLinesToDraw, history.m_Color);

                String Text = historyKeyValue.Key + ": Min:" + MinMin.ToString("0.0") + " Max:" + MaxMax.ToString("0.0");
                renderer.DrawString(Text, m_Position.x, TextHeight - m_Height);
                TextHeight -= 20;
            }

            RoundedRect BackGround2 = new RoundedRect(m_Position.x, m_Position.y - 1, m_Position.x + m_Width, m_Position.y - 1 + m_Height + 2, 5);
            VertexSourceApplyTransform TransformedBackGround2 = new VertexSourceApplyTransform(BackGround2, Position);
            Stroke StrockedTransformedBackGround = new Stroke(TransformedBackGround2);

            renderer.Render(StrockedTransformedBackGround, new RGBA_Bytes(0.0, 0, 0, 1));

            //renderer.Color = BoxColor;
            //renderer.DrawRect(m_Position.x, m_Position.y - 1, m_Width, m_Height + 2);
        }
예제 #33
0
 internal override void drawPath(CanvasPathBuilder p, Stroke stroke)
 {
     pendingRenderingOperations.Add(new DrawPathPainter(null, color, alpha, p, stroke));
 }
예제 #34
0
    // private void HandleTriggerClicked(object sender, ClickedEventArgs e)
    // {
    //     // SpawnCurrentPrimitiveAtController();
    //     Vector3 pos = cursor.position;
    //     Quaternion rotation = cursor.rotation;
    //     stroke = new Stroke(activeMeshFilter.mesh);
    //     stroke.options = strokeOptions;
    //     stroke.start(pos, rotation);
    // }
    // private void HandleTriggerUnClicked(object sender, ClickedEventArgs e)
    // {
    //     // SpawnCurrentPrimitiveAtController();
    //     stroke.end();
    //     combineStroke(stroke);
    //     stroke = null;
    // }
    // Update is called once per frame
    void Update()
    {
        //draw strokes when the mouse is clicked
        // Vector3 pos = transform.InverseTransformPoint(cameraMouse());

        // deltaZ += .005f;
        // Vector3 deltaPos = new Vector3(0, 0, Mathf.Sin(deltaZ) * 2);
        // pos += deltaPos;
        // deltaRX += .005f;
        // cursor.localEulerAngles = new Vector3(Mathf.Sin(deltaRX) * 90, 0f, 0f);

        // cursor.localPosition = pos;

        // Vector3 pos = cursor.position;


        // Quaternion rotation = cursor.rotation; //world rotation
        // if (Input.GetMouseButtonDown(0))
        // {
        //     stroke = new Stroke(activeMeshFilter.mesh);
        //     //set the x rotation randomly
        //     // cursor.localEulerAngles = new Vector3(Random.Range(-60f, 60f), 0, 0);
        //     stroke.options = strokeOptions;
        //     stroke.start(pos, rotation);
        // }
        // if (Input.GetMouseButton(0))
        // {
        //     stroke.move(pos, rotation);
        // }
        // if (Input.GetMouseButtonUp(0))
        // {
        //     stroke.end();
        //     combineStroke(stroke);
        // }
        SteamVR_Controller.Device device = SteamVR_Controller.Input((int)leftController.controllerIndex);
        // Debug.Log(device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger));
        float triggerVal = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger).x;
        float minTrigger = .05f;

        if (triggerVal > minTrigger)
        {
            Vector3    pos      = cursor.position;
            Quaternion rotation = cursor.rotation;
            if (stroke != null)
            {
                // Vector3 pos = cursor.position;
                // Quaternion rotation = cursor.rotation; //world rotation
                // leftController.
                stroke.move(pos, rotation, triggerVal);
            }
            else
            {
                stroke         = new Stroke(activeMeshFilter.mesh);
                stroke.options = strokeOptions;
                stroke.start(pos, rotation, triggerVal);
            }
        }
        else if (stroke != null)
        {
            stroke.end();
            combineStroke(stroke);
            stroke = null;
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            clearStrokes();
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }
    }
예제 #35
0
            public void PaintPixelsInRam(PaintCommand.UV command)
            {
                Stroke      stroke     = command.Stroke;
                float       brushAlpha = command.strokeAlphaPortion;
                TextureMeta image      = command.TextureData;
                Brush       bc         = command.Brush;

                var volume = image.texture2D.GetVolumeTextureData();

                if (!volume)
                {
                    return;
                }

                bc.brush3DRadius = Mathf.Min(BrushScaleMaxForCpu(volume), bc.brush3DRadius);

                var volumeScale = volume.size;

                var pos = (stroke.posFrom - volume.transform.position) / volumeScale + 0.5f * Vector3.one;

                var height   = volume.Height;
                var texWidth = image.width;

                BlitFunctions.brAlpha = brushAlpha;
                bc.PrepareCpuBlit(image);
                BlitFunctions.half = bc.Size(true) / volumeScale;

                var pixels = image.Pixels;

                var iHalf  = (int)(BlitFunctions.half - 0.5f);
                var smooth = bc.GetBrushType(true) != BrushTypes.Pixel.Inst;

                if (smooth)
                {
                    iHalf += 1;
                }

                BlitFunctions.alphaMode = BlitFunctions.SphereAlpha;

                var sliceWidth = texWidth / volume.hSlices;

                var hw = sliceWidth / 2;

                var y = (int)pos.y;
                var z = (int)(pos.z + hw);
                var x = (int)(pos.x + hw);

                for (BlitFunctions.y = -iHalf; BlitFunctions.y < iHalf + 1; BlitFunctions.y++)
                {
                    var h = y + BlitFunctions.y;

                    if (h >= height)
                    {
                        return;
                    }

                    if (h < 0)
                    {
                        continue;
                    }
                    var hy        = h / volume.hSlices;
                    var hx        = h % volume.hSlices;
                    var hTexIndex = (hy * texWidth + hx) * sliceWidth;

                    for (BlitFunctions.z = -iHalf; BlitFunctions.z < iHalf + 1; BlitFunctions.z++)
                    {
                        var trueZ = z + BlitFunctions.z;

                        if (trueZ < 0 || trueZ >= sliceWidth)
                        {
                            continue;
                        }
                        var yTexIndex = hTexIndex + trueZ * texWidth;

                        for (BlitFunctions.x = -iHalf; BlitFunctions.x < iHalf + 1; BlitFunctions.x++)
                        {
                            if (!BlitFunctions.alphaMode())
                            {
                                continue;
                            }
                            var trueX = x + BlitFunctions.x;

                            if (trueX < 0 || trueX >= sliceWidth)
                            {
                                continue;
                            }
                            var texIndex = yTexIndex + trueX;
                            BlitFunctions.blitMode(ref pixels[texIndex]);
                        }
                    }
                }
            }
예제 #36
0
        public override void OnRender(ChartControl chartControl, ChartScale chartScale)
        {
            if (firstTime && DrawingState == DrawingState.Normal)
            {
                firstTime = false;
                Cbi.License.Log("Path");
            }

            RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;
            Stroke outlineStroke = OutlineStroke;

            outlineStroke.RenderTarget = RenderTarget;
            ChartPanel chartPanel      = chartControl.ChartPanels[PanelIndex];
            double     strokePixAdjust = outlineStroke.Width % 2 == 0 ? 0.5d : 0d;
            Vector     pixelAdjustVec  = new Vector(strokePixAdjust, strokePixAdjust);

            SharpDX.Direct2D1.PathGeometry polyGeo  = CreatePathGeometry(chartControl, chartPanel, chartScale, strokePixAdjust);
            SharpDX.Direct2D1.Brush        tmpBrush = IsInHitTest ? chartControl.SelectionBrush : outlineStroke.BrushDX;

            RenderTarget.DrawGeometry(polyGeo, tmpBrush, outlineStroke.Width, outlineStroke.StrokeStyle);
            polyGeo.Dispose();

            if (PathBegin == PathToolCapMode.Arrow || PathEnd == PathToolCapMode.Arrow)
            {
                Point[] points = GetPathAnchorPoints(chartControl, chartScale);

                if (points.Length > 1)
                {
                    if (arrowPathGeometry == null)
                    {
                        arrowPathGeometry = new SharpDX.Direct2D1.PathGeometry(Core.Globals.D2DFactory);
                        SharpDX.Direct2D1.GeometrySink geometrySink = arrowPathGeometry.Open();
                        float           arrowWidth = 6f;
                        SharpDX.Vector2 top        = new SharpDX.Vector2(0, outlineStroke.Width * 0.5f);

                        geometrySink.BeginFigure(top, SharpDX.Direct2D1.FigureBegin.Filled);
                        geometrySink.AddLine(new SharpDX.Vector2(arrowWidth, -arrowWidth));
                        geometrySink.AddLine(new SharpDX.Vector2(-arrowWidth, -arrowWidth));
                        geometrySink.AddLine(top);                        // cap off figure
                        geometrySink.EndFigure(SharpDX.Direct2D1.FigureEnd.Closed);
                        geometrySink.Close();
                    }

                    if (PathBegin == PathToolCapMode.Arrow)
                    {
                        Vector lineVector = points[0] - points[1];

                        lineVector.Normalize();

                        Point             pointAdjusted    = points[0] + pixelAdjustVec;
                        SharpDX.Vector2   pointVec         = pointAdjusted.ToVector2();
                        float             vectorAngle      = -(float)Math.Atan2(lineVector.X, lineVector.Y);
                        Vector            adjustVector     = lineVector * 5;
                        SharpDX.Vector2   arrowPointVec    = new SharpDX.Vector2((float)(pointVec.X + adjustVector.X), (float)(pointVec.Y + adjustVector.Y));
                        SharpDX.Matrix3x2 transformMatrix2 = SharpDX.Matrix3x2.Rotation(vectorAngle, SharpDX.Vector2.Zero) * SharpDX.Matrix3x2.Scaling((float)Math.Max(1.0f, outlineStroke.Width * .45) + 0.25f) * SharpDX.Matrix3x2.Translation(arrowPointVec);
                        RenderTarget.Transform = transformMatrix2;

                        RenderTarget.FillGeometry(arrowPathGeometry, tmpBrush);
                        RenderTarget.Transform = SharpDX.Matrix3x2.Identity;
                    }

                    if (PathEnd == PathToolCapMode.Arrow)
                    {
                        Vector lineVector = points[points.Length - 1] - points[points.Length - 2];

                        lineVector.Normalize();

                        Point             pointAdjusted    = points[points.Length - 1] + pixelAdjustVec;
                        SharpDX.Vector2   pointVec         = pointAdjusted.ToVector2();
                        float             vectorAngle      = -(float)Math.Atan2(lineVector.X, lineVector.Y);
                        Vector            adjustVector     = lineVector * 5;
                        SharpDX.Vector2   arrowPointVec    = new SharpDX.Vector2((float)(pointVec.X + adjustVector.X), (float)(pointVec.Y + adjustVector.Y));
                        SharpDX.Matrix3x2 transformMatrix2 = SharpDX.Matrix3x2.Rotation(vectorAngle, SharpDX.Vector2.Zero) * SharpDX.Matrix3x2.Scaling((float)Math.Max(1.0f, outlineStroke.Width * .45) + 0.25f) * SharpDX.Matrix3x2.Translation(arrowPointVec);
                        RenderTarget.Transform = transformMatrix2;

                        RenderTarget.FillGeometry(arrowPathGeometry, tmpBrush);

                        RenderTarget.Transform = SharpDX.Matrix3x2.Identity;
                    }
                }
            }

            if (ShowCount)
            {
                SimpleFont wpfFont = chartControl.Properties.LabelFont ?? new SimpleFont();
                SharpDX.DirectWrite.TextFormat textFormat = wpfFont.ToDirectWriteTextFormat();
                textFormat.TextAlignment = SharpDX.DirectWrite.TextAlignment.Leading;
                textFormat.WordWrapping  = SharpDX.DirectWrite.WordWrapping.NoWrap;

                for (int i = 1; i < ChartAnchors.Count; i++)
                {
                    Point p  = ChartAnchors[i - 1].GetPoint(chartControl, chartPanel, chartScale);
                    Point p1 = ChartAnchors[i].GetPoint(chartControl, chartPanel, chartScale);

                    if (i + 1 < ChartAnchors.Count)
                    {
                        Point  p2 = ChartAnchors[i + 1].GetPoint(chartControl, chartPanel, chartScale);
                        Vector v1 = p - p1;

                        v1.Normalize();

                        Vector v2 = p2 - p1;

                        v2.Normalize();

                        Vector vector = v1 + v2;

                        vector.Normalize();

                        SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.DirectWriteFactory, i.ToString(), textFormat, 250, textFormat.FontSize);
                        Point textPoint = p1 - vector * textFormat.FontSize;
                        textPoint.X -= textLayout.Metrics.Width / 2f;
                        textPoint.Y -= textLayout.Metrics.Height / 2f;

                        RenderTarget.DrawTextLayout((textPoint + pixelAdjustVec).ToVector2(), textLayout, outlineStroke.BrushDX, SharpDX.Direct2D1.DrawTextOptions.NoSnap);
                        textLayout.Dispose();
                    }
                    else
                    {
                        SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.DirectWriteFactory, i.ToString(), textFormat, 250, textFormat.FontSize);
                        Vector vector = (p - p1);

                        vector.Normalize();

                        Point textPoint = p1 - vector * textFormat.FontSize;
                        textPoint.X -= textLayout.Metrics.Width / 2f;
                        textPoint.Y -= textLayout.Metrics.Height / 2f;

                        RenderTarget.DrawTextLayout((textPoint + pixelAdjustVec).ToVector2(), textLayout, outlineStroke.BrushDX, SharpDX.Direct2D1.DrawTextOptions.NoSnap);
                        textLayout.Dispose();
                    }
                }

                textFormat.Dispose();
            }
        }
예제 #37
0
        protected override void Serialize(IDictionary <string, object> json)
        {
            //>> Serialization

            if (Editable.HasValue)
            {
                json["editable"] = Editable;
            }

            if (Id.HasValue())
            {
                json["id"] = Id;
            }

            if (Rotatable.HasValue)
            {
                json["rotatable"] = Rotatable;
            }

            if (Resizable.HasValue)
            {
                json["resizable"] = Resizable;
            }

            if (Path.HasValue())
            {
                json["path"] = Path;
            }

            var stroke = Stroke.ToJson();

            if (stroke.Any())
            {
                json["stroke"] = stroke;
            }

            if (Type.HasValue())
            {
                json["type"] = Type;
            }

            if (X.HasValue)
            {
                json["x"] = X;
            }

            if (Y.HasValue)
            {
                json["y"] = Y;
            }

            if (MinWidth.HasValue)
            {
                json["minWidth"] = MinWidth;
            }

            if (MinHeight.HasValue)
            {
                json["minHeight"] = MinHeight;
            }

            if (Width.HasValue)
            {
                json["width"] = Width;
            }

            if (Height.HasValue)
            {
                json["height"] = Height;
            }

            if (Background.HasValue())
            {
                json["background"] = Background;
            }

            var hover = Hover.ToJson();

            if (hover.Any())
            {
                json["hover"] = hover;
            }

            var connectors = Connectors.ToJson();

            if (connectors.Any())
            {
                json["connectors"] = connectors;
            }

            var rotation = Rotation.ToJson();

            if (rotation.Any())
            {
                json["rotation"] = rotation;
            }

            if (Content.HasValue())
            {
                json["content"] = Content;
            }

            //<< Serialization

            if (Visual.HasValue())
            {
                json["visual"] = Visual;
            }
        }
예제 #38
0
 public SignedStroke(Stroke stroke)
     : base(stroke.StylusPoints, stroke.DrawingAttributes)
 {
 }
예제 #39
0
        //動作を戻る
        private void backButton_Click(object sender, RoutedEventArgs e)
        {
            counter--;
            try
            {
                //MessageBox.Show("counter = " + counter);
                //MessageBox.Show("learningLogs[" + counter + "] = (" + learningLogs[counter].GetStrokeId() + ", " + learningLogs[counter].GetBehavior() + ")");

                //一次元目がallなら全消去なのですべて再描画する
                if (learningLogs[counter].GetStrokeId().Equals("all"))
                {
                    //ターゲットとなるストロークのidを取ってくる
                    //対象の動作オブジェクトには("all", "erase")が入っているので、一つ前の動作のストロークidを使う
                    int x = Int16.Parse(learningLogs[counter + 1].GetStrokeId());

                    drawAll(x);
                }

                //二次元目がdrawのとき
                else if (learningLogs[counter].GetBehavior().Equals("draw"))
                {
                    //ターゲットとなるストロークのidを取ってくる
                    int x = Int16.Parse(learningLogs[counter].GetStrokeId());

                    //いったん全部消し、当該idまで、再描画する
                    inkCanvas1.Strokes.Clear();
                    counter++;
                    drawAll(x);
                    counter--;
                }

                //二次元目がeraseのとき
                else if (learningLogs[counter].GetBehavior().Equals("erase"))
                {
                    //ターゲットとなるストロークのidを取ってくる
                    int x = Int16.Parse(learningLogs[counter].GetStrokeId());

                    //Redraw stroke[x]
                    //strokeLiesの中から該当するidのストロークを探す
                    StrokeLine sl;
                    for (int i = 0; i < strokeLines.Count; i++)
                    {
                        if (strokeLines[i].GetId() == x)
                        {
                            sl = strokeLines[x];

                            //(とりあえず)隠れたスペースに書いてなければを再描画
                            if (!sl.GetInSpace())
                            {
                                //線の色、幅を取得
                                DrawingAttributes DA = new DrawingAttributes();
                                DA.Color  = sl.GetColor();
                                DA.Width  = sl.GetWidth();
                                DA.Height = sl.GetWidth();
                                inkCanvas1.DefaultDrawingAttributes = DA;

                                //点の情報を集める
                                StylusPointCollection spc = new StylusPointCollection();
                                for (int j = 0; j < sl.GetPoints().Count; j++)
                                {
                                    spc.Add(new StylusPoint(sl.GetPoints()[j].X, sl.GetPoints()[j].Y));
                                }
                                Stroke stroke = new Stroke(spc, DA);
                                inkCanvas1.Strokes.Add(stroke);
                            }
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("最初の動作です。");
            }
        }
예제 #40
0
 public void AddStroke(Stroke stroke)
 {
     unsafe { Bindings.StrokeSampleBuilderAddStroke(builder, stroke.Ptr); }
 }
예제 #41
0
        public void SavingFunction()
        {
            currentlySaving        = true;
            countThatHaveBeenSaved = 0;
            // first create images for all the parts
            foreach (FileNameAndPresentationName stlFileNames in stlFilesToPrint)
            {
                Mesh loadedMesh = StlProcessing.Load(stlFileNames.fileName);
                if (loadedMesh != null)
                {
                    AxisAlignedBoundingBox aabb     = loadedMesh.GetAxisAlignedBoundingBox();
                    RectangleDouble        bounds2D = new RectangleDouble(aabb.minXYZ.x, aabb.minXYZ.y, aabb.maxXYZ.x, aabb.maxXYZ.y);
                    double widthInMM   = bounds2D.Width + PartMarginMM * 2;
                    double textSpaceMM = 5;
                    double heightMM    = textSpaceMM + bounds2D.Height + PartMarginMM * 2;

                    TypeFacePrinter typeFacePrinter = new TypeFacePrinter(stlFileNames.presentationName, 28, Vector2.Zero, Justification.Center, Baseline.BoundsCenter);
                    double          sizeOfNameX     = typeFacePrinter.GetSize().x + PartMarginPixels * 2;
                    Vector2         sizeOfRender    = new Vector2(widthInMM * PixelPerMM, heightMM * PixelPerMM);

                    ImageBuffer imageOfPart = new ImageBuffer((int)(Math.Max(sizeOfNameX, sizeOfRender.x)), (int)(sizeOfRender.y), 32, new BlenderBGRA());
                    typeFacePrinter.Origin = new Vector2(imageOfPart.Width / 2, (textSpaceMM / 2) * PixelPerMM);

                    Graphics2D partGraphics2D = imageOfPart.NewGraphics2D();

                    RectangleDouble rectBounds  = new RectangleDouble(0, 0, imageOfPart.Width, imageOfPart.Height);
                    double          strokeWidth = .5 * PixelPerMM;
                    rectBounds.Inflate(-strokeWidth / 2);
                    RoundedRect rect = new RoundedRect(rectBounds, PartMarginMM * PixelPerMM);
                    partGraphics2D.Render(rect, RGBA_Bytes.LightGray);
                    Stroke rectOutline = new Stroke(rect, strokeWidth);
                    partGraphics2D.Render(rectOutline, RGBA_Bytes.DarkGray);

                    PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partGraphics2D, loadedMesh, new Vector2(-bounds2D.Left + PartMarginMM, -bounds2D.Bottom + textSpaceMM + PartMarginMM), PixelPerMM, RGBA_Bytes.Black);
                    partGraphics2D.Render(typeFacePrinter, RGBA_Bytes.Black);

                    partImagesToPrint.Add(new PartImage(imageOfPart));
                }
                countThatHaveBeenSaved++;
                if (UpdateRemainingItems != null)
                {
                    UpdateRemainingItems(this, new StringEventArgs(Path.GetFileName(stlFileNames.presentationName)));
                }
            }

            partImagesToPrint.Sort(BiggestToLittlestImages);

            PdfDocument document = new PdfDocument();

            document.Info.Title    = "MatterHackers Parts Sheet";
            document.Info.Author   = "MatterHackers Inc.";
            document.Info.Subject  = "This is a list of the parts that are in a queue from MatterControl.";
            document.Info.Keywords = "MatterControl, STL, 3D Printing";

            int  nextPartToPrintIndex = 0;
            int  plateNumber          = 1;
            bool done = false;

            while (!done && nextPartToPrintIndex < partImagesToPrint.Count)
            {
                PdfPage pdfPage = document.AddPage();
                CreateOnePage(plateNumber++, ref nextPartToPrintIndex, pdfPage);
            }
            try
            {
                // save the final document
                document.Save(pathAndFileToSaveTo);
                // Now try and open the document. This will lanch whatever PDF viewer is on the system and ask it
                // to show the file (at least on Windows).
                Process.Start(pathAndFileToSaveTo);
            }
            catch (Exception)
            {
            }

            OnDoneSaving();
            currentlySaving = false;
        }
예제 #42
0
        private void drawWithBeganPoint(Point point)
        {
            DoodleModel model = new DoodleModel();

            model.points.Add(new DoodlePoint(getLogicPoint(point)));
            model.drawType  = drawType;
            model.lineColor = lineColor;
            model.lineWidth = lineWidth;
            doodleModels.Add(model);

            switch (model.drawType)
            {
            case DoodleEnumType.eraser:
            {
                if (doodleCanvas is InkCanvas)
                {
                    double eraserWidth = getEraserWidth();
                    eraserPointList = new List <Point>();
                    eraserPointList.Add(point);
                    doodleCanvas.Strokes.Erase(eraserPointList, new RectangleStylusShape(eraserWidth, eraserWidth));
                }
            }
            break;

            case DoodleEnumType.draw:
            {
                if (doodleCanvas is InkCanvas)
                {
                    DrawingAttributes attributes = new DrawingAttributes();
                    attributes.Color = getColor(lineColor);
                    attributes.Width = attributes.Height = getBrushWidth(lineWidth);

                    List <Point> pointList = new List <Point>();
                    pointList.Add(point);

                    Stroke s = new Stroke(new StylusPointCollection(pointList), attributes);
                    doodleCanvas.Strokes.Add(s);
                    stroke = s;
                }
                else if (doodleCanvas is Canvas)
                {
                    Path path = new Path()
                    {
                        StrokeThickness = getBrushWidth(lineWidth),
                        Stroke          = getBrushColor(lineColor)
                    };
                    doodleCanvas.Children.Add(path);
                    element = path;
                }
            }
            break;

            case DoodleEnumType.rect:
            {
                Rectangle rect = new Rectangle()
                {
                    Margin          = new Thickness(point.X, point.Y, 0, 0),
                    Width           = 0,
                    Height          = 0,
                    StrokeThickness = getBrushWidth(lineWidth),
                    Stroke          = getBrushColor(lineColor)
                };
                doodleCanvas.Children.Add(rect);
                element = rect;
            }
            break;

            case DoodleEnumType.line:
            {
                Line line = new Line()
                {
                    X1 = point.X,
                    Y1 = point.Y,
                    X2 = point.X,
                    Y2 = point.Y,
                    StrokeThickness = getBrushWidth(lineWidth),
                    Stroke          = getBrushColor(lineColor)
                };

                doodleCanvas.Children.Add(line);
                element = line;
            }
            break;

            case DoodleEnumType.circle:
            {
                Ellipse circle = new Ellipse()
                {
                    Margin          = new Thickness(point.X, point.Y, 0, 0),
                    Width           = 0,
                    Height          = 0,
                    StrokeThickness = getBrushWidth(lineWidth),
                    Stroke          = getBrushColor(lineColor)
                };
                doodleCanvas.Children.Add(circle);
                element = circle;
            }
            break;

            case DoodleEnumType.arrow:
            {
                Arrow arrow = new Arrow()
                {
                    X1 = point.X,
                    Y1 = point.Y,
                    X2 = point.X,
                    Y2 = point.Y,
                    StrokeThickness = getBrushWidth(lineWidth),
                    Stroke          = getBrushColor(lineColor)
                };
                doodleCanvas.Children.Add(arrow);
                element = arrow;
            }
            break;

            case DoodleEnumType.cube:
            {
                DoodleCube cone = new DoodleCube(point, point, getBrushWidth(lineWidth), getBrushColor(lineColor));
                doodleCanvas.Children.Add(cone);
                element = cone;
            }
            break;

            case DoodleEnumType.cylinder:
            {
                DoodleCylinder cone = new DoodleCylinder(point, point, getBrushWidth(lineWidth), getBrushColor(lineColor));
                doodleCanvas.Children.Add(cone);
                element = cone;
            }
            break;

            case DoodleEnumType.cone:
            {
                DoodleCone cone = new DoodleCone(point, point, getBrushWidth(lineWidth), getBrushColor(lineColor));
                doodleCanvas.Children.Add(cone);
                element = cone;
            }
            break;

            default:
                break;
            }
        }
예제 #43
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            {
                ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());
                Graphics2D  subGraphics2D   = widgetsSubImage.NewGraphics2D();

                subGraphics2D.Clear(new RGBA_Bytes(255, 255, 255));
                for (int y = 0; y < MomsGame.GetHeight(); y++)
                {
                    for (int x = 0; x < MomsGame.GetWidth(); x++)
                    {
                        DrawCard(subGraphics2D, x, y);
                    }
                }

                String     whatToDo       = "Select any open space marked with an 'O'";
                RGBA_Bytes backFillCollor = new RGBA_Bytes(0xe1, 0xe0, 0xf6);

                if (MomsGame.GetWaitingForKing())
                {
                    backFillCollor = new RGBA_Bytes(0xf8, 0x89, 0x78);
                    whatToDo       = "Select a King for the hole";
                }
                else if (MomsGame.IsSolved())
                {
                    backFillCollor = new RGBA_Bytes(0xf8, 0x89, 0x78);
                    whatToDo       = "You win!";
                }
                else if (!MomsGame.MoveAvailable())
                {
                    backFillCollor = new RGBA_Bytes(0xf8, 0x89, 0x78);
                    whatToDo       = "No more moves! Shuffle to continue.";
                }

                if (whatToDo != null)
                {
                    TextWidget      stringToDraw = new TextWidget(whatToDo, 12);
                    RectangleDouble Size         = stringToDraw.Printer.LocalBounds;
                    double          TextX        = m_BoardX + CARD_WIDTH * 4;
                    double          TextY        = m_BoardY - 34;
                    RoundedRect     BackFill     = new RoundedRect(Size.Left - 6, Size.Bottom - 3, Size.Right + 6, Size.Top + 6, 3);
                    Stroke          BackBorder   = new Stroke(BackFill);
                    BackBorder.width(2);

                    subGraphics2D.SetTransform(Affine.NewTranslation(TextX, TextY));
                    subGraphics2D.Render(BackFill, backFillCollor);
                    subGraphics2D.Render(BackBorder, new RGBA_Bytes(0, 0, 0));
                    subGraphics2D.Render(stringToDraw.Printer, new RGBA_Bytes(0, 0, 0));
                }

                String ShufflesString;
                ShufflesString  = "Number of shuffles so far = ";
                ShufflesString += MomsGame.GetNumShuffles().ToString();

                TextWidget shuffelStringToDraw = new TextWidget(ShufflesString, 12);
                subGraphics2D.SetTransform(Affine.NewTranslation(m_BoardX, 350));
                subGraphics2D.Render(shuffelStringToDraw.Printer, new RGBA_Bytes(0, 0, 0));

                subGraphics2D.SetTransform(Affine.NewIdentity());
            }
            base.OnDraw(graphics2D);
        }
예제 #44
0
        public void DrawCard(Graphics2D DestGraphics, int CardX, int CardY)
        {
            double StartX = CardX * CARD_WIDTH + m_BoardX;
            double StartY = CardY * CARD_HEIGHT + m_BoardY;

            RectangleDouble CardBounds           = new RectangleDouble(StartX + 1.5, StartY + 1.5, StartX + CARD_WIDTH - 1.5, StartY + CARD_HEIGHT - 1.5);
            RoundedRect     CardFiledRoundedRect = new RoundedRect(CardBounds.Left, CardBounds.Bottom, CardBounds.Right, CardBounds.Top, 5);
            Stroke          CardRectBounds       = new Stroke(CardFiledRoundedRect);

            CardRectBounds.width(1);

            CCard  Card        = MomsGame.GetCard(CardX, CardY);
            int    CardValue   = Card.GetValue();
            int    CardSuit    = Card.GetSuit();
            String ValueString = "Uninitialized ";

            if (CardValue > (int)CCard.CARD_VALUE.VALUE_ACE)
            {
                DestGraphics.SetTransform(Affine.NewIdentity());
                DestGraphics.Render(CardRectBounds, new RGBA_Bytes(0, 0, 0));
                if (CardValue > 10)
                {
                    switch (CardValue)
                    {
                    case 11:
                        ValueString = "J";
                        break;

                    case 12:
                        ValueString = "Q";
                        break;

                    case 13:
                        ValueString = "K";
                        break;

                    default:
                        throw new Exception();
                    }
                }
                else
                {
                    ValueString = CardValue.ToString();
                }

                TextWidget      stringToDraw = new TextWidget(ValueString, 10);
                RectangleDouble textBounds   = stringToDraw.Printer.LocalBounds;
                DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + 2, CardBounds.Top - 8 - textBounds.Height / 2));
                DestGraphics.Render(stringToDraw.Printer, new RGBA_Bytes(0, 0, 0));
                DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Right - 4 - textBounds.Width, CardBounds.Bottom + 9 - textBounds.Height / 2));
                DestGraphics.Render(stringToDraw.Printer, new RGBA_Bytes(0, 0, 0));

                RGBA_Bytes    SuitColor = new RGBA_Bytes(0, 0, 0);
                IVertexSource suitPath  = new PathStorage();

                switch (CardSuit)
                {
                case (int)CCard.CARD_SUIT.SUIT_DIAMOND:
                {
                    SuitColor = new RGBA_Bytes(0xFF, 0x11, 0x11);
                    suitPath  = m_DiamondShape;
                }
                break;

                case (int)CCard.CARD_SUIT.SUIT_CLUB:
                {
                    SuitColor = new RGBA_Bytes(0x22, 0x22, 0x66);
                    suitPath  = new FlattenCurves(m_ClubShape);
                }
                break;

                case (int)CCard.CARD_SUIT.SUIT_HEART:
                {
                    SuitColor = new RGBA_Bytes(0xBB, 0x00, 0x00);
                    suitPath  = new FlattenCurves(m_HeartShape);
                }
                break;

                case (int)CCard.CARD_SUIT.SUIT_SPADE:
                {
                    SuitColor = new RGBA_Bytes(0x00, 0x00, 0x00);
                    suitPath  = new FlattenCurves(m_SpadeShape);
                }
                break;

                default:
                    break;
                }

                textBounds = stringToDraw.Printer.LocalBounds;

                if (CardValue < 11)
                {
                    for (int CurDot = 0; CurDot < CardValue; CurDot++)
                    {
                        double OffsetX = 0, OffsetY = 0;
                        GetSuitOffset(ref OffsetX, ref OffsetY, CurDot, (int)CardValue);
                        DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + OffsetX, CardBounds.Bottom + OffsetY));
                        DestGraphics.Render(suitPath, SuitColor);
                    }
                }
                else
                {
                    DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + 9, CardBounds.Bottom + 17));
                    DestGraphics.Render(suitPath, SuitColor);
                    DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Right - 9, CardBounds.Top - 17));
                    DestGraphics.Render(suitPath, SuitColor);

                    stringToDraw = new TextWidget(ValueString, 22);
                    textBounds   = stringToDraw.Printer.LocalBounds;
                    DestGraphics.SetTransform(Affine.NewTranslation(-1 + CardBounds.Left + CardBounds.Width / 2 - textBounds.Width / 2, CardBounds.Bottom + CardBounds.Height / 2 - textBounds.Height / 2));
                    DestGraphics.Render(stringToDraw.Printer, new RGBA_Bytes(0, 0, 0));
                }
            }
            else
            {
                RGBA_Bytes HoleColor = new RGBA_Bytes(0, 0, 0);

                String OpenSpaceString;

                if (!MomsGame.SpaceIsClickable(CardX, CardY))
                {
                    HoleColor       = new RGBA_Bytes(0xf8, 0xe2, 0xe8);
                    OpenSpaceString = "X";
                }
                else
                {
                    HoleColor       = new RGBA_Bytes(0xe1, 0xe0, 0xf6);
                    OpenSpaceString = "O";
                }

                TextWidget      stringToDraw = new TextWidget(OpenSpaceString, 35);
                RectangleDouble Size         = stringToDraw.Printer.LocalBounds;
                DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + CardBounds.Width / 2 - Size.Width / 2, CardBounds.Bottom + CardBounds.Height / 2 - Size.Height / 2));
                DestGraphics.Render(stringToDraw.Printer, HoleColor);
            }
        }
        private void ZoomAndRotate(GraphicLinkNode gln, MyGraphic relativeGraphic)
        {
            Matrix m1        = new Matrix();
            Matrix m2        = new Matrix();
            Matrix m3        = new Matrix();
            double zoomScale = 1;
            double preX1     = ((System.Windows.Shapes.Line)relativeGraphic.Shape).X1;
            double preY1     = ((System.Windows.Shapes.Line)relativeGraphic.Shape).Y1;
            double preX2     = ((System.Windows.Shapes.Line)relativeGraphic.Shape).X2;
            double preY2     = ((System.Windows.Shapes.Line)relativeGraphic.Shape).Y2;
            double nowX1     = preX1 + offset_x;
            double nowY1     = preY1 + offset_y;
            double nowX2     = preX2 + offset_x;
            double nowY2     = preY2 + offset_y;
            double preLength = MathTool.getInstance().distanceP2P(new StylusPoint(preX2, preY2), new StylusPoint(preX1, preY1));
            double nowLength;

            if (gln.Rule == "HeadIntersect")//修改第一个点
            {
                ((System.Windows.Shapes.Line)relativeGraphic.Shape).X1 = nowX1;
                ((System.Windows.Shapes.Line)relativeGraphic.Shape).Y1 = nowY1;

                if (relativeGraphic.ShapeType == "arrow" || relativeGraphic.ShapeType == "loopArc")
                {
                    double angle1 = MathTool.getInstance().getAngleP2P(new StylusPoint(preX1, preY1), new StylusPoint(preX2, preY2));
                    double angle2 = MathTool.getInstance().getAngleP2P(new StylusPoint(nowX1, nowY1), new StylusPoint(preX2, preY2));
                    double angle  = angle2 - angle1;//旋转角度

                    nowLength = MathTool.getInstance().distanceP2P(new StylusPoint(preX2, preY2), new StylusPoint(nowX1, nowY1));

                    if (preLength == 0 || nowLength == 0)
                    {
                        zoomScale = 1;
                    }
                    else
                    {
                        zoomScale = nowLength / preLength;
                    }
                    m1.RotateAt(-angle, preX2, preY2);
                    m2.ScaleAt(zoomScale, zoomScale, preX2, preY2);
                    Matrix m = m1 * m2;

                    relativeGraphic.Strokes[0].Transform(m, true);
                    relativeGraphic.Strokes[0].DrawingAttributes.StylusTipTransform = new Matrix(1, 0, 0, 1, 0, 0);
                    relativeGraphic.Strokes[1].Transform(m1, true);

                    if (relativeGraphic.Strokes.Count == 3)//笔迹数为3时
                    {
                        relativeGraphic.Strokes[2].Transform(m1, true);
                    }
                }
            }
            else if (gln.Rule == "TailIntersect")//修改最后点
            {
                ((System.Windows.Shapes.Line)relativeGraphic.Shape).X2 = nowX2;
                ((System.Windows.Shapes.Line)relativeGraphic.Shape).Y2 = nowY2;

                if (relativeGraphic.ShapeType == "arrow" || relativeGraphic.ShapeType == "loopArc")
                {
                    double angle1 = MathTool.getInstance().getAngleP2P(new StylusPoint(preX2, preY2), new StylusPoint(preX1, preY1));
                    double angle2 = MathTool.getInstance().getAngleP2P(new StylusPoint(nowX2, nowY2), new StylusPoint(preX1, preY1));
                    double angle  = angle2 - angle1;//旋转角度

                    nowLength = MathTool.getInstance().distanceP2P(new StylusPoint(nowX2, nowY2), new StylusPoint(preX1, preY1));

                    if (preLength == 0 || nowLength == 0)
                    {
                        zoomScale = 1;
                    }
                    else
                    {
                        zoomScale = nowLength / preLength;
                    }

                    m1.RotateAt(-angle, preX1, preY1);
                    relativeGraphic.Strokes[0].Transform(m1, false);
                    m2.ScaleAt(zoomScale, zoomScale, preX1, preY1);
                    relativeGraphic.Strokes[0].Transform(m2, false);

                    //************************************
                    //用于计算箭头的头部移动位置
                    StylusPoint           p  = new StylusPoint(preX2, preY2);
                    StylusPointCollection ps = new StylusPointCollection();
                    ps.Add(p);
                    Stroke s = new Stroke(ps);
                    //*************************************
                    //箭的头部只旋转和移动,不缩放
                    if (relativeGraphic.Strokes.Count == 2)//笔迹数为2时
                    {
                        relativeGraphic.Strokes[1].Transform(m1, false);
                        s.Transform(m1, false);
                        m3.Translate(nowX2 - s.StylusPoints[0].X, nowY2 - s.StylusPoints[0].Y);
                        relativeGraphic.Strokes[1].Transform(m3, false);
                    }
                    else if (relativeGraphic.Strokes.Count == 3)//笔迹数为3时
                    {
                        relativeGraphic.Strokes[1].Transform(m1, false);
                        relativeGraphic.Strokes[2].Transform(m1, false);
                        s.Transform(m1, false);
                        m3.Translate(nowX2 - s.StylusPoints[0].X, nowY2 - s.StylusPoints[0].Y);
                        relativeGraphic.Strokes[1].Transform(m3, false);
                        relativeGraphic.Strokes[2].Transform(m3, false);
                    }
                }
            }
        }
예제 #46
0
        private void drawWithMovePoint(Point point)
        {
            DoodleModel model = (DoodleModel)doodleModels[doodleModels.Count - 1];

            model.points.Add(new DoodlePoint(getLogicPoint(point)));

            switch (model.drawType)
            {
            case DoodleEnumType.eraser:
            {
                if (doodleCanvas is InkCanvas)
                {
                    double eraserWidth = getEraserWidth();
                    eraserPointList.Add(point);
                    if (eraserPointList.Count > 5)
                    {
                        eraserPointList.RemoveAt(0);
                    }
                    doodleCanvas.Strokes.Erase(eraserPointList, new RectangleStylusShape(eraserWidth, eraserWidth));
                }
            }
            break;

            case DoodleEnumType.draw:
            {
                if (doodleCanvas is InkCanvas)
                {
                    List <Point> pointList = new List <Point>();
                    pointList.Add(point);

                    Stroke s = stroke;
                    s.StylusPoints.Add(new StylusPointCollection(pointList));
                }
                else if (doodleCanvas is Canvas)
                {
                    Path path = (Path)element;
                    doodleCanvas.Children.Remove(path);
                    PathFigure pathFigure = new PathFigure();
                    pathFigure.StartPoint = getLocalPoint(model.points[0].GetPoint);

                    List <Point> controls = new List <Point>();
                    for (int i = 0; i < model.points.Count; i++)
                    {
                        controls.AddRange(BezierControlPoints(model.points, i));
                    }
                    for (int i = 1; i < model.points.Count; i++)
                    {
                        BezierSegment bs = new BezierSegment(controls[i * 2 - 1], controls[i * 2], getLocalPoint(model.points[i].GetPoint), true);
                        bs.IsSmoothJoin = true;
                        pathFigure.Segments.Add(bs);
                    }
                    PathFigureCollection pathFigureCollection = new PathFigureCollection();
                    pathFigureCollection.Add(pathFigure);
                    PathGeometry pathGeometry = new PathGeometry(pathFigureCollection);
                    path.Data = pathGeometry;
                    doodleCanvas.Children.Add(path);
                }
            }
            break;

            case DoodleEnumType.rect:
            {
                Point     startPoint = getLocalPoint(model.startPoint.GetPoint);
                Rectangle rect       = (Rectangle)element;
                rect.Margin = new Thickness(getSmallX(startPoint, point), getSmallY(startPoint, point), 0, 0);
                rect.Width  = Math.Abs(startPoint.X - point.X);
                rect.Height = Math.Abs(startPoint.Y - point.Y);
            }
            break;

            case DoodleEnumType.line:
            {
                Point startPoint = getLocalPoint(model.startPoint.GetPoint);
                Line  line       = (Line)element;
                line.X1 = startPoint.X;
                line.Y1 = startPoint.Y;
                line.X2 = point.X;
                line.Y2 = point.Y;
            }
            break;

            case DoodleEnumType.circle:
            {
                Point   startPoint = getLocalPoint(model.startPoint.GetPoint);
                Ellipse circle     = (Ellipse)element;
                circle.Margin = new Thickness(getSmallX(startPoint, point), getSmallY(startPoint, point), 0, 0);
                circle.Width  = Math.Abs(startPoint.X - point.X);
                circle.Height = Math.Abs(startPoint.Y - point.Y);
            }
            break;

            case DoodleEnumType.arrow:
            {
                Point startPoint = getLocalPoint(model.startPoint.GetPoint);
                Arrow arrow      = (Arrow)element;
                arrow.X1 = startPoint.X;
                arrow.Y1 = startPoint.Y;
                arrow.X2 = point.X;
                arrow.Y2 = point.Y;
            }
            break;

            case DoodleEnumType.cube:
            {
                Point      startPoint = getLocalPoint(model.startPoint.GetPoint);
                DoodleCube cone       = (DoodleCube)element;
                cone.SetPoints(startPoint, point);
            }
            break;

            case DoodleEnumType.cylinder:
            {
                Point          startPoint = getLocalPoint(model.startPoint.GetPoint);
                DoodleCylinder cone       = (DoodleCylinder)element;
                cone.SetPoints(startPoint, point);
            }
            break;

            case DoodleEnumType.cone:
            {
                Point      startPoint = getLocalPoint(model.startPoint.GetPoint);
                DoodleCone cone       = (DoodleCone)element;
                cone.SetPoints(startPoint, point);
            }
            break;

            default:
                break;
            }
        }
예제 #47
0
        //動作を進める
        private void goButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //MessageBox.Show(counter + "操作目 : " + learningLogs[counter].GetStrokeId() + "本目を" + learningLogs[counter].GetBehavior() + "する");

                //一次元目がallなら全消去なのですべて消去する
                if (learningLogs[counter].GetStrokeId().Equals("all"))
                {
                    inkCanvas1.Strokes.Clear();
                }

                //二次元目がdrawのとき
                else if (learningLogs[counter].GetBehavior().Equals("draw"))
                {
                    //ターゲットとなるストロークのidを取ってくる
                    int x = Int16.Parse(learningLogs[counter].GetStrokeId());

                    //strokeLiesの中から該当するidのストロークを探す
                    StrokeLine sl = strokeLines[x];

                    //再描画
                    //線の色、幅を取得
                    DrawingAttributes DA = new DrawingAttributes();
                    DA.Color  = sl.GetColor();
                    DA.Width  = sl.GetWidth();
                    DA.Height = sl.GetWidth();
                    inkCanvas1.DefaultDrawingAttributes = DA;

                    //点の情報を集める
                    StylusPointCollection spc = new StylusPointCollection();
                    for (int j = 0; j < sl.GetPoints().Count; j++)
                    {
                        spc.Add(new StylusPoint(sl.GetPoints()[j].X, sl.GetPoints()[j].Y));
                    }
                    Stroke stroke = new Stroke(spc, DA);
                    inkCanvas1.Strokes.Add(stroke);
                }


                //二次元目がeraseのとき
                else if (learningLogs[counter].GetBehavior().Equals("erase"))
                {
                    //ターゲットとなるストロークのidを取ってくる
                    int x = Int16.Parse(learningLogs[counter].GetStrokeId());

                    //strokeLiesの中から該当するidのストロークを探す
                    StrokeLine sl;
                    for (int i = 0; i < strokeLines.Count; i++)
                    {
                        if (strokeLines[i].GetId() == x)
                        {
                            sl = strokeLines[x];
                            break;
                        }
                    }

                    //いったん全部消し、当該idまで、再描画する
                    inkCanvas1.Strokes.Clear();
                    drawAll(x);
                }
                counter++;
            }
            catch
            {
                MessageBox.Show("最後の動作です。");
            }
        }
예제 #48
0
 public Task StrokeAsync(string subscriberId, Stroke stroke)
 {
     return(_broadcastService.BroadcastAsync(subscriberId, stroke));
 }
예제 #49
0
 public static void SquaredSmoothCircleBrush(Stroke stroke0, int mapSize, float[,] map)
 {
     SquaredCircleBrush(stroke0, mapSize, map, (stroke1, currentValue) => currentValue + Mathf.Lerp(1, 0, stroke1.CurrentPixel.GetNormalizedDistanceToCenter()));
 }
예제 #50
0
        /// <inheritdoc cref="ChartElement{TDrawingContext}.Measure(Chart{TDrawingContext})"/>
        public override void Measure(Chart <TDrawingContext> chart)
        {
            var cartesianChart = (CartesianChart <TDrawingContext>)chart;
            var primaryAxis    = cartesianChart.YAxes[ScalesYAt];
            var secondaryAxis  = cartesianChart.XAxes[ScalesXAt];

            var drawLocation           = cartesianChart.DrawMarginLocation;
            var drawMarginSize         = cartesianChart.DrawMarginSize;
            var secondaryScale         = new Scaler(drawLocation, drawMarginSize, primaryAxis);
            var previousSecondaryScale =
                primaryAxis.PreviousDataBounds is null ? null : new Scaler(drawLocation, drawMarginSize, primaryAxis);
            var primaryScale = new Scaler(drawLocation, drawMarginSize, secondaryAxis);

            var uw  = secondaryScale.MeasureInPixels(secondaryAxis.UnitWidth); //secondaryScale.ToPixels(1f) - secondaryScale.ToPixels(0f);
            var uwm = 0.5f * uw;
            var sw  = Stroke?.StrokeThickness ?? 0;
            var p   = primaryScale.ToPixels(pivot);

            var pos   = cartesianChart.SeriesContext.GetStackedColumnPostion(this);
            var count = cartesianChart.SeriesContext.GetStackedColumnSeriesCount();
            var cp    = 0f;

            if (count > 1)
            {
                uw /= count;
                uwm = 0.5f * uw;
                cp  = (pos - count / 2f) * uw + uwm;
            }

            if (uw > MaxBarWidth)
            {
                uw  = (float)MaxBarWidth;
                uwm = uw / 2f;
            }

            var actualZIndex = ZIndex == 0 ? ((ISeries)this).SeriesId : ZIndex;

            if (Fill is not null)
            {
                Fill.ZIndex = actualZIndex + 0.1;
                Fill.SetClipRectangle(cartesianChart.Canvas, new RectangleF(drawLocation, drawMarginSize));
                cartesianChart.Canvas.AddDrawableTask(Fill);
            }
            if (Stroke is not null)
            {
                Stroke.ZIndex = actualZIndex + 0.2;
                Stroke.SetClipRectangle(cartesianChart.Canvas, new RectangleF(drawLocation, drawMarginSize));
                cartesianChart.Canvas.AddDrawableTask(Stroke);
            }
            if (DataLabelsPaint is not null)
            {
                DataLabelsPaint.ZIndex = actualZIndex + 0.3;
                DataLabelsPaint.SetClipRectangle(cartesianChart.Canvas, new RectangleF(drawLocation, drawMarginSize));
                cartesianChart.Canvas.AddDrawableTask(DataLabelsPaint);
            }
            var dls            = (float)DataLabelsSize;
            var toDeletePoints = new HashSet <ChartPoint>(everFetched);

            var stacker = cartesianChart.SeriesContext.GetStackPosition(this, GetStackGroup());

            if (stacker is null)
            {
                throw new NullReferenceException("Unexpected null stacker");
            }

            var rx = (float)Rx;
            var ry = (float)Ry;

            foreach (var point in Fetch(cartesianChart))
            {
                var visual    = point.Context.Visual as TVisual;
                var secondary = secondaryScale.ToPixels(point.SecondaryValue);

                if (point.IsNull)
                {
                    if (visual is not null)
                    {
                        visual.X                 = p;
                        visual.Y                 = secondary - uwm + cp;
                        visual.Width             = 0;
                        visual.Height            = uw;
                        visual.RemoveOnCompleted = true;
                        point.Context.Visual     = null;
                    }
                    continue;
                }

                if (visual is null)
                {
                    var yi = secondary - uwm + cp;
                    if (previousSecondaryScale is not null)
                    {
                        yi = previousSecondaryScale.ToPixels(point.SecondaryValue) - uwm + cp;
                    }

                    var r = new TVisual
                    {
                        X      = p,
                        Y      = yi,
                        Width  = 0,
                        Height = uw,
                        Rx     = rx,
                        Ry     = ry
                    };

                    visual = r;
                    point.Context.Visual = visual;
                    OnPointCreated(point);
                    r.CompleteAllTransitions();

                    _ = everFetched.Add(point);
                }

                if (Fill is not null)
                {
                    Fill.AddGeometryToPaintTask(cartesianChart.Canvas, visual);
                }
                if (Stroke is not null)
                {
                    Stroke.AddGeometryToPaintTask(cartesianChart.Canvas, visual);
                }

                var sizedGeometry = visual;

                var sy       = stacker.GetStack(point);
                var primaryI = primaryScale.ToPixels(sy.Start);
                var primaryJ = primaryScale.ToPixels(sy.End);
                var y        = secondary - uwm + cp;

                sizedGeometry.X                 = primaryJ;
                sizedGeometry.Y                 = y;
                sizedGeometry.Width             = primaryI - primaryJ;
                sizedGeometry.Height            = uw;
                sizedGeometry.Rx                = rx;
                sizedGeometry.Ry                = ry;
                sizedGeometry.RemoveOnCompleted = false;

                point.Context.HoverArea = new RectangleHoverArea().SetDimensions(secondary - uwm + cp, primaryJ, uw, primaryI - primaryJ);

                OnPointMeasured(point);
                _ = toDeletePoints.Remove(point);

                if (DataLabelsPaint is not null)
                {
                    var label = (TLabel?)point.Context.Label;

                    if (label is null)
                    {
                        var l = new TLabel {
                            X = secondary - uwm + cp, Y = p
                        };

                        _ = l.TransitionateProperties(nameof(l.X), nameof(l.Y))
                            .WithAnimation(animation =>
                                           animation
                                           .WithDuration(AnimationsSpeed ?? cartesianChart.AnimationsSpeed)
                                           .WithEasingFunction(EasingFunction ?? cartesianChart.EasingFunction));

                        l.CompleteAllTransitions();
                        label = l;
                        point.Context.Label = label;
                    }

                    DataLabelsPaint.AddGeometryToPaintTask(cartesianChart.Canvas, label);
                    label.Text     = DataLabelsFormatter(new TypedChartPoint <TModel, TVisual, TLabel, TDrawingContext>(point));
                    label.TextSize = dls;
                    label.Padding  = DataLabelsPadding;
                    var labelPosition = GetLabelPosition(
                        primaryJ, y, primaryI - primaryJ, uw, label.Measure(DataLabelsPaint), DataLabelsPosition, SeriesProperties, point.PrimaryValue > Pivot);
                    label.X = labelPosition.X;
                    label.Y = labelPosition.Y;
                }
            }

            foreach (var point in toDeletePoints)
            {
                if (point.Context.Chart != cartesianChart.View)
                {
                    continue;
                }
                SoftDeletePoint(point, primaryScale, secondaryScale);
                _ = everFetched.Remove(point);
            }
        }
예제 #51
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            GammaLookUpTable    gamma               = new GammaLookUpTable(m_gamma.Value);
            IRecieveBlenderByte NormalBlender       = new BlenderBGRA();
            IRecieveBlenderByte GammaBlender        = new BlenderGammaBGRA(gamma);
            ImageBuffer         rasterNormal        = new ImageBuffer(NewGraphics2D().DestImage, NormalBlender);
            ImageBuffer         rasterGamma         = new ImageBuffer(NewGraphics2D().DestImage, GammaBlender);
            ImageClippingProxy  clippingProxyNormal = new ImageClippingProxy(rasterNormal);
            ImageClippingProxy  clippingProxyGamma  = new ImageClippingProxy(rasterGamma);

            clippingProxyNormal.clear(new ColorF(0, 0, 0));

            ScanlineRasterizer   ras = new ScanlineRasterizer();
            ScanlineCachePacked8 sl  = new ScanlineCachePacked8();

            VertexSource.Ellipse e = new VertexSource.Ellipse();

            // TODO: If you drag the control circles below the bottom of the window we get an exception.  This does not happen in AGG.
            // It needs to be debugged.  Turning on clipping fixes it.  But standard agg works without clipping.  Could be a bigger problem than this.
            //ras.clip_box(0, 0, width(), height());

            // Render two "control" circles
            e.init(m_x[0], m_y[0], 3, 3, 16);
            ras.add_path(e);
            ScanlineRenderer scanlineRenderer = new ScanlineRenderer();

            scanlineRenderer.RenderSolid(clippingProxyNormal, ras, sl, new Color(127, 127, 127));
            e.init(m_x[1], m_y[1], 3, 3, 16);
            ras.add_path(e);
            scanlineRenderer.RenderSolid(clippingProxyNormal, ras, sl, new Color(127, 127, 127));

            // Creating a rounded rectangle
            VertexSource.RoundedRect r = new VertexSource.RoundedRect(m_x[0], m_y[0], m_x[1], m_y[1], 10);
            r.normalize_radius();

            // Drawing as an outline
            Stroke p = new Stroke(r);

            p.Width = 1.0;
            ras.add_path(p);

            //Renderer.RenderSolid(clippingProxyGamma, ras, sl, new RGBA_Bytes(0, 0, 0));
            scanlineRenderer.RenderSolid(clippingProxyGamma, ras, sl, new Color(255, 1, 1));

            /*
             *              int i;
             *
             *              // radial line test
             *              //-------------------------
             *              dashed_line<rasterizer_type,
             *                                      renderer_scanline_type,
             *                                      scanline_type> dash(ras, ren_sl, sl);
             *
             *              double cx = width() / 2.0;
             *              double cy = height() / 2.0;
             *
             *              ren_sl.color(agg::rgba(1.0, 1.0, 1.0, 0.2));
             *              for(i = 180; i > 0; i--)
             *              {
             *                      double n = 2.0 * agg::pi * i / 180.0;
             *                      dash.draw(cx + min(cx, cy) * sin(n), cy + min(cx, cy) * cos(n),
             *                                        cx, cy,
             *                                        1.0, (i < 90) ? i : 0.0);
             *              }
             *
             *              typedef agg::gradient_x gradient_func_type;
             *              typedef agg::span_interpolator_linear<> interpolator_type;
             *              typedef agg::span_allocator<color_type> span_allocator_type;
             *              typedef agg::pod_auto_array<color_type, 256> color_array_type;
             *              typedef agg::span_gradient<color_type,
             *                                                                 interpolator_type,
             *                                                                 gradient_func_type,
             *                                                                 color_array_type> span_gradient_type;
             *
             *              typedef agg::renderer_scanline_aa<renderer_base_type,
             *                                                                                span_allocator_type,
             *                                                                                span_gradient_type> renderer_gradient_type;
             *
             *              gradient_func_type  gradient_func;                   // The gradient function
             *              agg::trans_affine   gradient_mtx;                    // Affine transformer
             *              interpolator_type   span_interpolator(gradient_mtx); // Span interpolator
             *              span_allocator_type span_allocator;                  // Span Allocator
             *              color_array_type    gradient_colors;                 // The gradient colors
             *              span_gradient_type  span_gradient(span_interpolator,
             *                                                                                gradient_func,
             *                                                                                gradient_colors,
             *                                                                                0, 100);
             *
             *              renderer_gradient_type ren_gradient(ren_base, span_allocator, span_gradient);
             *
             *              dashed_line<rasterizer_type,
             *                                      renderer_gradient_type,
             *                                      scanline_type> dash_gradient(ras, ren_gradient, sl);
             *
             *              double x1, y1, x2, y2;
             *
             *              for(i = 1; i <= 20; i++)
             *              {
             *                      ren_sl.color(agg::rgba(1,1,1));
             *
             *                      // integral point sizes 1..20
             *                      //----------------
             *                      agg::ellipse ell;
             *
             *                      ell.init(20 + i * (i + 1) + 0.5,
             *                                       20.5,
             *                                       i / 2.0,
             *                                       i / 2.0,
             *                                       8 + i);
             *                      ras.reset();
             *                      ras.add_path(ell);
             *                      agg::render_scanlines(ras, sl, ren_sl);
             *
             *                      // fractional point sizes 0..2
             *                      //----------------
             *                      ell.init(18 + i * 4 + 0.5, 33 + 0.5,
             *                                       i/20.0, i/20.0,
             *                                       8);
             *                      ras.reset();
             *                      ras.add_path(ell);
             *                      agg::render_scanlines(ras, sl, ren_sl);
             *
             *                      // fractional point positioning
             *                      //---------------
             *                      ell.init(18 + i * 4 + (i-1) / 10.0 + 0.5,
             *                                       27 + (i - 1) / 10.0 + 0.5,
             *                                       0.5, 0.5, 8);
             *                      ras.reset();
             *                      ras.add_path(ell);
             *                      agg::render_scanlines(ras, sl, ren_sl);
             *
             *                      // integral line widths 1..20
             *                      //----------------
             *                      fill_color_array(gradient_colors,
             *                                                       agg::rgba(1,1,1),
             *                                                       agg::rgba(i % 2, (i % 3) * 0.5, (i % 5) * 0.25));
             *
             *                      x1 = 20 + i* (i + 1);
             *                      y1 = 40.5;
             *                      x2 = 20 + i * (i + 1) + (i - 1) * 4;
             *                      y2 = 100.5;
             *                      calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx);
             *                      dash_gradient.draw(x1, y1, x2, y2, i, 0);
             *
             *                      fill_color_array(gradient_colors,
             *                                                       agg::rgba(1,0,0),
             *                                                       agg::rgba(0,0,1));
             *
             *                      // fractional line lengths H (red/blue)
             *                      //----------------
             *                      x1 = 17.5 + i * 4;
             *                      y1 = 107;
             *                      x2 = 17.5 + i * 4 + i/6.66666667;
             *                      y2 = 107;
             *                      calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx);
             *                      dash_gradient.draw(x1, y1, x2, y2, 1.0, 0);
             *
             *                      // fractional line lengths V (red/blue)
             *                      //---------------
             *                      x1 = 18 + i * 4;
             *                      y1 = 112.5;
             *                      x2 = 18 + i * 4;
             *                      y2 = 112.5 + i / 6.66666667;
             *                      calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx);
             *                      dash_gradient.draw(x1, y1, x2, y2, 1.0, 0);
             *
             *                      // fractional line positioning (red)
             *                      //---------------
             *                      fill_color_array(gradient_colors,
             *                                                       agg::rgba(1,0,0),
             *                                                       agg::rgba(1,1,1));
             *                      x1 = 21.5;
             *                      y1 = 120 + (i - 1) * 3.1;
             *                      x2 = 52.5;
             *                      y2 = 120 + (i - 1) * 3.1;
             *                      calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx);
             *                      dash_gradient.draw(x1, y1, x2, y2, 1.0, 0);
             *
             *                      // fractional line width 2..0 (green)
             *                      fill_color_array(gradient_colors,
             *                                                       agg::rgba(0,1,0),
             *                                                       agg::rgba(1,1,1));
             *                      x1 = 52.5;
             *                      y1 = 118 + i * 3;
             *                      x2 = 83.5;
             *                      y2 = 118 + i * 3;
             *                      calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx);
             *                      dash_gradient.draw(x1, y1, x2, y2, 2.0 - (i - 1) / 10.0, 0);
             *
             *                      // stippled fractional width 2..0 (blue)
             *                      fill_color_array(gradient_colors,
             *                                                       agg::rgba(0,0,1),
             *                                                       agg::rgba(1,1,1));
             *                      x1 = 83.5;
             *                      y1 = 119 + i * 3;
             *                      x2 = 114.5;
             *                      y2 = 119 + i * 3;
             *                      calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx);
             *                      dash_gradient.draw(x1, y1, x2, y2, 2.0 - (i - 1) / 10.0, 3.0);
             *
             *                      ren_sl.color(agg::rgba(1,1,1));
             *                      if(i <= 10)
             *                      {
             *                              // integral line width, horz aligned (mipmap test)
             *                              //-------------------
             *                              dash.draw(125.5, 119.5 + (i + 2) * (i / 2.0),
             *                                                135.5, 119.5 + (i + 2) * (i / 2.0),
             *                                                i, 0.0);
             *                      }
             *
             *                      // fractional line width 0..2, 1 px H
             *                      //-----------------
             *                      dash.draw(17.5 + i * 4, 192, 18.5 + i * 4, 192, i / 10.0, 0);
             *
             *                      // fractional line positioning, 1 px H
             *                      //-----------------
             *                      dash.draw(17.5 + i * 4 + (i - 1) / 10.0, 186,
             *                                        18.5 + i * 4 + (i - 1) / 10.0, 186,
             *                                        1.0, 0);
             *              }
             *
             *              // Triangles
             *              //---------------
             *              for (int i = 1; i <= 13; i++)
             *              {
             *                      fill_color_array(gradient_colors,
             *                                                       agg::rgba(1,1,1),
             *                                                       agg::rgba(i % 2, (i % 3) * 0.5, (i % 5) * 0.25));
             *                      calc_linear_gradient_transform(width()  - 150,
             *                                                                                 height() - 20 - i * (i + 1.5),
             *                                                                                 width()  - 20,
             *                                                                                 height() - 20 - i * (i + 1),
             *                                                                                 gradient_mtx);
             *                      ras.reset();
             *                      ras.move_to_d(width() - 150, height() - 20 - i * (i + 1.5));
             *                      ras.line_to_d(width() - 20,  height() - 20 - i * (i + 1));
             *                      ras.line_to_d(width() - 20,  height() - 20 - i * (i + 2));
             *                      agg::render_scanlines(ras, sl, ren_gradient);
             *              }
             */

            base.OnDraw(graphics2D);
        }
 public void preventDrawing(Stroke stroke)
 {
     this.Traits.Remove(stroke);
 }
 /// <summary>
 /// Adds Stroke to the current State of the Session
 /// Represented by the CurrentParticipantID and CurrentPage Object
 /// </summary>
 public void AddStrokeToParticipantPage(Stroke stroke)
 {
     CurrentPage.Strokes.Add(stroke);
 }
예제 #54
0
        private void CreateCircularBedGridImage(int linesInX, int linesInY)
        {
            Vector2 bedImageCentimeters = new Vector2(linesInX, linesInY);

            BedImage = new ImageBuffer(1024, 1024, 32, new BlenderBGRA());
            Graphics2D graphics2D = BedImage.NewGraphics2D();

            graphics2D.Clear(bedBaseColor);
#if true
            {
                double lineDist = BedImage.Width / (double)linesInX;

                int count     = 1;
                int pointSize = 16;
                graphics2D.DrawString(count.ToString(), 4, 4, pointSize, color: bedMarkingsColor);
                double  currentRadius = lineDist;
                Vector2 bedCenter     = new Vector2(BedImage.Width / 2, BedImage.Height / 2);
                for (double linePos = lineDist + BedImage.Width / 2; linePos < BedImage.Width; linePos += lineDist)
                {
                    int linePosInt = (int)linePos;
                    graphics2D.DrawString(count.ToString(), linePos + 2, BedImage.Height / 2, pointSize, color: bedMarkingsColor);

                    Ellipse circle  = new Ellipse(bedCenter, currentRadius);
                    Stroke  outline = new Stroke(circle);
                    graphics2D.Render(outline, bedMarkingsColor);
                    currentRadius += lineDist;
                    count++;
                }

                graphics2D.Line(0, BedImage.Height / 2, BedImage.Width, BedImage.Height / 2, bedMarkingsColor);
                graphics2D.Line(BedImage.Width / 2, 0, BedImage.Width / 2, BedImage.Height, bedMarkingsColor);
            }
#else
            {
                double lineDist = bedCentimeterGridImage.Width / (double)linesInX;

                int count     = 1;
                int pointSize = 20;
                graphics2D.DrawString(count.ToString(), 0, 0, pointSize);
                for (double linePos = lineDist; linePos < bedCentimeterGridImage.Width; linePos += lineDist)
                {
                    count++;
                    int linePosInt = (int)linePos;
                    graphics2D.Line(linePosInt, 0, linePosInt, bedCentimeterGridImage.Height, RGBA_Bytes.Black);
                    graphics2D.DrawString(count.ToString(), linePos, 0, pointSize);
                }
            }
            {
                double lineDist = bedCentimeterGridImage.Height / (double)linesInY;

                int count     = 1;
                int pointSize = 20;
                for (double linePos = lineDist; linePos < bedCentimeterGridImage.Height; linePos += lineDist)
                {
                    count++;
                    int linePosInt = (int)linePos;
                    graphics2D.Line(0, linePosInt, bedCentimeterGridImage.Height, linePosInt, RGBA_Bytes.Black);
                    graphics2D.DrawString(count.ToString(), 0, linePos, pointSize);
                }
            }
#endif
        }
 GestureStroke NormalizeStroke(Stroke stroke, GestureNormalizeSettings settings)
 {
     return(GestureRecognizer.IsDot(stroke, targetNormalizationPointCount)
         ? HandleDotStroke(stroke, settings)
         : HandleRegularStroke(stroke, settings));
 }
예제 #56
0
파일: NetDraw.cs 프로젝트: Marko50/TDIN
 public void OnLastSegment(Stroke stroke)
 {
     strokes.Add(stroke);
 }
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

            if (!didInit)
            {
                didInit = true;
                OnInitialize();
            }

            if (m_gamma.Value != m_old_gamma)
            {
                m_gamma_lut.SetGamma(m_gamma.Value);
                ImageIO.LoadImageData("spheres.bmp", m_SourceImage);
                //m_SourceImage.apply_gamma_dir(m_gamma_lut);
                m_old_gamma = m_gamma.Value;
            }

            ImageBuffer pixf = new ImageBuffer();

            switch (widgetsSubImage.BitDepth)
            {
            case 24:
                pixf.Attach(widgetsSubImage, new BlenderBGR());
                break;

            case 32:
                pixf.Attach(widgetsSubImage, new BlenderBGRA());
                break;

            default:
                throw new NotImplementedException();
            }

            ImageClippingProxy clippingProxy = new ImageClippingProxy(pixf);

            clippingProxy.clear(new RGBA_Floats(1, 1, 1));

            if (m_trans_type.SelectedIndex < 2)
            {
                // For the affine parallelogram transformations we
                // calculate the 4-th (implicit) point of the parallelogram
                m_quad.SetXN(3, m_quad.GetXN(0) + (m_quad.GetXN(2) - m_quad.GetXN(1)));
                m_quad.SetYN(3, m_quad.GetYN(0) + (m_quad.GetYN(2) - m_quad.GetYN(1)));
            }

            ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
            // draw a background to show how the alpha is working
            int RectWidth = 70;
            int xoffset   = 50;
            int yoffset   = 50;

            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    if ((i + j) % 2 != 0)
                    {
                        VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * RectWidth + xoffset, j * RectWidth + yoffset,
                                                                                     (i + 1) * RectWidth + xoffset, (j + 1) * RectWidth + yoffset, 2);
                        rect.normalize_radius();

                        g_rasterizer.add_path(rect);
                        scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(.2, .2, .2));
                    }
                }
            }

            //--------------------------
            // Render the "quad" tool and controls
            g_rasterizer.add_path(m_quad);
            scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0, 0.3, 0.5, 0.1));

            // Prepare the polygon to rasterize. Here we need to fill
            // the destination (transformed) polygon.
            g_rasterizer.SetVectorClipBox(0, 0, Width, Height);
            g_rasterizer.reset();
            int b = 0;

            g_rasterizer.move_to_d(m_quad.GetXN(0) - b, m_quad.GetYN(0) - b);
            g_rasterizer.line_to_d(m_quad.GetXN(1) + b, m_quad.GetYN(1) - b);
            g_rasterizer.line_to_d(m_quad.GetXN(2) + b, m_quad.GetYN(2) + b);
            g_rasterizer.line_to_d(m_quad.GetXN(3) - b, m_quad.GetYN(3) + b);

            //typedef agg::span_allocator<color_type> span_alloc_type;
            span_allocator         sa            = new span_allocator();
            image_filter_bilinear  filter_kernel = new image_filter_bilinear();
            ImageFilterLookUpTable filter        = new ImageFilterLookUpTable(filter_kernel, true);

            ImageBufferAccessorClamp source = new ImageBufferAccessorClamp(m_SourceImage);

            stopwatch.Restart();

            switch (m_trans_type.SelectedIndex)
            {
            case 0:
            {
                /*
                 *              agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *
                 *              typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
                 *              interpolator_type interpolator(tr);
                 *
                 *              typedef image_filter_2x2_type<source_type,
                 *                                                                        interpolator_type> span_gen_type;
                 *              span_gen_type sg(source, interpolator, filter);
                 *              agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 */
                break;
            }

            case 1:
            {
                /*
                 *              agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *
                 *              typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
                 *              typedef image_resample_affine_type<source_type> span_gen_type;
                 *
                 *              interpolator_type interpolator(tr);
                 *              span_gen_type sg(source, interpolator, filter);
                 *              sg.blur(m_blur.Value);
                 *              agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 */
                break;
            }

            case 2:
            {
                /*
                 *              agg::trans_perspective tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *              if(tr.is_valid())
                 *              {
                 *                      typedef agg::span_interpolator_linear_subdiv<agg::trans_perspective> interpolator_type;
                 *                      interpolator_type interpolator(tr);
                 *
                 *                      typedef image_filter_2x2_type<source_type,
                 *                                                                                interpolator_type> span_gen_type;
                 *                      span_gen_type sg(source, interpolator, filter);
                 *                      agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 *              }
                 */
                break;
            }

            case 3:
            {
                /*
                 *              agg::trans_perspective tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *              if(tr.is_valid())
                 *              {
                 *                      typedef agg::span_interpolator_trans<agg::trans_perspective> interpolator_type;
                 *                      interpolator_type interpolator(tr);
                 *
                 *                      typedef image_filter_2x2_type<source_type,
                 *                                                                                interpolator_type> span_gen_type;
                 *                      span_gen_type sg(source, interpolator, filter);
                 *                      agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 *              }
                 */
                break;
            }

            case 4:
            {
                //typedef agg::span_interpolator_persp_lerp<> interpolator_type;
                //typedef agg::span_subdiv_adaptor<interpolator_type> subdiv_adaptor_type;

                span_interpolator_persp_lerp interpolator   = new span_interpolator_persp_lerp(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                span_subdiv_adaptor          subdiv_adaptor = new span_subdiv_adaptor(interpolator);

                span_image_resample sg = null;
                if (interpolator.is_valid())
                {
                    switch (source.SourceImage.BitDepth)
                    {
                    case 24:
                        sg = new span_image_resample_rgb(source, subdiv_adaptor, filter);
                        break;

                    case 32:
                        sg = new span_image_resample_rgba(source, subdiv_adaptor, filter);
                        break;
                    }

                    sg.blur(m_blur.Value);
                    scanlineRenderer.GenerateAndRender(g_rasterizer, g_scanline, clippingProxy, sa, sg);
                }
                break;
            }

            case 5:
            {
                /*
                 *              typedef agg::span_interpolator_persp_exact<> interpolator_type;
                 *              typedef agg::span_subdiv_adaptor<interpolator_type> subdiv_adaptor_type;
                 *
                 *              interpolator_type interpolator(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *              subdiv_adaptor_type subdiv_adaptor(interpolator);
                 *
                 *              if(interpolator.is_valid())
                 *              {
                 *                      typedef image_resample_type<source_type,
                 *                                                                              subdiv_adaptor_type> span_gen_type;
                 *                      span_gen_type sg(source, subdiv_adaptor, filter);
                 *                      sg.blur(m_blur.Value);
                 *                      agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 *              }
                 */
                break;
            }
            }

            double tm = stopwatch.ElapsedMilliseconds;
            //pixf.apply_gamma_inv(m_gamma_lut);

            gsv_text t = new gsv_text();

            t.SetFontSize(10.0);

            Stroke pt = new Stroke(t);

            pt.width(1.5);

            string buf = string.Format("{0:F2} ms", tm);

            t.start_point(10.0, 70.0);
            t.text(buf);

            g_rasterizer.add_path(pt);
            scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0, 0, 0));

            //--------------------------
            //m_trans_type.Render(g_rasterizer, g_scanline, clippingProxy);
            //m_gamma.Render(g_rasterizer, g_scanline, clippingProxy);
            //m_blur.Render(g_rasterizer, g_scanline, clippingProxy);
            base.OnDraw(graphics2D);
        }
예제 #58
0
 public static void CubicEaseInCircleBrush(Stroke stroke0, int mapSize, float[,] map)
 {
     CircleBrush(stroke0, mapSize, map, (stroke1, currentValue) => currentValue + EasingHelper.EaseInCubic(1, 0, stroke1.CurrentPixel.GetNormalizedDistanceToCenter(), 1));
 }
예제 #59
0
        /// <inheritdoc cref="ChartElement{TDrawingContext}.Measure(Chart{TDrawingContext})"/>
        public override void Measure(Chart <TDrawingContext> chart)
        {
            var cartesianChart = (CartesianChart <TDrawingContext>)chart;
            var primaryAxis    = cartesianChart.YAxes[ScalesYAt];
            var secondaryAxis  = cartesianChart.XAxes[ScalesXAt];

            var drawLocation         = cartesianChart.DrawMarginLocation;
            var drawMarginSize       = cartesianChart.DrawMarginSize;
            var secondaryScale       = new Scaler(drawLocation, drawMarginSize, secondaryAxis);
            var primaryScale         = new Scaler(drawLocation, drawMarginSize, primaryAxis);
            var previousPrimaryScale = primaryAxis.PreviousDataBounds is null
                ? null
                : new Scaler(drawLocation, drawMarginSize, primaryAxis, true);
            var previousSecondaryScale = secondaryAxis.PreviousDataBounds is null
                ? null
                : new Scaler(drawLocation, drawMarginSize, secondaryAxis, true);

            var helper  = new MeasureHelper(secondaryScale, cartesianChart, this, secondaryAxis, primaryScale.ToPixels(pivot));
            var pHelper = previousSecondaryScale == null || previousPrimaryScale == null
                ? null
                : new MeasureHelper(
                previousSecondaryScale, cartesianChart, this, secondaryAxis, previousPrimaryScale.ToPixels(pivot));

            var actualZIndex = ZIndex == 0 ? ((ISeries)this).SeriesId : ZIndex;

            if (Fill is not null)
            {
                Fill.ZIndex = actualZIndex + 0.1;
                Fill.SetClipRectangle(cartesianChart.Canvas, new LvcRectangle(drawLocation, drawMarginSize));
                cartesianChart.Canvas.AddDrawableTask(Fill);
            }
            if (Stroke is not null)
            {
                Stroke.ZIndex = actualZIndex + 0.2;
                Stroke.SetClipRectangle(cartesianChart.Canvas, new LvcRectangle(drawLocation, drawMarginSize));
                cartesianChart.Canvas.AddDrawableTask(Stroke);
            }
            if (DataLabelsPaint is not null)
            {
                DataLabelsPaint.ZIndex = actualZIndex + 0.3;
                DataLabelsPaint.SetClipRectangle(cartesianChart.Canvas, new LvcRectangle(drawLocation, drawMarginSize));
                cartesianChart.Canvas.AddDrawableTask(DataLabelsPaint);
            }

            var dls            = (float)DataLabelsSize;
            var toDeletePoints = new HashSet <ChartPoint>(everFetched);

            var rx = (float)Rx;
            var ry = (float)Ry;

            foreach (var point in Fetch(cartesianChart))
            {
                var visual    = point.Context.Visual as TVisual;
                var primary   = primaryScale.ToPixels(point.PrimaryValue);
                var secondary = secondaryScale.ToPixels(point.SecondaryValue);
                var b         = Math.Abs(primary - helper.p);

                if (point.IsNull)
                {
                    if (visual is not null)
                    {
                        visual.X                 = secondary - helper.uwm + helper.cp;
                        visual.Y                 = helper.p;
                        visual.Width             = helper.uw;
                        visual.Height            = 0;
                        visual.RemoveOnCompleted = true;
                        point.Context.Visual     = null;
                    }
                    continue;
                }

                if (visual is null)
                {
                    var xi  = secondary - helper.uwm + helper.cp;
                    var pi  = helper.p;
                    var uwi = helper.uw;
                    var hi  = 0f;

                    if (previousSecondaryScale is not null && previousPrimaryScale is not null && pHelper is not null)
                    {
                        var previousPrimary = previousPrimaryScale.ToPixels(point.PrimaryValue);
                        var bp  = Math.Abs(previousPrimary - pHelper.p);
                        var cyp = point.PrimaryValue > pivot ? previousPrimary : previousPrimary - bp;

                        xi  = previousSecondaryScale.ToPixels(point.SecondaryValue) - pHelper.uwm + pHelper.cp;
                        pi  = cartesianChart.IsZoomingOrPanning ? cyp : pHelper.p;
                        uwi = pHelper.uw;
                        hi  = cartesianChart.IsZoomingOrPanning ? bp : 0;
                    }

                    var r = new TVisual
                    {
                        X      = xi,
                        Y      = pi,
                        Width  = uwi,
                        Height = hi
                    };

                    if (_isRounded)
                    {
                        var rounded = (IRoundedRectangleChartPoint <TDrawingContext>)r;
                        rounded.Rx = rx;
                        rounded.Ry = ry;
                    }

                    visual = r;
                    point.Context.Visual = visual;
                    OnPointCreated(point);

                    _ = everFetched.Add(point);
                }

                if (Fill is not null)
                {
                    Fill.AddGeometryToPaintTask(cartesianChart.Canvas, visual);
                }
                if (Stroke is not null)
                {
                    Stroke.AddGeometryToPaintTask(cartesianChart.Canvas, visual);
                }

                var cy = point.PrimaryValue > pivot ? primary : primary - b;
                var x  = secondary - helper.uwm + helper.cp;

                visual.X      = x;
                visual.Y      = cy;
                visual.Width  = helper.uw;
                visual.Height = b;
                if (_isRounded)
                {
                    var rounded = (IRoundedRectangleChartPoint <TDrawingContext>)visual;
                    rounded.Rx = rx;
                    rounded.Ry = ry;
                }
                visual.RemoveOnCompleted = false;

                var ha = new RectangleHoverArea().SetDimensions(secondary - helper.uwm + helper.cp, cy, helper.uw, b);
                point.Context.HoverArea = ha;

                OnPointMeasured(point);
                _ = toDeletePoints.Remove(point);

                if (DataLabelsPaint is not null)
                {
                    var label = (TLabel?)point.Context.Label;

                    if (label is null)
                    {
                        var l = new TLabel {
                            X = secondary - helper.uwm + helper.cp, Y = helper.p
                        };

                        _ = l.TransitionateProperties(nameof(l.X), nameof(l.Y))
                            .WithAnimation(animation =>
                                           animation
                                           .WithDuration(AnimationsSpeed ?? cartesianChart.AnimationsSpeed)
                                           .WithEasingFunction(EasingFunction ?? cartesianChart.EasingFunction));

                        l.CompleteAllTransitions();
                        label = l;
                        point.Context.Label = l;
                    }

                    DataLabelsPaint.AddGeometryToPaintTask(cartesianChart.Canvas, label);

                    label.Text     = DataLabelsFormatter(new TypedChartPoint <TModel, TVisual, TLabel, TDrawingContext>(point));
                    label.TextSize = dls;
                    label.Padding  = DataLabelsPadding;
                    var labelPosition = GetLabelPosition(
                        x, cy, helper.uw, b, label.Measure(DataLabelsPaint),
                        DataLabelsPosition, SeriesProperties, point.PrimaryValue > Pivot);
                    label.X = labelPosition.X;
                    label.Y = labelPosition.Y;
                }
            }

            foreach (var point in toDeletePoints)
            {
                if (point.Context.Chart != cartesianChart.View)
                {
                    continue;
                }
                SoftDeleteOrDisposePoint(point, primaryScale, secondaryScale);
                _ = everFetched.Remove(point);
            }
        }
예제 #60
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (Root.FormCollection is null)
            {
                return; // the initialisation is not yet completed. we wait for
            }
            Tick++;

            /*
             *          if (Tick == 1)
             *                  TickStartTime = DateTime.Now;
             *          else if (Tick % 60 == 0)
             *          {
             *                  Console.WriteLine(60 / (DateTime.Now - TickStartTime).TotalMilliseconds * 1000);
             *                  TickStartTime = DateTime.Now;
             *          }
             */

            if (Root.UponAllDrawingUpdate)
            {
                ClearCanvus();
                DrawStrokes();
                DrawButtons(true);
                if (Root.Snapping > 0)
                {
                    DrawSnapping(Root.SnappingRect);
                }
                UpdateFormDisplay(true);
                Root.UponAllDrawingUpdate = false;
            }

            else if (Root.UponTakingSnap)
            {
                if (Root.SnappingRect.Width == this.Width && Root.SnappingRect.Height == this.Height)
                {
                    System.Threading.Thread.Sleep(200);
                }
                ClearCanvus();
                DrawStrokes();
                //DrawButtons(false);
                UpdateFormDisplay(true);
                if (Root.VideoRecordWindowInProgress)
                {
                    Root.FormCollection.VideoRecordStartFFmpeg(Root.SnappingRect);
                    Root.UponTakingSnap = false;
                    return;
                }
                else
                {
                    SnapShot(Root.SnappingRect);
                }
                Root.UponTakingSnap = false;
                if (Root.CloseOnSnap == "true")
                {
                    Root.FormCollection.RetreatAndExit();
                }
                else if (Root.CloseOnSnap == "blankonly")
                {
                    if ((Root.FormCollection.IC.Ink.Strokes.Count == 0))
                    {
                        Root.FormCollection.RetreatAndExit();
                    }
                }
            }

            else if (Root.Snapping == 2)
            {
                if (Root.MouseMovedUnderSnapshotDragging)
                {
                    ClearCanvus();
                    DrawStrokes();
                    DrawButtons(false);
                    DrawSnapping(Root.SnappingRect);
                    UpdateFormDisplay(true);
                    Root.MouseMovedUnderSnapshotDragging = false;
                }
            }

            else if (!(Root.FormCollection is null) && !(Root.FormCollection.IC is null) && Root.FormCollection.IC.CollectingInk && Root.EraserMode == false && Root.InkVisible)
            {             // Drawing in progress : we get the last stroke in the list, if we have to draw because not deleted and not a shape in progress
                //we replace the rectangle containing the stroke by the saved one and

                if (Root.FormCollection.IC.Ink.Strokes.Count > 0)
                {
                    Stroke stroke = Root.FormCollection.IC.Ink.Strokes[Root.FormCollection.IC.Ink.Strokes.Count - 1];
                    if ((!stroke.Deleted) && (Root.ToolSelected == Tools.Hand))
                    {
                        BitBlt(OutcanvusDc, 0, 0, this.Width, this.Height, canvusDc, 0, 0, 0x00CC0020);
                        Root.FormCollection.IC.Renderer.Draw(gOutCanvus, stroke, Root.FormCollection.IC.DefaultDrawingAttributes);
                    }
                    UpdateFormDisplay(true, Root.ToolSelected == Tools.Hand);
                }
            }