Exemplo n.º 1
0
    private void DrawAt(Vector2 position, PointerEventData.InputButton button)
    {
        if (this.brush == null)
        {
            return;
        }
        ImagePainter.PointerState pointerState = this.pointerState[button];
        Vector2 vector2_1 = this.rectTransform.Unpivot(position);

        if (pointerState.isDown)
        {
            Vector2 vector2_2  = Vector2.op_Subtraction(pointerState.lastPos, vector2_1);
            Vector2 normalized = ((Vector2) ref vector2_2).get_normalized();
            for (float num = 0.0f; (double)num < (double)((Vector2) ref vector2_2).get_magnitude(); num += Mathf.Max(this.brush.spacing, 1f) * Mathf.Max(this.spacingScale, 0.1f))
            {
                this.onDrawing.Invoke(Vector2.op_Addition(vector2_1, Vector2.op_Multiply(num, normalized)), this.brush);
            }
            pointerState.lastPos = vector2_1;
        }
        else
        {
            this.onDrawing.Invoke(vector2_1, this.brush);
            pointerState.lastPos = vector2_1;
        }
    }
Exemplo n.º 2
0
    private void DrawAt(Vector2 position, PointerEventData.InputButton button)
    {
        if (this.brush == null)
        {
            return;
        }
        ImagePainter.PointerState pointerState = this.pointerState[(int)button];
        Vector2 vector2 = this.rectTransform.Unpivot(position);

        if (!pointerState.isDown)
        {
            this.onDrawing.Invoke(vector2, this.brush);
            pointerState.lastPos = vector2;
            return;
        }
        Vector2 vector21 = pointerState.lastPos - vector2;
        Vector2 vector22 = vector21.normalized;

        for (float i = 0f; i < vector21.magnitude; i = i + Mathf.Max(this.brush.spacing, 1f) * Mathf.Max(this.spacingScale, 0.1f))
        {
            this.onDrawing.Invoke(vector2 + (i * vector22), this.brush);
        }
        pointerState.lastPos = vector2;
    }