使用stroke方法将图形绘制在窗口里，仅对基本的几何图形有效
769026
def stroke(self):
        
        self.update_all()
        length = len(self.points)
        
        # thick lines
        if self.line_width <= 3:
            if length==4:
                self.vertex_list.draw(pyglet.gl.GL_LINES)
            elif length > 4:
                self.vertex_list.draw(pyglet.gl.GL_LINE_LOOP)
            return

        # 
        color = color_to_tuple(self.color, self.opacity)
        if length == 4:
            x, y, x1, y1 = self.points[0:4]
            l = max(1, math.sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y)))
            ly = (x1-x) / l * self.line_width / 2
            lx = - (y1-y) / l * self.line_width / 2

            points = [x-lx, y-ly, x+lx, y+ly, x1+lx, y1+ly, x1-lx, y1-ly]

            vertex_list = pyglet.graphics.vertex_list(
                4,
                ('v2f', points),
                ('c4B', color * 4))
            vertex_list.draw(pyglet.gl.GL_QUADS)

        elif length > 4:
            points = []
            for i in range(0, length, 2):
                x, y = self.points[i], self.points[i+1]
                x1, y1 = self.points[i-2], self.points[i-1]
                x2, y2 = self.points[(i+2) % length], self.points[(i+3) % length]

                l1 = max(1, math.sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y)))
                l2 = max(1, math.sqrt((x2-x)*(x2-x)+(y2-y)*(y2-y)))

                nx1, ny1 = (x - x1) / l1, (y - y1) / l1
                nx2, ny2 = (x - x2) / l2, (y - y2) / l2
                nx, ny = nx1 + nx2, ny1 + ny2
                vx, vy = -ny1, nx1

                t = nx1*nx2 + ny1*ny2
                if t > 0.99:
                    lx = vx * self.line_width / 2
                    ly = vy * self.line_width / 2
                    points += [x-lx, y-ly, x+lx, y+ly, x+lx, y+ly, x-lx, y-ly]
                elif t < -0.99:
                    lx = vx * self.line_width / 2
                    ly = vy * self.line_width / 2
                    points += [x+lx, y+ly, x-lx, y-ly]
                else:
                    radio = 1/(vx*nx + vy*ny)
                    if radio < 0: 
                        radio = -radio

                    lx = (nx1+nx2) * self.line_width / 2 * radio
                    ly = (ny1+ny2) * self.line_width / 2 * radio
                    points += [x+lx, y+ly, x-lx, y-ly]

            batch = pyglet.graphics.Batch()
            for i in range(0, len(points), 4):

                batch.add(4, pyglet.gl.GL_QUADS, None,
                    ('v2f', (points[i-4], points[i-3], points[i-2], points[i-1],
                        points[i+2], points[i+3], points[i], points[i+1])),
                    ('c4B', color * 4))

            batch.draw()

        pyglet.gl.glLoadIdentity()
864770
function stroke(shape, fill) {
         if (shape.shapeType === "Rectangle") {
           this.strokeRect(shape.left, shape.top, shape.width, shape.height, fill);
         } else if (shape instanceof me.Line || shape instanceof me.Polygon) {
           this.strokePolygon(shape, fill);
         } else if (shape instanceof me.Ellipse) {
           this.strokeEllipse(shape.pos.x, shape.pos.y, shape.radiusV.x, shape.radiusV.y, fill);
         }
       }
1113776
function() {
      return [
        "stroke: ", (this.stroke ? this.stroke : 'none'), "; ",
        "stroke-width: ", (this.strokeWidth ? this.strokeWidth : '0'), "; ",
        "stroke-dasharray: ", (this.strokeDashArray ? this.strokeDashArray.join(' ') : "; "),
        "fill: ", (this.fill ? this.fill : 'none'), "; ",
        "opacity: ", (this.opacity ? this.opacity : '1'), ";"
      ].join("");
    }
