draw arc going counter-clockwise from start_angle to end_angle
553669
def arc(self, x, y, radius, start_angle, end_angle):
        """"""
        self._add_instruction("arc", x, y, radius, start_angle, end_angle)
1297096
def rect(box, draw, trans)
      use_cairo do |cc|
        cc.rotate_about(box.x, box.y, trans.angle)
        cc.rounded_rectangle(box.x, box.y, box.width, box.height,
                             box.x_radius, box.y_radius)
        cc.fill_n_stroke(draw)
      end
    end
1214595
function twoArcsRender() {
    // For each small multiple
    function twoArcs(g) {
      g.each(function(d) {
        g = d3.select(this);
        widget.createParts(g, d);

        var right_pad = d.depth > 0 ? sector_right_pad / (3 * d.depth) : sector_right_pad;
        var score = widget.getScore(d);

        if (!d.children) {
          var inner_r = sector_bottom_pad + d.y0;
          var out_r = sector_bottom_pad + d.y0 + utils.getBarLengthFactor(d) * Math.abs(score) * (d.y1 - d.y0);

          var _bar = d3.arc()
            .startAngle(d.x0)
            .endAngle(d.x1)
            .innerRadius(inner_r)
            .outerRadius(out_r); // Draw leaf arcs

          widget._childElements.parts[widget.getUniqueId(d, 'bar')]
            .attr('d', _bar);

          //add label;
          var rotate = 0,
            lbl_anchor = 'start',
            dy_init = 0;

          if (d.x0 > Math.PI) {
            rotate = d.x0 * 180 / Math.PI + 90;
            lbl_anchor = 'end';
            dy_init = -(d.x1 - d.x0) * 20 * Math.PI;
          } else {
            rotate = d.x0 * 180 / Math.PI - 90;
            lbl_anchor = 'start';
            dy_init = 5 + (d.x1 - d.x0) * 20 * Math.PI;
          }

          widget._childElements.parts[widget.getUniqueId(d, 'sector_leaf_text')]
            .attr('dy', dy_init)
            .attr('text-anchor', lbl_anchor)
            .attr('transform', 'translate(' + (out_r + 5) * Math.sin(d.x0) + ',' + (-(out_r + 5) * Math.cos(d.x0)) + ') ' + 'rotate(' + rotate + ')');
        } else {
          var arc1_extend = Math.max(Math.abs(score) * (d.x1 - d.x0) - right_pad, 0);
          //Regular renders
          var arc1 = d3.arc()
            .startAngle(function(d) {
              return d.x0;
            }) //x:startangle,
            .endAngle(function(d) {
              return d.x0 + arc1_extend;
            }) //dx: endangle,
            .innerRadius(function(d) {
              return sector_bottom_pad + d.y0;
            })
            .outerRadius(function(d) {
              return d.y1;
            });

          widget._childElements.parts[widget.getUniqueId(d, 'arc1')]
            .attr('d', arc1);

          var arc2 = d3.arc()
            .startAngle(function(d) {
              return d.x0 + arc1_extend;
            }) //x:startangle,
            .endAngle(function(d) {
              return d.x0 + (d.x1 - d.x0) - right_pad;
            }) //dx: endangle,
            .innerRadius(function(d) {
              return sector_bottom_pad + d.y0;
            })
            .outerRadius(function(d) {
              return d.y1;
            });
          widget._childElements.parts[widget.getUniqueId(d, 'arc2')]
            .attr('d', arc2);

          var bottom = utils.isLocatedBottom(d);
          var arc_for_label, arc_for_label_number;
          var arc_label_radius, arc_label_number_radius;
          if (d.depth === 1 && bottom) {
            arc_label_radius = d.y1 - (d.y1 - sector_bottom_pad - d.y0) / 6;
            arc_label_number_radius = d.y1 - (d.y1 - sector_bottom_pad - d.y0) / 8;
          } else {
            arc_label_radius = sector_bottom_pad + d.y0 + (d.y1 - sector_bottom_pad - d.y0) * 5 / 12;
            arc_label_number_radius = d.y1 - (d.y1 - sector_bottom_pad - d.y0) / 7;
          }

          if (bottom) {
            //special reversed label for bottom data
            arc_for_label = utils.arc(d.x1 - right_pad - Math.PI / 2, d.x0 - Math.PI / 2, arc_label_radius);
            arc_for_label_number = utils.arc(d.x1 - right_pad - Math.PI / 2, d.x0 - Math.PI / 2, arc_label_number_radius);
          } else {
            arc_for_label = d3SvgSingleArc()
              .startAngle(function(d) {
                return d.x0;
              })
              .endAngle(function(d) {
                return d.x1 - right_pad;
              })
              .radius(function(d) {
                return d.depth === 1 ? d.y1 - (d.y1 - sector_bottom_pad - d.y0) / 3 : sector_bottom_pad + d.y0 + (d.y1 - sector_bottom_pad - d.y0) * 3 / 5;
              });

            arc_for_label_number = d3SvgSingleArc()
              .startAngle(function(d) {
                return d.x0;
              })
              .endAngle(function(d) {
                return d.x1 - right_pad;
              })
              .radius(function(d) {
                return d.depth === 1 ? d.y1 - (d.y1 - sector_bottom_pad - d.y0) / 3 : sector_bottom_pad + d.y0 + (d.y1 - sector_bottom_pad - d.y0) / 5;
              });
          }
          widget._childElements.parts[widget.getUniqueId(d, 'arc_for_label')]
            .attr('d', arc_for_label);
          if (d.depth > 1) {
            widget._childElements.parts[widget.getUniqueId(d, 'arc_for_label_number')]
              .attr('d', arc_for_label_number);
          }
        }
      });
    }

    return twoArcs;
  }
