@@ -477,14 +477,8 @@ void QDPlatform_DrawShape(GrafPtr port, GrafVerb verb, const Rect* rect,
477477 /* Draw with pattern */
478478 for (SInt32 y = rect -> top ; y < rect -> bottom ; y ++ ) {
479479 for (SInt32 x = rect -> left ; x < rect -> right ; x ++ ) {
480- /* Get pattern bit (8x8 repeating) */
481- SInt32 patY = (y - rect -> top ) % 8 ;
482- SInt32 patX = (x - rect -> left ) % 8 ;
483- UInt8 patByte = pat -> pat [patY ];
484- Boolean bit = (patByte >> (7 - patX )) & 1 ;
485-
486- /* Use black for 1 bits, white for 0 bits */
487- UInt32 color = bit ? pack_color (0 , 0 , 0 ) : pack_color (255 , 255 , 255 );
480+ UInt32 color = QDPlatform_SelectPatternColor (port , pat , x , y ,
481+ pack_color (0 , 0 , 0 ));
488482 QDPlatform_SetPixel (x + offsetX , y + offsetY , color );
489483 }
490484 }
@@ -524,17 +518,11 @@ void QDPlatform_DrawShape(GrafPtr port, GrafVerb verb, const Rect* rect,
524518 } else if (verb == erase ) {
525519 /* Erase should use port's background pattern, NOT desktop pattern */
526520 if (pat ) {
527- /* Use 1-bit pattern with background color */
521+ /* Use 1-bit pattern with port background color */
528522 for (SInt32 y = rect -> top ; y < rect -> bottom ; y ++ ) {
529523 for (SInt32 x = rect -> left ; x < rect -> right ; x ++ ) {
530- /* Get pattern bit (8x8 repeating) */
531- SInt32 patY = y % 8 ; /* Use absolute position for desktop pattern */
532- SInt32 patX = x % 8 ;
533- UInt8 patByte = pat -> pat [patY ];
534- Boolean bit = (patByte >> (7 - patX )) & 1 ;
535-
536- /* Use black for 1 bits, white for 0 bits */
537- UInt32 color = bit ? pack_color (0 , 0 , 0 ) : pack_color (255 , 255 , 255 );
524+ UInt32 color = QDPlatform_SelectPatternColor (port , pat , x , y ,
525+ pack_color (255 , 255 , 255 ));
538526 QDPlatform_SetPixel (x + offsetX , y + offsetY , color );
539527 }
540528 }
@@ -593,13 +581,21 @@ void QDPlatform_DrawShape(GrafPtr port, GrafVerb verb, const Rect* rect,
593581 !QDPointInEllipse (x , y + 1 , rect );
594582
595583 if (neighborOutside ) {
596- UInt32 color = pack_color (0 , 0 , 0 );
597- if (pat ) {
598- UInt8 patByte = pat -> pat [(y - rect -> top ) & 7 ];
599- Boolean bit = (patByte >> (7 - ((x - rect -> left ) & 7 ))) & 1 ;
600- color = bit ? pack_color (0 , 0 , 0 ) : pack_color (255 , 255 , 255 );
584+ UInt32 color = QDPlatform_SelectPatternColor (port , pat , x , y ,
585+ pack_color (0 , 0 , 0 ));
586+ /* Apply pen size: also fill nearby pixels for thick outlines */
587+ SInt16 penW = port ? (port -> pnSize .h > 1 ? port -> pnSize .h : 1 ) : 1 ;
588+ SInt16 penH = port ? (port -> pnSize .v > 1 ? port -> pnSize .v : 1 ) : 1 ;
589+ for (SInt16 py = 0 ; py < penH ; py ++ ) {
590+ for (SInt16 px = 0 ; px < penW ; px ++ ) {
591+ SInt32 dx = x + px + offsetX ;
592+ SInt32 dy = y + py + offsetY ;
593+ if (dx >= 0 && dx < (SInt32 )fb_width &&
594+ dy >= 0 && dy < (SInt32 )fb_height ) {
595+ QDPlatform_SetPixel (dx , dy , color );
596+ }
597+ }
601598 }
602- QDPlatform_SetPixel (x + offsetX , y + offsetY , color );
603599 }
604600 }
605601 }
@@ -643,14 +639,8 @@ void QDPlatform_DrawShape(GrafPtr port, GrafVerb verb, const Rect* rect,
643639 continue ;
644640 }
645641
646- UInt32 color = fallbackColor ;
647- if (pat ) {
648- SInt32 patY = (verb == paint ) ? ((y - rect -> top ) & 7 ) : (y & 7 );
649- SInt32 patX = (verb == paint ) ? ((x - rect -> left ) & 7 ) : (x & 7 );
650- UInt8 patByte = pat -> pat [patY ];
651- Boolean bit = (patByte >> (7 - patX )) & 1 ;
652- color = bit ? pack_color (0 , 0 , 0 ) : pack_color (255 , 255 , 255 );
653- }
642+ UInt32 color = pat ? QDPlatform_SelectPatternColor (port , pat , x , y , fallbackColor )
643+ : fallbackColor ;
654644
655645 if (verb == erase && pat == NULL ) {
656646 color = pack_color (255 , 255 , 255 );
@@ -681,14 +671,8 @@ void QDPlatform_DrawShape(GrafPtr port, GrafVerb verb, const Rect* rect,
681671
682672 if (!neighborOutside ) continue ;
683673
684- UInt32 color = pack_color (0 , 0 , 0 );
685- if (pat ) {
686- SInt32 patY = (y - rect -> top ) & 7 ;
687- SInt32 patX = (x - rect -> left ) & 7 ;
688- UInt8 patByte = pat -> pat [patY ];
689- Boolean bit = (patByte >> (7 - patX )) & 1 ;
690- color = bit ? pack_color (0 , 0 , 0 ) : pack_color (255 , 255 , 255 );
691- }
674+ UInt32 color = QDPlatform_SelectPatternColor (port , pat , x , y ,
675+ pack_color (0 , 0 , 0 ));
692676
693677 if (mode == patXor ) {
694678 UInt32 current = QDPlatform_GetPixel (x + offsetX , y + offsetY );
@@ -731,14 +715,8 @@ void QDPlatform_DrawShape(GrafPtr port, GrafVerb verb, const Rect* rect,
731715 continue ;
732716 }
733717
734- UInt32 color = fallbackColor ;
735- if (pat ) {
736- SInt32 patY = (verb == paint ) ? ((y - rect -> top ) & 7 ) : (y & 7 );
737- SInt32 patX = (verb == paint ) ? ((x - rect -> left ) & 7 ) : (x & 7 );
738- UInt8 patByte = pat -> pat [patY ];
739- Boolean bit = (patByte >> (7 - patX )) & 1 ;
740- color = bit ? pack_color (0 , 0 , 0 ) : pack_color (255 , 255 , 255 );
741- }
718+ UInt32 color = pat ? QDPlatform_SelectPatternColor (port , pat , x , y , fallbackColor )
719+ : fallbackColor ;
742720
743721 if (verb == erase && pat == NULL ) {
744722 color = pack_color (255 , 255 , 255 );
@@ -775,14 +753,8 @@ void QDPlatform_DrawShape(GrafPtr port, GrafVerb verb, const Rect* rect,
775753
776754 if (!isEdge ) continue ;
777755
778- UInt32 color = pack_color (0 , 0 , 0 );
779- if (pat ) {
780- SInt32 patY = (y - rect -> top ) & 7 ;
781- SInt32 patX = (x - rect -> left ) & 7 ;
782- UInt8 patByte = pat -> pat [patY ];
783- Boolean bit = (patByte >> (7 - patX )) & 1 ;
784- color = bit ? pack_color (0 , 0 , 0 ) : pack_color (255 , 255 , 255 );
785- }
756+ UInt32 color = QDPlatform_SelectPatternColor (port , pat , x , y ,
757+ pack_color (0 , 0 , 0 ));
786758
787759 if (mode == patXor ) {
788760 UInt32 current = QDPlatform_GetPixel (x + offsetX , y + offsetY );
@@ -896,17 +868,11 @@ void QDPlatform_FillPoly(GrafPtr port, PolyHandle poly, const Pattern* pat,
896868 UInt32 current = QDPlatform_GetPixel (x , y );
897869 color = current ^ 0x00FFFFFF ;
898870 } else {
899- /* Apply pattern */
900- if (pat ) {
901- SInt32 patY = y & 7 ;
902- SInt32 patX = x & 7 ;
903- UInt8 patByte = pat -> pat [patY ];
904- Boolean bit = (patByte >> (7 - patX )) & 1 ;
905- color = bit ? pack_color (0 , 0 , 0 ) : pack_color (255 , 255 , 255 );
906- } else {
907- color = (verb == erase ) ? pack_color (255 , 255 , 255 )
908- : pack_color (0 , 0 , 0 );
909- }
871+ /* Apply pattern with port colors */
872+ UInt32 fallback = (verb == erase ) ? pack_color (255 , 255 , 255 )
873+ : pack_color (0 , 0 , 0 );
874+ color = pat ? QDPlatform_SelectPatternColor (port , pat , x , y , fallback )
875+ : fallback ;
910876
911877 if (mode == patXor ) {
912878 UInt32 current = QDPlatform_GetPixel (x , y );
@@ -1066,14 +1032,11 @@ void QDPlatform_DrawRegion(RgnHandle rgn, short mode, const Pattern* pat) {
10661032 extern void EraseRect (const Rect * r );
10671033 EraseRect (& r );
10681034 } else if (mode == paint && pat ) {
1069- /* Simple paint with pattern */
1035+ /* Simple paint with pattern using port colors */
10701036 for (int y = r .top ; y < r .bottom ; y ++ ) {
10711037 for (int x = r .left ; x < r .right ; x ++ ) {
1072- int patY = (y - r .top ) % 8 ;
1073- int patX = (x - r .left ) % 8 ;
1074- uint8_t patByte = pat -> pat [patY ];
1075- bool bit = (patByte >> (7 - patX )) & 1 ;
1076- uint32_t color = bit ? pack_color (0 , 0 , 0 ) : pack_color (255 , 255 , 255 );
1038+ uint32_t color = QDPlatform_SelectPatternColor (port , pat , x , y ,
1039+ pack_color (0 , 0 , 0 ));
10771040 QDPlatform_SetPixel (x , y , color );
10781041 }
10791042 }
@@ -1100,12 +1063,8 @@ void QDPlatform_DrawRegion(RgnHandle rgn, short mode, const Pattern* pat) {
11001063 for (int y = top ; y < bottom ; y ++ ) {
11011064 for (int x = left ; x < right ; x ++ ) {
11021065 /* Use position for pattern tiling (8x8 repeat) */
1103- int patY = y % 8 ;
1104- int patX = x % 8 ;
1105- uint8_t patByte = pat -> pat [patY ];
1106- bool bit = (patByte >> (7 - patX )) & 1 ;
1107- /* Pattern: 0=white, 1=black */
1108- uint32_t color = bit ? pack_color (0 , 0 , 0 ) : pack_color (255 , 255 , 255 );
1066+ uint32_t color = QDPlatform_SelectPatternColor (port , pat , x , y ,
1067+ pack_color (0 , 0 , 0 ));
11091068
11101069 /* Write to appropriate location */
11111070 if (isDirectFB ) {
0 commit comments