2 * Sixth - System for data storage, computation, exploration and interaction.
3 * Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 3 of the GNU Lesser General Public License
7 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic;
12 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
13 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
14 import eu.svjatoslav.sixth.e3d.renderer.raster.texture.Texture;
16 public class GlowingPoint extends ForwardOrientedTexture {
18 private static final int TEXTURE_SIZE = 50;
19 private final Color color;
21 public GlowingPoint(final Point3D point, final double pointSize,
23 super(point, pointSize, getTexture(color));
30 public static Texture getTexture(final Color color) {
31 final Texture texture = new Texture(TEXTURE_SIZE, TEXTURE_SIZE, 1);
32 for (int x = 0; x < TEXTURE_SIZE; x++)
33 for (int y = 0; y < TEXTURE_SIZE; y++) {
34 int address = texture.primaryBitmap.getAddress(x, y);
36 final int distance = (int) Math
37 .sqrt((((TEXTURE_SIZE / 2) - x) * ((TEXTURE_SIZE / 2) - x))
38 + (((TEXTURE_SIZE / 2) - y) * ((TEXTURE_SIZE / 2) - y)));
40 int alpha = 255 - ((270 * distance) / (TEXTURE_SIZE / 2));
44 texture.primaryBitmap.bytes[address] = (byte) alpha;
46 texture.primaryBitmap.bytes[address] = (byte) color.b;
48 texture.primaryBitmap.bytes[address] = (byte) color.g;
50 texture.primaryBitmap.bytes[address] = (byte) color.r;