Java Graphics Draw drawBeamVariableRadiusVertical(Graphics g, Color c, int midx, int y1, int y2, int r1, int r2)

Here you can find the source of drawBeamVariableRadiusVertical(Graphics g, Color c, int midx, int y1, int y2, int r1, int r2)

Description

draw Beam Variable Radius Vertical

License

BSD License

Declaration

public static void drawBeamVariableRadiusVertical(Graphics g, Color c, int midx, int y1, int y2, int r1,
            int r2) 

Method Source Code

//package com.java2s;
/***//from   w  ww  .ja  v a2s . c o m
 * Copyright (C) 2010 Johan Henriksson
 * This code is under the Endrov / BSD license. See www.endrov.net
 * for the full text and how to cite.
 */

import java.awt.Color;
import java.awt.Graphics;

public class Main {
    public static void drawBeamVariableRadiusVertical(Graphics g, Color c, int midx, int y1, int y2, int r1,
            int r2) {
        float[] carr = c.getRGBColorComponents(null);
        for (int y = y1; y < y2; y++) {
            double fact = (y - y1) / (double) (y2 - y1);
            int hereBeamR = (int) ((1 - fact) * r1 + fact * r2);

            for (int i = -hereBeamR; i < hereBeamR; i++) {
                double weight = 1 - Math.abs(i) / (double) hereBeamR;
                g.setColor(new Color(carr[0], carr[1], carr[2], (float) weight));
                g.drawLine(midx + i, y, midx + i, y);
            }
        }
    }
}

Related

  1. drawAndFill(Graphics g, Shape s, Color draw, Color fill)
  2. drawAngledLine(Graphics g, int x, int y, double angle, int length)
  3. drawAt(final Graphics2D g, final double x, final double y, final Shape s)
  4. drawAutoCompleteMarker(Graphics2D g2, int x, int y, int iconSize)
  5. drawBeamsplit(Graphics g, int midx, int midy, Color cup, Color cdown, Color cright, boolean showMirror, boolean isDichroic)
  6. drawBoundary(Graphics2D g2d, Rectangle bounds, Point2D.Double[] pts)
  7. drawBoxOrBlockChar(Graphics g, int x, int y, int bi, char c, int charWidth, int charHeight)
  8. drawBubbleHead(Graphics2D g, Point2D headPosition, double orientation, double size, Color color, Stroke stroke)
  9. drawBubbles(Graphics g, int nCode)