Advertisement
Guest User

jorge4-raylib.f

a guest
Jan 24th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.64 KB | None | 0 0
  1. \
  2. \ JANAITE 20200123
  3. \ A simple hello of Raylib v.2.5
  4. \ FROM: https://www.raylib.com/examples.html
  5. \ MUDANÇAS &&& POR PeterForth 25-1-2020
  6.  
  7. REQUIRE CAPI: lib\win\api-call\capi.f
  8. REQUIRE ALIAS devel\~moleg\lib\util\alias.f
  9.  
  10. \ &&& TEM QUE SE LLAMAR GRAPHICS O GRAPHICA O ALGUMA COISA
  11. \ PARECIDA
  12.  
  13. VOCABULARY GRAPHICS ALSO GRAPHICS DEFINITIONS
  14.  
  15. 3 CAPI: InitWindow libraylib.dll
  16. 0 CAPI: WindowShouldClose libraylib.dll
  17. 0 CAPI: CloseWindow libraylib.dll
  18.  
  19. 0 CAPI: BeginDrawing libraylib.dll
  20. 1 CAPI: ClearBackground libraylib.dll
  21. 5 CAPI: DrawText libraylib.dll
  22. 0 CAPI: EndDrawing libraylib.dll
  23. 1 CAPI: SetTargetFPS libraylib.dll
  24.  
  25. 5 CAPI: DrawLine libraylib.dll
  26. 4 CAPI: DrawCircle libraylib.dll
  27.  
  28. 5 CAPI: DrawRectangle libraylib.dll
  29. 5 CAPI: DrawRectangleLines libraylib.dll
  30. 6 CAPI: DrawRectangleGradientH libraylib.dll
  31.  
  32. \ WINAPI: DrawCircleGradient libraylib.dll
  33. \ WINAPI: DrawCircleLines libraylib.dll
  34. \ WINAPI: DrawTriangle libraylib.dll
  35.  
  36. \ output ARGB with 8 bit each color component
  37.  
  38. \ DECIMAL
  39.  
  40. : >RGBA ( r g b a -- u )
  41. 24 LSHIFT SWAP
  42. 16 LSHIFT OR SWAP
  43. 8 LSHIFT OR SWAP
  44. OR CONSTANT ;
  45.  
  46. \ &&&&&&=====AGREGUEI===precisa !==========================
  47.  
  48. DECIMAL
  49.  
  50. \ S" lib\include\float2.f" INCLUDED
  51. \ &&& LIBRARIA FLOATING POINT forthwin1.1 ya tem
  52.  
  53. : F>FL ( -> f ) ( F: f -> )
  54. [
  55. 0x8D C, 0x6D C, 0xFC C,
  56. 0xD9 C, 0x5D C, 0x00 C,
  57. 0x87 C, 0x45 C, 0x00 C,
  58. 0xC3 C, ] ;
  59.  
  60. \ Number of float from float stack to data stack
  61. : F>DL ( -> d ) ( F: f -> )
  62. FLOAT>DATA SWAP ;
  63.  
  64. \ Convert number on stack to float
  65. : S>FL ( n -> f )
  66. DS>F F>FL ;
  67.  
  68. \ Convert number on stack to double
  69. : S>DL ( n -> d )
  70. DS>F F>DL ;
  71. \ =======================================================
  72.  
  73. \ constants from raylib.h
  74. 200 200 200 255 >RGBA #LIGHTGRAY \ Light Gray
  75. 130 130 130 255 >RGBA #GRAY \ Gray
  76. 80 80 80 255 >RGBA #DARKGRAY \ Dark Gray
  77. 253 249 0 255 >RGBA #YELLOW \ Yellow
  78. 255 203 0 255 >RGBA #GOLD \ Gold
  79. 255 161 0 255 >RGBA #ORANGE \ Orange
  80. 255 109 194 255 >RGBA #PINK \ Pink
  81. 230 41 55 255 >RGBA #RED \ Red
  82. 190 33 55 255 >RGBA #MAROON \ Maroon
  83. 0 228 48 255 >RGBA #GREEN \ Green
  84. 0 158 47 255 >RGBA #LIME \ Lime
  85. 0 117 44 255 >RGBA #DARKGREEN \ Dark Green
  86. 102 191 255 255 >RGBA #SKYBLUE \ Sky Blue
  87. 0 121 241 255 >RGBA #BLUE \ Blue
  88. 0 82 172 255 >RGBA #DARKBLUE \ Dark Blue
  89. 200 122 255 255 >RGBA #PURPLE \ Purple
  90. 135 60 190 255 >RGBA #VIOLET \ Violet
  91. 112 31 126 255 >RGBA #DARKPURPLE \ Dark Purple
  92. 211 176 131 255 >RGBA #BEIGE \ Beige
  93. 127 106 79 255 >RGBA #BROWN \ Brown
  94. 76 63 47 255 >RGBA #DARKBROWN \ Dark Brown
  95. 255 255 255 255 >RGBA #WHITE \ White
  96. 0 0 0 255 >RGBA #BLACK \ Black
  97. 0 0 0 0 >RGBA #BLANK \ Blank (Transparent)
  98. 255 0 255 255 >RGBA #MAGENTA \ Magenta
  99. 245 245 245 255 >RGBA #RAYWHITE
  100.  
  101. : raylibBeginDrawing BeginDrawing DROP ;
  102. : raylibEndDrawing EndDrawing DROP ;
  103. : raylibClearBackground ClearBackground DROP ;
  104. : raylibDrawText DrawText DROP ;
  105. : raylibDrawRectangle DrawRectangle DROP ;
  106. : raylibDrawRectangleLines DrawRectangleLines DROP ;
  107. : raylibDrawRectangleGradientH DrawRectangleGradientH DROP ;
  108.  
  109.  
  110. ALIAS raylibBeginDrawing BeginDraw
  111. ALIAS raylibEndDrawing EndDraw
  112. ALIAS raylibClearBackground ClrBkg
  113. ALIAS raylibDrawText DrawText
  114. ALIAS raylibDrawRectangle DrawRect
  115.  
  116.  
  117. : init
  118. S" raylib example - basic window" DROP 480 640 InitWindow
  119. 60 SetTargetFPS
  120. DROP DROP
  121. ;
  122.  
  123. : mainloop1
  124. BEGIN WindowShouldClose FALSE = WHILE
  125. raylibBeginDrawing
  126. #RAYWHITE raylibClearBackground
  127. #MAGENTA 20 200 190 S" Congrats! You created your first window!" DROP raylibDrawText
  128. raylibEndDrawing
  129. REPEAT ;
  130.  
  131. 640 CONSTANT #WIDTH
  132.  
  133. : mainloop2
  134. BEGIN WindowShouldClose FALSE = WHILE
  135. raylibBeginDrawing
  136. #RAYWHITE raylibClearBackground
  137.  
  138. \ #DARKBLUE +35e0 120 160 #WIDTH 4 / DrawCircle DROP
  139.  
  140. \ DrawCircle ( color fradius centery centerx )
  141.  
  142. \ #DARKBLUE S" +35e0" >FLOAT 120 35 DrawCircle
  143.  
  144. \ ****************************************
  145. #DARKBLUE 35 S>FL 120 35 DrawCircle \ &&& FUNCIONA !!
  146. \ **************______********************
  147. \ s>fl converte um Integer para Float
  148.  
  149.  
  150. \ #DARKBLUE 35.0e 120 35 DrawCircle
  151.  
  152. #RED 60 120 100 #WIDTH 2 / 60 - raylibDrawRectangle
  153. #ORANGE 60 80 320 #WIDTH 2 / 40 - raylibDrawRectangleLines
  154. #GOLD #MAROON 130 180 170 #WIDTH 2 / 90 - raylibDrawRectangleGradientH
  155.  
  156. \ #VIOLET DrawTriangle
  157. \ DrawTriangle((Vector2){screenWidth/4*3, 80},
  158. \ (Vector2){screenWidth/4*3 - 60, 150},
  159. \ (Vector2){screenWidth/4*3 + 60, 150}, VIOLET);
  160. \
  161. \ DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN);
  162. \ #BROWN 0 80 6 ??
  163. \ #SKYBLUE #GREEN 60 220 #WIDTH 4 / DrawCircleGradient
  164.  
  165. \ NOTE: We draw all LINES based shapes together to optimize internal drawing,
  166. \ this way, all LINES are rendered in a single draw pass
  167. \ #BLACK 42 #WIDTH 18 - 42 18 DrawLine
  168.  
  169. \ #DARKBLUE 80 340 #WIDTH 4 / DrawCircleLines
  170.  
  171. \ DrawTriangleLines((Vector2){screenWidth/4*3, 160},
  172. \ (Vector2){screenWidth/4*3 - 20, 230},
  173. \ (Vector2){screenWidth/4*3 + 20, 230}, DARKBLUE);
  174. raylibEndDrawing
  175. REPEAT ;
  176.  
  177. : finish
  178. CloseWindow DROP ;
  179.  
  180. : main init mainloop2 finish ;
  181.  
  182. 1 2 3 main . . .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement