geometry

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 8 Imported by: 0

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

View Source
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.

View Source
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.

View Source
const (
	PrimaryFont  = "monasans-medium.ttf"
	FallbackFont = "monasans-regular.ttf"
)

Font file paths for text rendering.

View Source
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

func CalculateMultiYearDimensions(yearCount int) (width, depth float64)

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

func CreateColumn(x, y, height, size float64) ([]types.Triangle, error)

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

func CreateCube(x, y, z, width, height, depth float64) ([]types.Triangle, error)

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

func CreateCuboidBase(width, depth float64) ([]types.Triangle, error)

CreateCuboidBase generates triangles for a rectangular base.

func CreateQuad

func CreateQuad(v1, v2, v3, v4 types.Point3D) ([]types.Triangle, error)

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

func GenerateImageGeometry(innerWidth, baseHeight float64) ([]types.Triangle, error)

GenerateImageGeometry creates 3D geometry from the embedded logo image.

func NormalizeContribution

func NormalizeContribution(count, maxCount int) float64

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

type ModelDimensions struct {
	InnerWidth float64
	InnerDepth float64
}

ModelDimensions defines the inner dimensions of the model.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL