Как к цвету заливки на треугольнике

Используйте метод замены со строкой выбора.

РЕДАКТИРОВАТЬ: После внимательного прочтения я вижу, что вы хотели противоположную строку Вот и то, и другое.

using System;
using System.Text.RegularExpressions;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string Source = @"H)*e/.?l\l{}*o ][W!~`@#""or^-_=+ld!";
            string Trash = @"[^a-zA-Z0-9]";
            string InvertedTrash = @"[a-zA-Z0-9]";

            Output(Source, Trash);
            Console.WriteLine($"{System.Environment.NewLine}Opposite Day!{System.Environment.NewLine}");
            Output(Source, InvertedTrash);
            Console.ReadKey();
        }
        static string TakeOutTheTrash(string Source, string Trash)
        {
            return (new Regex(Trash)).Replace(Source, string.Empty);
        }
        static void Output(string Source, string Trash)
        {
            string Sanitized = TakeOutTheTrash(Source, Trash);
            Console.WriteLine($"Started with: {Source}");
            Console.WriteLine($"Ended with: {Sanitized}");
        }
    }
}
6
задан user1118321 5 March 2015 в 14:42
поделиться

2 ответа

Сделайте a Polygon от вершин и заливки это вместо этого, путем вызова fillPolygon(...):

// A simple triangle.
x[0]=100; x[1]=150; x[2]=50;
y[0]=100; y[1]=150; y[2]=150;
n = 3;

Polygon p = new Polygon(x, y, n);  // This polygon represents a triangle with the above
                                   //   vertices.

g.fillPolygon(p);     // Fills the triangle above.
18
ответ дан 8 December 2019 в 04:10
поделиться

Необходимо указать вершины полигона (в этом случае, треугольник) и передать fillPolygon():

  public void paint(Graphics g) 
  {
    int xpoints[] = {25, 145, 25, 145, 25};
    int ypoints[] = {25, 25, 145, 145, 25};
    int npoints = 5;

    g.fillPolygon(xpoints, ypoints, npoints);
  }
8
ответ дан 8 December 2019 в 04:10
поделиться
Другие вопросы по тегам:

Похожие вопросы: