Class Line
java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.Line
A 3D line segment with perspective-correct width and alpha blending.
This class represents a line between two 3D points, rendered with a specified width that adjusts based on perspective (distance from the viewer). The line is drawn using interpolators to handle edge cases and alpha blending for transparency effects.
The rendering algorithm: 1. For thin lines (below a threshold), draws single-pixel lines with alpha adjustment based on perspective. 2. For thicker lines, creates four interpolators to define the line's rectangular area and fills it scanline by scanline.
Note: The width is scaled by the LINE_WIDTH_MULTIPLIER and adjusted based on the distance from the viewer (z-coordinate) to maintain a consistent visual size.
-
Field Summary
FieldsModifier and TypeFieldDescriptionColor of the line.final doublewidth of the line.Fields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape
onScreenZ, shapeId, verticesFields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
mouseInteractionController -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidpaint(RenderingContext buffer) Renders this line to the screen using perspective-correct width and alpha blending.Methods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape
getZ, transformMethods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
setMouseInteractionController
-
Field Details
-
width
public final double widthwidth of the line. -
color
Color of the line.
-
-
Constructor Details
-
Line
Creates a copy of an existing line with cloned coordinates and color.- Parameters:
parentLine- the line to copy
-
Line
Creates a line between two points with the specified color and width.- Parameters:
point1- the starting point of the linepoint2- the ending point of the linecolor- the color of the linewidth- the width of the line in world units
-
-
Method Details
-
paint
Renders this line to the screen using perspective-correct width and alpha blending.This method handles two rendering modes:
- Thin lines: When the projected width is below threshold, draws single-pixel lines with alpha adjusted for sub-pixel appearance.
- Thick lines: Creates four edge interpolators and fills the rectangular area scanline by scanline with perspective-correct alpha fading at edges.
- Specified by:
paintin classAbstractCoordinateShape- Parameters:
buffer- the rendering context containing the pixel buffer
-