447561
private void drawTriangle(ShaderBuffer out1, float x1, float y1, float z1, float w1,
                              ShaderBuffer out2, float x2, float y2, float z2, float w2,
                              ShaderBuffer out3, float x3, float y3, float z3, float w3,
                              ShaderImplementation fragmentShader, ShaderBuffer fragmentIn, ShaderBuffer fragmentOut) {
        // (28).(4) (in bits) fixed-point coordinates
        final int fy1 = Math.round(y1 * 16);
        final int fy2 = Math.round(y2 * 16);
        final int fy3 = Math.round(y3 * 16);
        final int fx1 = Math.round(x1 * 16);
        final int fx2 = Math.round(x2 * 16);
        final int fx3 = Math.round(x3 * 16);
        // Deltas
        final int dx12 = fx1 - fx2;
        final int dx23 = fx2 - fx3;
        final int dx31 = fx3 - fx1;
        final int dy12 = fy1 - fy2;
        final int dy23 = fy2 - fy3;
        final int dy31 = fy3 - fy1;
        // Fixed-point deltas
        final int fdx12 = dx12 << 4;
        final int fdx23 = dx23 << 4;
        final int fdx31 = dx31 << 4;
        final int fdy12 = dy12 << 4;
        final int fdy23 = dy23 << 4;
        final int fdy31 = dy31 << 4;
        // Block size, standard 8x8 (must be power of two), here 2^3
        final int block = 1 << 3;
        // Bounding rectangle, start in the corner of the 8x8 block
        final int minX = Math.min(fx1, Math.min(fx2, fx3)) + 0xf >> 4 & ~(block - 1);
        final int maxX = Math.max(fx1, Math.max(fx2, fx3)) + 0xf >> 4;
        final int minY = Math.min(fy1, Math.min(fy2, fy3)) + 0xf >> 4 & ~(block - 1);
        final int maxY = Math.max(fy1, Math.max(fy2, fy3)) + 0xf >> 4;
        // Determinant of deltas to compute the normalized barycentric coordinates for interpolation
        final float det = dx23 * dy12 - dy23 * dx12;
        // Barycentric coordinates
        int c1 = dy12 * fx1 - dx12 * fy1;
        int c2 = dy23 * fx2 - dx23 * fy2;
        int c3 = dy31 * fx3 - dx31 * fy3;
        // Correct for fill convention
        if (dy12 < 0 || dy12 == 0 && dx12 > 0) {
            c1++;
        }
        if (dy23 < 0 || dy23 == 0 && dx23 > 0) {
            c2++;
        }
        if (dy31 < 0 || dy31 == 0 && dx31 > 0) {
            c3++;
        }
        // Loop through blocks
        for (int by = minY; by < maxY; by += block) {
            for (int bx = minX; bx < maxX; bx += block) {
                // Corners of block
                final int bx0 = bx << 4;
                final int bx1 = bx + block - 1 << 4;
                final int by0 = by << 4;
                final int by1 = by + block - 1 << 4;
                // Evaluate half-space functions
                final boolean a00 = c1 + dx12 * by0 - dy12 * bx0 <= 0;
                final boolean a10 = c1 + dx12 * by0 - dy12 * bx1 <= 0;
                final boolean a01 = c1 + dx12 * by1 - dy12 * bx0 <= 0;
                final boolean a11 = c1 + dx12 * by1 - dy12 * bx1 <= 0;
                final boolean b00 = c2 + dx23 * by0 - dy23 * bx0 <= 0;
                final boolean b10 = c2 + dx23 * by0 - dy23 * bx1 <= 0;
                final boolean b01 = c2 + dx23 * by1 - dy23 * bx0 <= 0;
                final boolean b11 = c2 + dx23 * by1 - dy23 * bx1 <= 0;
                final boolean c00 = c3 + dx31 * by0 - dy31 * bx0 <= 0;
                final boolean c10 = c3 + dx31 * by0 - dy31 * bx1 <= 0;
                final boolean c01 = c3 + dx31 * by1 - dy31 * bx0 <= 0;
                final boolean c11 = c3 + dx31 * by1 - dy31 * bx1 <= 0;
                // Skip the block when outside an edge
                if (a00 && a10 && a01 && a11 || b00 && b10 && b01 && b11 || c00 && c10 && c01 && c11) {
                    continue;
                }
                // Compute the barycentric coordinates
                int cy1 = c1 + dx12 * by0 - dy12 * bx0;
                int cy2 = c2 + dx23 * by0 - dy23 * bx0;
                int cy3 = c3 + dx31 * by0 - dy31 * bx0;
                // Iterate the block
                for (int y = by; y < by + block; y++) {
                    int cx1 = cy1;
                    int cx2 = cy2;
                    int cx3 = cy3;
                    for (int x = bx; x < bx + block; x++) {
                        // Only draw pixels inside the triangle
                        if (cx1 > 0 && cx2 > 0 && cx3 > 0) {
                            // Compute the normalized barycentric coordinates
                            final float t = cx1 / det;
                            final float r = cx2 / det;
                            final float s = 1 - t - r;
                            // Lerp the rest of the data using the barycentric coordinates
                            final float z = SoftwareUtil.baryLerp(z1, z2, z3, r, s, t);
                            final float w = SoftwareUtil.baryLerp(w1, w2, w3, r, s, t);
                            fragmentIn.clear();
                            fragmentIn.writeRaw(Float.floatToIntBits(x));
                            fragmentIn.writeRaw(Float.floatToIntBits(y));
                            fragmentIn.writeRaw(Float.floatToIntBits(z));
                            fragmentIn.writeRaw(Float.floatToIntBits(w));
                            out1.position(4);
                            out2.position(4);
                            out3.position(4);
                            SoftwareUtil.baryLerp(out1, out2, out3, r, s, t, 1, fragmentIn);
                            fragmentIn.flip();
                            // Shade and write the fragment
                            writeFragment(fragmentShader, fragmentIn, fragmentOut, x, y, z);
                        }
                        cx1 -= fdy12;
                        cx2 -= fdy23;
                        cx3 -= fdy31;
                    }
                    cy1 += fdx12;
                    cy2 += fdx23;
                    cy3 += fdx31;
                }
            }
        }
    }
