Documentation ¶
Overview ¶
Package geometry provides 3D geometry generation functions for STL models.
Package geometry provides 3D geometry manipulation functions for generating STL models.
Index ¶
- Constants
- func CalculateMultiYearDimensions(yearCount int) (width, depth float64)
- func Create3DText(username string, year string, innerWidth, baseHeight float64) ([]types.Triangle, error)
- func CreateColumn(x, y, height, size float64) ([]types.Triangle, error)
- func CreateContributionGeometry(contributions [][]types.ContributionDay, yearIndex int, maxContrib int) ([]types.Triangle, error)
- func CreateCube(x, y, z, width, height, depth float64) ([]types.Triangle, error)
- func CreateCuboidBase(width, depth float64) ([]types.Triangle, error)
- func CreateQuad(v1, v2, v3, v4 types.Point3D) ([]types.Triangle, error)
- func GenerateImageGeometry(innerWidth, baseHeight float64) ([]types.Triangle, error)
- func NormalizeContribution(count, maxCount int) float64
- type ModelDimensions
Constants ¶
const ( BaseHeight float64 = 10.0 // Height of the base in model units MaxHeight float64 = 25.0 // Maximum height for contribution columns CellSize float64 = 2.5 // Size of each contribution cell GridSize int = 53 // Number of weeks in a year BaseThickness float64 = 10.0 // Total thickness of the base MinHeight float64 = CellSize // Minimum height for any contribution column )
Model dimension constants define the basic measurements for the 3D model.
const ( TextPadding float64 = CellSize * 2 // Increased padding TextWidthPct float32 = 0.6 // Reduced to ensure text fits TextDepth float64 = 2.0 * CellSize // More prominent depth )
Text rendering constants control the appearance and positioning of text.
const ( PrimaryFont = "monasans-medium.ttf" FallbackFont = "monasans-regular.ttf" )
Font file paths for text rendering.
const ( YearSpacing float64 = 0.0 // Remove gap between years YearOffset float64 = 7.0 * CellSize )
Additional constants for year range styling
Variables ¶
This section is empty.
Functions ¶
func CalculateMultiYearDimensions ¶
CalculateMultiYearDimensions calculates dimensions for multiple years
func Create3DText ¶
func Create3DText(username string, year string, innerWidth, baseHeight float64) ([]types.Triangle, error)
Create3DText generates 3D text geometry for the username and year.
func CreateColumn ¶
CreateColumn generates triangles for a vertical column at the specified position. The column extends from the base height to the specified height.
func CreateContributionGeometry ¶
func CreateContributionGeometry(contributions [][]types.ContributionDay, yearIndex int, maxContrib int) ([]types.Triangle, error)
CreateContributionGeometry generates geometry for a single year's contributions
func CreateCube ¶
CreateCube generates triangles forming a cube at the specified position with given dimensions. The cube is created in a right-handed coordinate system where:
- X increases to the right
- Y increases moving away from the viewer
- Z increases moving upward
The specified position (x,y,z) defines the front bottom left corner of the cube. Returns a slice of triangles that form all six faces of the cube.
func CreateCuboidBase ¶
CreateCuboidBase generates triangles for a rectangular base.
func CreateQuad ¶
CreateQuad creates two triangles forming a quadrilateral from four vertices. Returns an error if the vertices form a degenerate quad or contain invalid coordinates.
func GenerateImageGeometry ¶
GenerateImageGeometry creates 3D geometry from the embedded logo image.
func NormalizeContribution ¶
NormalizeContribution converts a contribution count to a normalized height value. Returns 0 for no contributions, or a value between MinHeight and MaxHeight for active contributions.
Types ¶
type ModelDimensions ¶
ModelDimensions defines the inner dimensions of the model.