@@ -6,7 +6,7 @@ type PixelInput = {
6
6
totalCols : number ;
7
7
screenX : number ;
8
8
screenWidth : number ;
9
- alignment : 'left' | 'right' ;
9
+ alignment : 'left' | 'right' | 'full' ;
10
10
emptyRatio : number ;
11
11
colors : readonly string [ ] ;
12
12
} ;
@@ -23,7 +23,9 @@ export function createPixelPattern(input: PixelInput): string | null {
23
23
normalizedScreenX ,
24
24
normalizedY ,
25
25
input . alignment ,
26
- input . emptyRatio
26
+ input . emptyRatio ,
27
+ input . col ,
28
+ input . totalCols
27
29
) ;
28
30
29
31
return isEmpty ? null : getRandomColor ( input . colors ) ;
@@ -34,35 +36,56 @@ export function createPixelPattern(input: PixelInput): string | null {
34
36
function shouldPixelBeEmpty (
35
37
_normalizedX : number , // Container position (unused, kept for future use)
36
38
normalizedScreenX : number ,
37
- normalizedY : number ,
38
- alignment : 'left' | 'right' ,
39
- emptyRatio : number
39
+ _normalizedY : number , // Not used in this implementation
40
+ alignment : 'left' | 'right' | 'full' ,
41
+ _emptyRatio : number , // Not used in simple split
42
+ col : number ,
43
+ totalCols : number
40
44
) : boolean {
41
- const boundary = calculateBoundary ( normalizedY , emptyRatio ) ;
42
-
45
+ // For 'full' alignment, stretch the grid to 100% with no empty zones
46
+ if ( alignment === 'full' ) {
47
+ return false ; // Show all pixels across the entire grid
48
+ }
49
+
50
+ // 60/40 split - pixels appear on opposite side of alignment with more coverage
51
+ const splitPoint = 0.45 ; // 40% threshold means 60% coverage on the opposite side
52
+
53
+ let shouldHideBasedOnAlignment = false ;
54
+
43
55
if ( alignment === 'right' ) {
44
- return normalizedScreenX > boundary ? hasGhostPixel ( ) : hasScatterEffect ( normalizedScreenX , boundary , normalizedY ) ;
56
+ // For right alignment: show pixels on the LEFT 60% (inverted)
57
+ shouldHideBasedOnAlignment = normalizedScreenX > splitPoint ;
45
58
} else {
46
- return normalizedScreenX < boundary ? hasGhostPixel ( ) : hasScatterEffect ( normalizedScreenX , boundary , normalizedY ) ;
59
+ // For left alignment: show pixels on the RIGHT 60% (inverted)
60
+ shouldHideBasedOnAlignment = normalizedScreenX < splitPoint ;
47
61
}
48
- }
49
-
50
- function calculateBoundary ( normalizedY : number , emptyRatio : number ) : number {
51
- const waveOffset = Math . sin ( normalizedY * Math . PI * 3 ) * 0.1 ;
52
- const randomOffset = ( Math . random ( ) - 0.5 ) * 0.15 ;
53
- return emptyRatio + waveOffset + randomOffset ;
54
- }
55
-
56
- function hasScatterEffect ( screenX : number , boundary : number , normalizedY : number ) : boolean {
57
- const distance = Math . abs ( screenX - boundary ) ;
58
- const scatterChance = Math . pow ( 1 - distance / boundary , 2 ) * 0.25 ;
59
- const rowVariation = Math . sin ( normalizedY * Math . PI * 2 ) * 0.1 ;
60
62
61
- return Math . random ( ) < ( scatterChance + rowVariation ) ;
62
- }
63
-
64
- function hasGhostPixel ( ) : boolean {
65
- return Math . random ( ) >= 0.3 ;
63
+ // If already hidden by alignment, return true
64
+ if ( shouldHideBasedOnAlignment ) {
65
+ return true ;
66
+ }
67
+
68
+ // Apply random hiding to only the last column of the visible area
69
+ const splitCol = Math . floor ( totalCols * splitPoint ) ; // Column where the split happens
70
+ let shouldApplyRandomHiding = false ;
71
+
72
+ if ( alignment === 'right' ) {
73
+ // For right alignment: pixels show on LEFT side (cols 0 to splitCol)
74
+ // Target only the last visible column (rightmost edge of visible area)
75
+ const isLastVisibleColumn = col === splitCol ;
76
+ shouldApplyRandomHiding = isLastVisibleColumn ;
77
+ } else {
78
+ // For left alignment: pixels show on RIGHT side (cols splitCol to totalCols)
79
+ // Target only the first visible column (leftmost edge of visible area)
80
+ const isFirstVisibleColumn = col === splitCol + 1 ;
81
+ shouldApplyRandomHiding = isFirstVisibleColumn ;
82
+ }
83
+
84
+ if ( shouldApplyRandomHiding ) {
85
+ return Math . random ( ) < 0.50 ; // 40% chance for random gaps in the target column
86
+ }
87
+
88
+ return false ; // All other visible pixels are shown
66
89
}
67
90
68
91
function getRandomColor ( colors : readonly string [ ] ) : string {
0 commit comments