1167630
function(d) {
          var i = d3.interpolate(this._current, d);
          this._current = i(0);
          return function(t) {
            return 'translate(' + arc.centroid(i(t)) + ') rotate(' + labelAngle(d) + ')';
          };
        }
681265
function _drawArc(canvas, ctx, params, path) {
	var x1, y1, x2, y2,
		x3, y3, x4, y4,
		offsetX, offsetY,
		diff;

	// Determine offset from dragging
	if (params === path) {
		offsetX = 0;
		offsetY = 0;
	} else {
		offsetX = params.x;
		offsetY = params.y;
	}

	// Convert default end angle to radians
	if (!path.inDegrees && path.end === 360) {
		path.end = PI * 2;
	}

	// Convert angles to radians
	path.start *= params._toRad;
	path.end *= params._toRad;
	// Consider 0deg due north of arc
	path.start -= (PI / 2);
	path.end -= (PI / 2);

	// Ensure arrows are pointed correctly for CCW arcs
	diff = PI / 180;
	if (path.ccw) {
		diff *= -1;
	}

	// Calculate coordinates for start arrow
	x1 = _getArcX(path, path.start + diff);
	y1 = _getArcY(path, path.start + diff);
	x2 = _getArcX(path, path.start);
	y2 = _getArcY(path, path.start);

	_addStartArrow(
		canvas, ctx,
		params, path,
		x1, y1,
		x2, y2
	);

	// Draw arc
	ctx.arc(path.x + offsetX, path.y + offsetY, path.radius, path.start, path.end, path.ccw);

	// Calculate coordinates for end arrow
	x3 = _getArcX(path, path.end + diff);
	y3 = _getArcY(path, path.end + diff);
	x4 = _getArcX(path, path.end);
	y4 = _getArcY(path, path.end);

	_addEndArrow(
		canvas, ctx,
		params, path,
		x4, y4,
		x3, y3
	);
}
560566
def on_arc_right(self, speed, radius_mm, distance_mm, brake=True, block=True):
        
        self._on_arc(speed, radius_mm, distance_mm, brake, block, True)
10229
function (x, y, r, innerR, start, end) {
		// arcs are defined as symbols for the ability to set
		// attributes in attr and animate

		if (isObject(x)) {
			y = x.y;
			r = x.r;
			innerR = x.innerR;
			start = x.start;
			end = x.end;
			x = x.x;
		}

		return this.symbol('arc', x || 0, y || 0, r || 0, {
			innerR: innerR || 0,
			start: start || 0,
			end: end || 0
		});
	}
138700
function drawRadialNumbers(context, options) {
    let radius = radialTicksRadius(context, options) - context.max * 0.15;
    let points = {};
    let i = 0;
    let s = options.majorTicks.length;
    let isAnimated = options.animationTarget !== 'needle';
    let colors = options.colorNumbers instanceof Array ?
        options.colorNumbers : new Array(s).fill(options.colorNumbers);

    let plateValueAngle = isAnimated ? -(options.value - options.minValue) /
        (options.maxValue - options.minValue) * options.ticksAngle : 0;

    if (isAnimated) {
        context.save();
        context.rotate(-drawings.radians(plateValueAngle));
    }

    context.font = drawings.font(options, 'Numbers', context.max / 200);
    context.lineWidth = 0;
    context.textAlign = 'center';
    context.textBaseline = 'middle';

    for (; i < s; ++i) {
        let angle = plateValueAngle + radialNextAngle(options,
            options.exactTicks ? options.majorTicks[i] : i, s);
        let textWidth = context.measureText(options.majorTicks[i]).width;
        let textHeight = options.fontNumbersSize;
        let textRadius = Math.sqrt(textWidth * textWidth +
            textHeight * textHeight) / 2;
        let point = drawings.radialPoint(radius - textRadius -
            options.numbersMargin / 100 * context.max,
            drawings.radians(angle));

        if (angle === 360) angle = 0;

        if (points[angle]) {
            continue; //already drawn at this place, skipping
        }

        points[angle] = true;

        context.fillStyle = colors[i];
        context.fillText(options.majorTicks[i], point.x, point.y);
    }

    isAnimated && context.restore();
}
1088579
def draw_line(self, start, end, color):
        
        def dist(p, a, b):
            return (abs((b[0] - a[0]) * (a[1] - p[1]) - (a[0] - p[0]) * (b[1] - a[1])) /
                    math.sqrt((b[0] - a[0])**2 + (b[1] - a[1])**2))

        points = []
        for x in range(min(start[0], end[0]), max(start[0], end[0]) + 1):
            for y in range(min(start[1], end[1]), max(start[1], end[1]) + 1):
                if dist((x, y), start, end) < 0.5:
                    points.append((x, y))
        for point in points:
            self.draw_dot(point, color)
950679
function (x, y, w, h, options) {
			var start = options.start,
				end = options.end,
				radius = options.r || w || h,
				innerRadius = options.innerR,
				cosStart = mathCos(start),
				sinStart = mathSin(start),
				cosEnd = mathCos(end),
				sinEnd = mathSin(end),
				ret;

			if (end - start === 0) { // no angle, don't show it.
				return ['x'];
			}

			ret = [
				'wa', // clockwise arc to
				x - radius, // left
				y - radius, // top
				x + radius, // right
				y + radius, // bottom
				x + radius * cosStart, // start x
				y + radius * sinStart, // start y
				x + radius * cosEnd, // end x
				y + radius * sinEnd  // end y
			];

			if (options.open && !innerRadius) {
				ret.push(
					'e',
					M,
					x,// - innerRadius,
					y// - innerRadius
				);
			}

			ret.push(
				'at', // anti clockwise arc to
				x - innerRadius, // left
				y - innerRadius, // top
				x + innerRadius, // right
				y + innerRadius, // bottom
				x + innerRadius * cosEnd, // start x
				y + innerRadius * sinEnd, // start y
				x + innerRadius * cosStart, // end x
				y + innerRadius * sinStart, // end y
				'x', // finish path
				'e' // close
			);

			ret.isArc = true;
			return ret;

		}
947579
def angle_diff(start_a=[0.0], end_a=[0.0], direction=True):
    '''
    '''
    assert isinstance(start_a, list)
    assert isinstance(end_a, list)
    l_angle = len(start_a)
    assert l_angle > 0
    assert l_angle == len(end_a)
    for i in start_a:
        assert isinstance(i, float)
        assert abs(i) <= 2*pi
    for i in end_a:
        assert isinstance(i, float)
        assert abs(i) <= 2*pi
    assert isinstance(direction, bool)

    # Convert True/False to 1/-1
    inv = 2 * int(direction) - 1

    diff = [end_a[i] - start_a[i] for i in range(l_angle)]
    diff = [(2*pi + d) if d < 0.0 else d for d in diff]
    return [d*inv for d in diff]
1203883
function drawRadialMajorTicks(context, options) {
    drawings.prepareTicks(options);

    //noinspection JSUnresolvedFunction
    let r = abs(radialTicksRadius(context, options));
    let i, colors;
    let s = options.majorTicks.length;
    let pixelRatio = SmartCanvas.pixelRatio;

    context.lineWidth = 2 * pixelRatio;
    context.save();

    colors = options.colorMajorTicks instanceof Array ?
        options.colorMajorTicks : new Array(s).fill(options.colorStrokeTicks ||
            options.colorMajorTicks);

    i = 0;
    for (; i < s; ++i) {
        context.strokeStyle = colors[i];
        context.rotate(drawings.radians(radialNextAngle(
            options,
            options.exactTicks ? options.majorTicks[i] : i,
            s
        )));

        context.beginPath();
        context.moveTo(0, r);
        context.lineTo(0, r - context.max * 0.15);
        closeStrokedPath(context);
    }

    if (options.strokeTicks) {
        context.strokeStyle = options.colorStrokeTicks || colors[0];
        context.rotate(HPI);

        context.beginPath();
        context.arc(0, 0, r,
            drawings.radians(options.startAngle),
            drawings.radians(options.startAngle + options.ticksAngle),
            false
        );
        closeStrokedPath(context);
    }
}
550385
function(node,x,y,size,color,context) {
    context.fillStyle = 'yellow';
    context.beginPath();
    context.arc(x,y,size,1.25*Math.PI,0,false);
    context.arc(x,y,size,0,0.75*Math.PI,false);
    context.lineTo(x,y);
    context.closePath();
    context.fill();

    context.fillStyle = 'white';
    context.strokeStyle = 'black';
    context.beginPath();
    context.arc(x+size/3,y-size/3,size/4,0,2*Math.PI,false);
    context.closePath();
    context.fill();
    context.stroke();

    context.fillStyle = 'black';
    context.beginPath();
    context.arc(x+4*size/9,y-size/3,size/8,0,2*Math.PI,false);
    context.closePath();
    context.fill();
  }
1372509
function drawRadialMinorTicks(context, options) {
    let radius = radialTicksRadius(context, options);
    let s, range, angle;
    let i = 0;
    let delta = 0;
    let minTicks = Math.abs(options.minorTicks) || 0;
    let ratio = options.ticksAngle / (options.maxValue - options.minValue);

    context.lineWidth = SmartCanvas.pixelRatio;
    context.strokeStyle = options.colorMinorTicks || options.colorStrokeTicks;

    context.save();

    if (options.exactTicks) {
        range = options.maxValue - options.minValue;
        s = minTicks ? range / minTicks : 0;
        delta = (BaseGauge.mod(options.majorTicks[0], minTicks) || 0)  * ratio;
    }

    else {
        s = minTicks * (options.majorTicks.length - 1);
    }

    for (; i < s; ++i) {
        angle = options.startAngle + delta + i * (options.ticksAngle / s);
        if (angle <= (options.ticksAngle + options.startAngle )) {
            context.rotate(drawings.radians(angle));

            context.beginPath();
            context.moveTo(0, radius);
            context.lineTo(0, radius - context.max * 0.075);
            closeStrokedPath(context);
        }
    }
}
628979
def clockwise?
	    edges.map {|e| (e.last.x - e.first.x) * (e.last.y + e.first.y)}.reduce(:+) >= 0
	end
567848
public void setArcByTangent (XY p1, XY p2, XY p3, float radius) {
        // use simple geometric calculations of arc center, radius and angles by tangents
        float a1 = -FloatMath.atan2(p1.y() - p2.y(), p1.x() - p2.x());
        float a2 = -FloatMath.atan2(p3.y() - p2.y(), p3.x() - p2.x());
        float am = (a1 + a2) / 2f;
        float ah = a1 - am;
        float d = radius / Math.abs(FloatMath.sin(ah));
        float x = p2.x() + d * FloatMath.cos(am);
        float y = p2.y() - d * FloatMath.sin(am);
        ah = ah >= 0f ? FloatMath.PI * 1.5f - ah : FloatMath.PI * 0.5f - ah;
        a1 = normAngle(FloatMath.toDegrees(am - ah));
        a2 = normAngle(FloatMath.toDegrees(am + ah));
        float delta = a2 - a1;
        if (delta <= 0f) {
            delta += 360f;
        }
        setArcByCenter(x, y, radius, a1, delta, type);
    }