98715
function nextTick(fn, thisArg) {
    if (thisArg) {
        fn = bind(fn, thisArg);
    }
    nextTasks.push(fn);

    if (nextHandler) {
        return;
    }

    nextHandler = function () {
        var tasks = nextTasks.slice(0);
        nextTasks = [];
        nextHandler = null;

        for (var i = 0, l = tasks.length; i < l; i++) {
            tasks[i]();
        }
    };

    // 非标准方法，但是此方法非常吻合要求。
    /* istanbul ignore next */
    if (typeof setImmediate === 'function') {
        setImmediate(nextHandler);
    }
    // 用MessageChannel去做setImmediate的polyfill
    // 原理是将新的message事件加入到原有的dom events之后
    else if (typeof MessageChannel === 'function') {
        var channel = new MessageChannel();
        var port = channel.port2;
        channel.port1.onmessage = nextHandler;
        port.postMessage(1);
    }
    // for native app
    else if (isNativePromise) {
        Promise.resolve().then(nextHandler);
    }
    else {
        setTimeout(nextHandler, 0);
    }
}
212006
public void strokeRoundRectangle(Rectangle rect, Color color, float linewidth, float r) {
		template.saveState();
		setStroke(color, linewidth, null);
		template.roundRectangle(origX + rect.getLeft(), origY + rect.getBottom(), rect.getWidth(), rect.getHeight(), r);
		template.stroke();
		template.restoreState();
	}
41515
function drawLinearMajorTicks(context, options) {
    let [hasLeft, hasRight] = drawings.prepareTicks(options);
    let lineWidth = 2;
    let valuePerNonExactTick = (options.maxValue - options.minValue) /
        (options.majorTicks.length - 1);
    let colors = options.colorMajorTicks instanceof Array ?
        options.colorMajorTicks :
        new Array(options.majorTicks.length).fill(
            options.colorStrokeTicks || options.colorMajorTicks);
    let ticks = options.exactTicks ? options.majorTicks :
        options.majorTicks.map((tick, i) => {
            return options.minValue + valuePerNonExactTick * i;
        });

    drawLinearTicks(context, colors, ticks, options.minValue, options.maxValue,
        hasLeft, hasRight, lineWidth, options.ticksWidth / 100);

    if (options.strokeTicks) {
        let {isVertical, length, width, barWidth, barMargin, barOffset, X, Y,
            ticksLength, pixelRatio, ticksPadding} = context.barDimensions;
        let rightTicks = (width - barWidth) / 2 + barWidth +
            ticksPadding * width;
        let leftTicks = (width - barWidth) / 2 - ticksPadding * width;
        let sX, sY, eX, eY;

        context.strokeStyle = options.colorStrokeTicks || colors[0];

        lineWidth *= pixelRatio;

        if (isVertical) {
            sY = Y + length - barMargin - barOffset + lineWidth / 2;
            eY = sY - ticksLength - lineWidth;

            if (hasLeft) {
                //noinspection JSUnresolvedFunction
                eX = sX = round(X + leftTicks);
                drawLinearTickStroke(context, sX, sY, eX, eY);
            }

            if (hasRight) {
                //noinspection JSUnresolvedFunction
                eX = sX = round(X + rightTicks);
                drawLinearTickStroke(context, sX, sY, eX, eY);
            }
        }

        else {
            sX = X + barMargin + barOffset - lineWidth / 2;
            eX = sX + ticksLength + lineWidth;

            if (hasLeft) {
                //noinspection JSUnresolvedFunction
                eY = sY = round(Y + leftTicks);
                drawLinearTickStroke(context, sX, sY, eX, eY);
            }

            if (hasRight) {
                //noinspection JSUnresolvedFunction
                eY = sY = round(Y + rightTicks);
                drawLinearTickStroke(context, sX, sY, eX, eY);
            }
        }
    }
}
9320
function drawHandles() {
            let handleFillColor = colorHelper.colorSchemasHuman.grey[1];

            // Styling
            handle = chartBrush
                        .selectAll('.handle.brush-rect')
                        .style('fill', handleFillColor);
        }
1317822
def fill_stroke(self, fill = None, stroke = None, opacity = 1, line_width = None):
        """"""
        if line_width: self.set_line_style(line_width)

        if fill and stroke:
            self.fill_preserve(fill, opacity)
        elif fill:
            self.fill(fill, opacity)

        if stroke:
            self.stroke(stroke)
553452
function(){
		/* "ものを動かしたように描画する"でなければinputLineと同じ */
		if(this.puzzle.execConfig('dispmove')){
			this.inputMoveLine();
			return;
		}
		
		var pos, border;
		if(!this.board.borderAsLine){
			pos = this.getpos(0);
			if(this.prevPos.equals(pos)){ return;}
			border = this.prevPos.getnb(pos);
		}
		else{
			pos = this.getpos(0.35);
			if(this.prevPos.equals(pos)){ return;}
			border = this.prevPos.getborderobj(pos);
		}
		
		if(!border.isnull){
			if(this.inputData===null){ this.inputData=(border.isLine()?0:1);}
			if     (this.inputData===1){ border.setLine();}
			else if(this.inputData===0){ border.removeLine();}
			border.draw();
		}
		this.prevPos = pos;
	}
135955
def _features_with_strokes(self, hwr_obj):
        """"""
        x = []
        img = Image.new('L', ((int(hwr_obj.get_width()*self.scaling_factor) + 2), (int(hwr_obj.get_height()*self.scaling_factor) + 2)), 'black')
        draw = ImageDraw.Draw(img, 'L')
        pointlist = hwr_obj.get_pointlist()
        bb = hwr_obj.get_bounding_box()
        for stroke_nr in range(self.strokes):
            last_point = None
            # make sure that the current symbol actually has that many
            # strokes
            if stroke_nr < len(pointlist):
                for point_nr in range(self.points_per_stroke):
                    if point_nr < len(pointlist[stroke_nr]):
                        point = pointlist[stroke_nr][point_nr]
                        x.append(pointlist[stroke_nr][point_nr]['x'])
                        x.append(pointlist[stroke_nr][point_nr]['y'])
                        if last_point is None:
                            last_point = point
                        y_from = int((-bb['miny'] + last_point['y'])*self.scaling_factor)
                        x_from = int((-bb['minx'] + last_point['x'])*self.scaling_factor)
                        y_to = int((-bb['miny'] + point['y'])*self.scaling_factor)
                        x_to = int((-bb['minx'] + point['x'])*self.scaling_factor)
                        draw.line([x_from, y_from, x_to, y_to], fill='#ffffff', width=1)
                        if self.pixel_env > 0:
                            pix = img.load()
                            for x_offset in range(-self.pixel_env,
                                                  self.pixel_env + 1):
                                for y_offset in range(-self.pixel_env,
                                                      self.pixel_env + 1):
                                    xp = int((-bb['minx'] + point['x'])
                                             * self.scaling_factor) + x_offset
                                    yp = int((-bb['miny'] + point['y'])
                                             * self.scaling_factor) + y_offset
                                    xp = max(0, xp)
                                    yp = max(0, yp)
                                    x.append(pix[xp, yp])
                        last_point = point
                    else:
                        x.append(self.fill_empty_with)
                        x.append(self.fill_empty_with)
                        if self.pixel_env > 0:
                            for i in range((1 + 2 * self.pixel_env)**2):
                                x.append(self.fill_empty_with)
            else:
                for _ in range(self.points_per_stroke):
                    x.append(self.fill_empty_with)
                    x.append(self.fill_empty_with)
                    if self.pixel_env > 0:
                        for i in range((1 + 2 * self.pixel_env)**2):
                            x.append(self.fill_empty_with)
        del draw
        return x
1347564
function drawMathLine(i,lineFct) {
		var line = 0;
		// check if the math function exists
		if (typeof eval(lineFct) == "function") {
			var parameter = {data:data,datasetNr: i};
			line = window[lineFct](parameter);
		 }
		if (!(typeof(line)=='undefined')) {
			ctx.strokeStyle= data.datasets[i].mathLineStrokeColor ? data.datasets[i].mathLineStrokeColor : config.defaultStrokeColor;
			ctx.lineWidth = config.datasetStrokeWidth;
			ctx.beginPath();
			ctx.moveTo(yAxisPosX,yPos(i,0,line,false));
			ctx.lineTo(yAxisPosX + msr.availableWidth,yPos(i,data.datasets[i].data.length-1,line,false));
			ctx.stroke();
			ctx.closePath();
		}
	}
786468
private function drawAscii()
    {
        $fail = [
            '(╯°□°）╯︵ ┻━┻',
            '¯\_(ツ)_/¯',
            '┻━┻︵ \(°□°)/ ︵ ┻━┻',
            '(ಠ_ಠ)',
            '(ノಠ益ಠ)ノ彡',
            '(✖﹏✖)'
        ];

        $pass = [
            '☜(ﾟヮﾟ☜)',
            '♪ヽ( ⌒o⌒)人(⌒-⌒ )v ♪',
            '┗(^-^)┓',
            'ヽ(^。^)ノ',
            'ヽ(^▽^)v'
        ];

        if (count($this->failures)) {
            $key = array_rand($fail, 1);
            $this->console->writeLn($fail[$key]);
        } else {
            $key = array_rand($pass, 1);
            $this->console->writeLn($pass[$key]);
        }
    }
856786
private void drawInterfere(Graphics2D g) {
		final ThreadLocalRandom random = RandomUtil.getRandom();
		// 干扰线
		for (int i = 0; i < this.interfereCount; i++) {
			int xs = random.nextInt(width);
			int ys = random.nextInt(height);
			int xe = xs + random.nextInt(width / 8);
			int ye = ys + random.nextInt(height / 8);
			g.setColor(ImgUtil.randomColor(random));
			g.drawLine(xs, ys, xe, ye);
		}
	}
428238
function drawTooltip(){
            tooltipTextContainer = svg.selectAll('.tooltip-group')
              .append('g')
                .classed('tooltip-text', true);

            tooltip = tooltipTextContainer
              .append('rect')
                .classed('tooltip-text-container', true)
                .attr('x', -tooltipWidth / 4 + 8)
                .attr('y', 0)
                .attr('width', tooltipWidth)
                .attr('height', tooltipHeight)
                .attr('rx', tooltipBorderRadius)
                .attr('ry', tooltipBorderRadius)
                .style('fill', bodyFillColor)
                .style('stroke', borderStrokeColor)
                .style('stroke-width', 1);

            tooltipTitle = tooltipTextContainer
              .append('text')
                .classed('tooltip-title', true)
                .attr('x', -tooltipWidth / 4 + 16)
                .attr('dy', '.35em')
                .attr('y', 16)
                .style('fill', titleFillColor);

            tooltipDivider = tooltipTextContainer
              .append('line')
                .classed('tooltip-divider', true)
                .attr('x1', -tooltipWidth / 4 + 16)
                .attr('x2', 265)
                .attr('y1', 31)
                .attr('y2', 31)
                .style('stroke', borderStrokeColor);

            tooltipBody = tooltipTextContainer
              .append('g')
                .classed('tooltip-body', true)
                .style('transform', 'translateY(8px)')
                .style('fill', textFillColor);
        }
378192
def set_stroke(self, width=1, color='black'):
        
        self.attributes['stroke'] = color
        self.attributes['stroke-width'] = str(width)
1196493
function drawLine(dom, point, width) {
      dom.append('line')
        .attr('x1', 0)
        .attr('y1', point)
        .attr('x2', width)
        .attr('y2', point)
        .attr('stroke-width', lineWidth)
        .attr('stroke', lineColor);
    }
662983
function reducePath(contour) {

            if (!contour.length) {
                return contour;
            }

            var prev;
            var next;
            var p;
            for (var i = contour.length - 1, last = i; i >= 0; i--) {

                // 这里注意逆序
                p = contour[i];
                next = i === last ? contour[0] : contour[i + 1];
                prev = i === 0 ? contour[last] : contour[i - 1];

                if (redundant(prev, p, next)) {
                    contour.splice(i, 1);
                    last--;
                    continue;
                }
            }

            return contour;
        }