Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.Canvas;

import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;

public class Main {
    /**
     * Helper method to draw a generic triangle onto the canvas
     * @param canvas the canvas being drawn to
     * @param a point 1
     * @param b point 2
     * @param c point 3
     */
    public static void drawTriangle(Canvas canvas, Point a, Point b, Point c, Paint paint) {

        Path path = new Path();
        path.setFillType(Path.FillType.EVEN_ODD);
        path.moveTo(b.x, b.y);
        path.lineTo(c.x, c.y);
        path.lineTo(a.x, a.y);
        path.close();

        canvas.drawPath(path, paint);
    }
}