Area fill pattern

6 posts / 0 new
Last post
trixie
trixie's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 2011-02-03 13:58
Area fill pattern

I'm trying to draw a fill pattern that is supposed to look like the one that checkbox.gadget displays when disabled (ghosted). What would the area fill pattern definition look like? I need to pass this definition as an argument to the SetAfPt() macro, or alternatively, as a tag value to the fillrect image class.

thomas
thomas's picture
Offline
Last seen: 1 week 20 hours ago
Joined: 2011-05-16 14:23
Re: Area fill pattern
  1. UWORD pattern[] = {0x1111,0x4444};
  2.  
  3. SetAfPt (rp,pattern,1);
trixie
trixie's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: Area fill pattern

@thomas

Thanks a lot - will try it out.

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

trixie
trixie's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: Area fill pattern

@thomas

I'm calling SetAfPt() with the parameters as advised. The call is preceded by a SetAPen() and followed by a RectFill(). Nothing seems to be drawn. Are any other settings necessary?

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

thomas
thomas's picture
Offline
Last seen: 1 week 20 hours ago
Joined: 2011-05-16 14:23
Re: Area fill pattern

This works for me:

  1. #include <graphics/gfxmacros.h>
  2. #undef GetOutlinePen
  3.  
  4. #include <proto/dos.h>
  5. #include <proto/exec.h>
  6. #include <proto/graphics.h>
  7. #include <proto/intuition.h>
  8.  
  9.  
  10. void fill_window (struct Window *win)
  11.  
  12. {
  13. static const UWORD pattern[] = {
  14. 0x8888,0x2222,0x4444,0x1111
  15. };
  16.  
  17. SetABPenDrMd (win->RPort,2,3,JAM2);
  18.  
  19. SetAfPt (win->RPort,(UWORD *)pattern,2);
  20.  
  21. RectFill (win->RPort,win->BorderLeft,win->BorderTop,
  22. win->BorderLeft + win->GZZWidth - 1,
  23. win->BorderTop + win->GZZHeight - 1);
  24.  
  25. SetAfPt (win->RPort,NULL,0);
  26. }
  27.  
  28.  
  29. int main (void)
  30. {
  31. struct Window *win;
  32.  
  33. if ((win = OpenWindowTags (NULL,
  34. WA_Left,80,
  35. WA_Top,80,
  36. WA_Width,400,
  37. WA_Height,120,
  38. WA_Title,"Pattern Fill Demo",
  39. WA_Flags,WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_SIZEGADGET | WFLG_SIZEBBOTTOM | WFLG_ACTIVATE | WFLG_SIMPLE_REFRESH,
  40. WA_IDCMP,IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | IDCMP_REFRESHWINDOW,
  41. WA_MinWidth,80,
  42. WA_MinHeight,60,
  43. WA_MaxWidth,0x7fff,
  44. WA_MaxHeight,0x7fff,
  45. TAG_END)))
  46. {
  47. BOOL cont = TRUE;
  48. struct IntuiMessage *imsg;
  49.  
  50. fill_window (win);
  51.  
  52. do {
  53. if (Wait ((1L << win->UserPort->mp_SigBit) | SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
  54. cont = FALSE;
  55.  
  56. while ((imsg = (struct IntuiMessage *) GetMsg (win->UserPort)))
  57. {
  58. switch (imsg->Class)
  59. {
  60. case IDCMP_REFRESHWINDOW:
  61. BeginRefresh (win);
  62. fill_window (win);
  63. EndRefresh (win,TRUE);
  64. break;
  65. case IDCMP_VANILLAKEY:
  66. if (imsg->Code == 0x1b) /* Esc */
  67. cont = FALSE;
  68. break;
  69. case IDCMP_CLOSEWINDOW:
  70. cont = FALSE;
  71. break;
  72. }
  73. ReplyMsg ((struct Message *)imsg);
  74. }
  75. }
  76. while (cont);
  77.  
  78. CloseWindow (win);
  79. }
  80. else
  81. Printf ("cannot open window\n");
  82.  
  83. return (RETURN_OK);
  84. }
trixie
trixie's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: Area fill pattern

@thomas

Thanks again, works fine now. In the end it was a typical late-night coding error: my settings were correct but I overlooked a wrong coordinate for RectFill(). Doh!

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

Log in or register to post comments