Author Topic: Line + Draw  (Read 6669 times)

0 Members and 1 Guest are viewing this topic.

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Line + Draw
« Reply #15 on: September 27, 2020, 02:56:24 pm »
Hmmmm....looks a lot like my VQB_Frame command!

Code: QB64: [Select]
  1. SUB VQB_Frame (X%, Y%, Width%, Height%, CLR&)
  2. OldCLR& = CLR&
  3. LINE (X%, Y%)-(X% + Width%, Y% + Height%), CLR&, BF
  4. FOR Border% = 0 TO 4
  5.   IF CLR& > _RGB(0, 0, 0) THEN
  6.     NewRed& = _RED(CLR&) - (6 * Border%)
  7.     NewGreen& = _GREEN(CLR&) - (6 * Border%)
  8.     NewBlue& = _BLUE(CLR&) - (6 * Border%)
  9.     CLR& = _RGB(NewRed&, NewGreen&, NewBlue&)
  10.   ELSE
  11.     NewRed& = _RED(CLR&) + (6 * Border%)
  12.     NewGreen& = _GREEN(CLR&) + (6 * Border%)
  13.     NewBlue& = _BLUE(CLR&) + (6 * Border%)
  14.     CLR& = _RGBA(NewRed&, NewGreen&, NewBlue&, 120)
  15.   END IF
  16.   LINE (X% - Border%, Y% - Border%)-(X% + Width% + Border%, Y% - Border%), CLR&, BF
  17.   LINE (X% - Border%, Y% + Height% + Border%)-(X% + Width% + Border%, Y% + Height% + Border%), CLR&, BF
  18.   LINE (X% - Border%, Y% - Border%)-(X% - Border%, Y% + Height% + Border%), CLR&, BF
  19.   LINE (X% + Width% + Border%, Y% - Border%)-(X% + Width% + Border%, Y% + Height% + Border%), CLR&, BF
  20. CLR& = OldCLR&

I found this on my dropbox the other day, the code is ten years old but should still be good for shapes and lines etc...

Code: QB64: [Select]
  1. SUB GDK_Triangle (x1%, y1%, x2%, y2%, x3%, y3%, CLR&)
  2. LINE (x1%, y1%)-(x2%, y2%), CLR&
  3. LINE (x1%, y1%)-(x3%, y3%), CLR&
  4. LINE (x2%, y2%)-(x3%, y3%), CLR&
  5.  
  6.  
  7. SUB GDK_TriangleFill (x1%, y1%, x2%, y2%, x3%, y3%, CLR&, FillCLR&)
  8. LINE (x1%, y1%)-(x2%, y2%), CLR&
  9. LINE (x1%, y1%)-(x3%, y3%), CLR&
  10. LINE (x2%, y2%)-(x3%, y3%), CLR&
  11. paintx% = (x1% + x2% + x3%) / 3
  12. painty% = (y1% + y2% + y3%) / 3
  13. PAINT (paintx%, painty%), FillCLR&, CLR&
  14.  
  15.  
  16. SUB GDK_Ellipse (X%, Y%, XRadius!, YRadius!, CLR&)
  17. IF XRadius! > YRadius! THEN Radius! = XRadius! ELSE Radius! = YRadius!
  18. MinStep! = 1 / (2 * 3.1415926535 * Radius!)
  19. FOR i = 0 TO 8 * ATN(1) STEP MinStep!
  20.   pointx% = X% + (XRadius! * COS(i))
  21.   pointy% = Y% + (YRadius! * SIN(i))
  22.   PSET (pointx%, pointy%), CLR&
  23.  
  24.  
  25. SUB GDK_EllipseFill (X%, Y%, XRadius!, YRadius!, CLR&, FillCLR&)
  26. IF XRadius! > YRadius! THEN Radius! = XRadius! ELSE Radius! = YRadius!
  27. MinStep! = 1 / (2 * 3.1415926535 * Radius!)
  28. FOR i = 0 TO 8 * ATN(1) STEP MinStep!
  29.   pointx% = X% + (XRadius! * COS(i))
  30.   pointy% = Y% + (YRadius! * SIN(i))
  31.   PSET (pointx%, pointy%), CLR&
  32. PAINT (X%, Y%), FillCLR&, CLR&
  33.  
  34.  
  35. SUB GDK_EllipseSegment (X%, Y%, XRadius!, YRadius!, Start!, End!, CLR&)
  36. Firstloop% = 0
  37. IF XRadius! > YRadius! THEN Radius! = XRadius! ELSE Radius! = YRadius!
  38. MinStep! = 1 / (2 * 3.1415926535 * Radius!)
  39. FOR i = Start! TO End! STEP MinStep!
  40.   pointx% = X% + (XRadius! * COS(i))
  41.   pointy% = Y% + (YRadius! * SIN(i))
  42.   IF Firstloop% = 0 THEN
  43.     LINE (X%, Y%)-(pointx%, pointy%), CLR&
  44.     Firstloop% = 1
  45.   END IF
  46.   PSET (pointx%, pointy%), CLR&
  47. LINE (X%, Y%)-(pointx%, pointy%), CLR&
  48.  
  49.  
  50. SUB GDK_EllipseSegmentFill (X%, Y%, XRadius!, YRadius!, Start!, End!, CLR&, FillClr&)
  51. Firstloop% = 0
  52. DIM Firstloopxy(2) AS INTEGER
  53. IF XRadius! > YRadius! THEN Radius! = XRadius! ELSE Radius! = YRadius!
  54. MinStep! = 1 / (2 * 3.1415926535 * Radius!)
  55. FOR i = Start! TO End! STEP MinStep!
  56.   pointx% = X% + (XRadius! * COS(i))
  57.   pointy% = Y% + (YRadius! * SIN(i))
  58.   IF Firstloop% = 0 THEN
  59.     Firstloopxy(0) = pointx%
  60.     Firstloopxy(1) = pointy%
  61.     LINE (X%, Y%)-(pointx%, pointy%), CLR&
  62.     Firstloop% = 1
  63.   END IF
  64.   PSET (pointx%, pointy%), CLR&
  65. LINE (X%, Y%)-(pointx%, pointy%), CLR&
  66. IF End! - Start! > 4 * ATN(1) THEN
  67.   i = (End! / 4)
  68.   pointx% = X% + (XRadius! * COS(i))
  69.   pointy% = Y% + (YRadius! * SIN(i))
  70. paintx% = (X% + Firstloopxy(0) + pointx%) / 3
  71. painty% = (Y% + Firstloopxy(1) + pointy%) / 3
  72. PAINT (paintx%, painty%), FillClr&, CLR&
  73.  
  74.  
  75. SUB GDK_Circle (X%, Y%, Radius!, CLR&)
  76. MinStep! = 1 / (2 * 3.1415926535 * Radius!)
  77. FOR i = 0 TO 8 * ATN(1) STEP MinStep!
  78.   pointx% = X% + (Radius! * COS(i))
  79.   pointy% = Y% + (Radius! * SIN(i))
  80.   PSET (pointx%, pointy%), CLR&
  81.  
  82.  
  83. SUB GDK_CircleFill (X%, Y%, Radius!, CLR&, FillCLR&)
  84. MinStep! = 1 / (2 * 3.1415926535 * Radius!)
  85. FOR i = 0 TO 8 * ATN(1) STEP MinStep!
  86.   pointx% = X% + (Radius! * COS(i))
  87.   pointy% = Y% + (Radius! * SIN(i))
  88.   PSET (pointx%, pointy%), CLR&
  89. PAINT (X%, Y%), FillCLR&, CLR&
  90.  
  91.  
  92. SUB GDK_CircleSegment (X%, Y%, Radius!, CLR&, CircleStart!, CircleEnd!)
  93. Firstloop% = 0
  94. MinStep! = 1 / (2 * 3.1415926535 * Radius!)
  95. FOR i = CircleStart! TO CircleEnd! STEP MinStep!
  96.   pointx% = X% + (Radius! * COS(i))
  97.   pointy% = Y% + (Radius! * SIN(i))
  98.   IF Firstloop% = 0 THEN
  99.     LINE (X%, Y%)-(pointx%, pointy%), CLR&
  100.     Firstloop% = 1
  101.   END IF
  102.   PSET (pointx%, pointy%), CLR&
  103. LINE (X%, Y%)-(pointx%, pointy%), CLR&
  104.  
  105.  
  106. SUB GDK_CircleSegmentFill (X%, Y%, Radius!, CLR&, FillClr&, CircleStart!, CircleEnd!)
  107. Firstloop% = 0
  108. DIM Firstloopxy(2) AS INTEGER
  109. MinStep! = 1 / (2 * 3.1415926535 * Radius!)
  110. FOR i = CircleStart! TO CircleEnd! STEP MinStep!
  111.   pointx% = X% + (Radius! * COS(i))
  112.   pointy% = Y% + (Radius! * SIN(i))
  113.   IF Firstloop% = 0 THEN
  114.     LINE (X%, Y%)-(pointx%, pointy%), CLR&
  115.     Firstloopxy(0) = pointx%
  116.     Firstloopxy(1) = pointy%
  117.     Firstloop% = 1
  118.   END IF
  119.   PSET (pointx%, pointy%), CLR&
  120. LINE (X%, Y%)-(pointx%, pointy%), CLR&
  121. IF CircleEnd! - CircleStart! > 4 * ATN(1) THEN
  122.   i = (CircleEnd! / 4)
  123.   pointx% = X% + (Radius! * COS(i))
  124.   pointy% = Y% + (Radius! * SIN(i))
  125. paintx% = (X% + Firstloopxy(0) + pointx%) / 3
  126. painty% = (Y% + Firstloopxy(1) + pointy%) / 3
  127. PAINT (paintx%, painty%), FillClr&, CLR&
  128.  
  129.  
  130. SUB GDK_Line (X%, Y%, XX%, YY%, CLR&, WIDTH%)
  131. IF WIDTH% MOD 2 = 0 THEN
  132.   FOR offset = -(WIDTH% / 2) TO WIDTH% / 2
  133.     LINE (X%, Y% + offset)-(XX%, YY% + offset), CLR&
  134.   NEXT
  135.   FOR offset = -((WIDTH% + 1) / 2) TO (WIDTH% + 1) / 2
  136.     LINE (X%, Y% + offset)-(XX%, YY% + offset), CLR&
  137.   NEXT
  138.  
  139.  
  140. SUB GDK_LineAngle (X%, Y%, Angle!, Length!, CLR&)
  141. x2% = X% + (Length! * COS(Angle!))
  142. y2% = Y% + (Length! * SIN(Angle!))
  143. LINE (X%, Y%)-(x2%, y2%), CLR&
  144.  
  145.  
  146. SUB GDK_LineH (X%, XX%, Y%, CLR&, WIDTH%)
  147. IF WIDTH% MOD 2 = 0 THEN
  148.   FOR offset = -(WIDTH% / 2) TO WIDTH% / 2
  149.     LINE (X%, Y% + offset)-(XX%, Y% + offset), CLR&
  150.   NEXT
  151.   FOR offset = -((WIDTH% + 1) / 2) TO (WIDTH% - 1) / 2
  152.     LINE (X%, Y% + offset)-(XX%, Y% + offset), CLR&
  153.   NEXT
  154.  
  155.  
  156. SUB GDK_LineV (Y%, YY%, X%, CLR&, WIDTH%)
  157. IF WIDTH% MOD 2 = 0 THEN
  158.   FOR offset = -(WIDTH% / 2) TO WIDTH% / 2
  159.     LINE (X% + offset, Y%)-(X% + offset, YY%), CLR&
  160.   NEXT
  161.   FOR offset = -((WIDTH% + 1) / 2) TO (WIDTH% - 1) / 2
  162.     LINE (X% + offset, Y%)-(X% + offset, YY%), CLR&
  163.   NEXT
  164.  
  165.  
  166. SUB GDK_Box (X%, Y%, Width%, Height%, CLR&)
  167. LINE (X%, Y%)-(X% + Width%, Y% + Height%), CLR&, B
  168.  
  169.  
  170. SUB GDK_BoxFill (X%, Y%, Width%, Height%, CLR&, FillCLR&)
  171. LINE (X%, Y%)-(X% + Width%, Y% + Height%), CLR&, B
  172. PAINT (X% + 2, Y% + 2), FillCLR&, CLR&
  173.  
  174.  
  175. SUB GDK_BoxXS (X%, Y%, Width%, Height%, XWidth%, CLR&, ShadeClr&)
  176. Oldclr& = CLR&
  177. FOR j% = 0 TO XWidth% - 1
  178.   IF _RED(CLR&) <= 255 AND _RED(ShadeClr&) > 0 THEN newred& = _RED(CLR&) - _RED(ShadeClr&)
  179.   IF _BLUE(CLR&) <= 255 AND _BLUE(ShadeClr&) > 0 THEN newblue& = _BLUE(CLR&) - _BLUE(ShadeClr&)
  180.   IF _GREEN(CLR&) <= 255 AND _GREEN(ShadeClr&) > 0 THEN newgreen& = _GREEN(CLR&) - _GREEN(ShadeClr&)
  181.   CLR& = _RGB(newred&, newgreen&, newblue&)
  182.   LINE (X% - j%, Y% - j%)-(X% + Width% + j%, Y% + Height% + j%), CLR&, B
  183. CLR& = Oldclr&
  184.  
  185.  
  186. SUB GDK_EllipseXS (X%, Y%, XRadius!, YRadius!, CLR&, Width%, ShadeClr&)
  187. FOR j% = 0 TO Width% - 1
  188.   IF _RED(CLR&) <= 255 AND _RED(ShadeClr&) > 0 THEN newred& = _RED(CLR&) - _RED(ShadeClr&)
  189.   IF _BLUE(CLR&) <= 255 AND _BLUE(ShadeClr&) > 0 THEN newblue& = _BLUE(CLR&) - _BLUE(ShadeClr&)
  190.   IF _GREEN(CLR&) <= 255 AND _GREEN(ShadeClr&) > 0 THEN newgreen& = _GREEN(CLR&) - _GREEN(ShadeClr&)
  191.   CLR& = _RGB(newred&, newgreen&, newblue&)
  192.   IF XRadius! > YRadius! THEN Radius! = XRadius! ELSE Radius! = YRadius!
  193.   MinStep! = 1 / (2 * 3.1415926535 * Radius!)
  194.   FOR i = 0 TO 8 * ATN(1) STEP MinStep!
  195.     pointx% = X% + (XRadius! * COS(i))
  196.     pointy% = Y% + (YRadius! * SIN(i))
  197.     PSET (pointx%, pointy%), CLR&
  198.   NEXT
  199.   XRadius! = XRadius! + 1
  200.   YRadius! = YRadius! + 1
  201.  
  202.  
  203. SUB GDK_CircleXS (X%, Y%, Radius!, CLR&, Width%, ShadeClr&)
  204. OldClr& = CLR&
  205. FOR j% = 0 TO Width% - 1
  206.   IF _RED(ShadeClr&) > 0 THEN newred& = _RED(CLR&) - _RED(ShadeClr&)
  207.   IF _BLUE(ShadeClr&) > 0 THEN newblue& = _BLUE(CLR&) - _BLUE(ShadeClr&)
  208.   IF _GREEN(ShadeClr&) > 0 THEN newgreen& = _GREEN(CLR&) - _GREEN(ShadeClr&)
  209.   CLR& = _RGB(newred&, newgreen&, newblue&)
  210.   MinStep! = 1 / (2 * 3.1415926535 * Radius!)
  211.   FOR i = 0 TO 8 * ATN(1) STEP MinStep!
  212.     pointx% = X% + (Radius! * COS(i))
  213.     pointy% = Y% + (Radius! * SIN(i))
  214.     PSET (pointx%, pointy%), CLR&
  215.   NEXT
  216.   Radius! = Radius! + 1
  217. CLR& = OldClr&
  218.  
  219.  
  220. SUB GDK_EllipseX (X%, Y%, XRadius!, YRadius!, CLR&, Width%)
  221. FOR j% = 0 TO Width% - 1
  222.   IF XRadius! > YRadius! THEN Radius! = XRadius! ELSE Radius! = YRadius!
  223.   MinStep! = 1 / (2 * 3.1415926535 * Radius!)
  224.   FOR i = 0 TO 8 * ATN(1) STEP MinStep!
  225.     pointx% = X% + (XRadius! * COS(i))
  226.     pointy% = Y% + (YRadius! * SIN(i))
  227.     PSET (pointx%, pointy%), CLR&
  228.   NEXT
  229.   XRadius! = XRadius! + 1
  230.   YRadius! = YRadius! + 1
  231.  
  232.  
  233. SUB GDK_CircleX (X%, Y%, Radius!, CLR&, Width%)
  234. MinStep! = 1 / (2 * 3.1415926535 * Radius!)
  235. FOR j% = 0 TO Width% - 1
  236.   FOR i = 0 TO 8 * ATN(1) STEP MinStep!
  237.     pointx% = X% + (Radius! * COS(i))
  238.     pointy% = Y% + (Radius! * SIN(i))
  239.     PSET (pointx%, pointy%), CLR&
  240.   NEXT
  241.   Radius! = Radius! + 1
  242.  

Unseen

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Line + Draw
« Reply #16 on: September 27, 2020, 04:12:57 pm »
I did something very similar to Fellippe's "box" subroutine for making buttons in my star system simulator. SierraKen's calculator buttons inspired me to add a "beveling" SUB to add some 3D pop to them, also similar to the frame examples above. I also made it so that the button label would show any associated hotkeys in a highlight color. Easy to change the position & parameters of the buttons.

All that's required is to call:
Con_Blok x position, y position, width, height, button label, hotkey position, button color

Code: QB64: [Select]
  1. A& = _NEWIMAGE(600, 400, 32)
  2. 'DIM SHARED f&
  3. 'f& = _LOADFONT("c:\windows\fonts\arialbd.ttf", 16, "monospace")
  4. Con_Blok 50, 50, 80, 48, "Sit", 1, &HFF00FF00
  5. Con_Blok 150, 50, 80, 48, "Stay", 2, &HFF0000FF
  6. Con_Blok 300, 150, 80, 48, "Fetch", 1, &HFF04500FF
  7. Con_Blok 500, 320, 80, 48, "Roll", 1, &HFFFF00FF
  8.  
  9.  
  10.  
  11. SUB Con_Blok (xpos AS INTEGER, ypos AS INTEGER, xsiz AS INTEGER, ysiz AS INTEGER, label AS STRING, high AS INTEGER, col AS _UNSIGNED LONG)
  12.  
  13.     'Create control block
  14.     CN& = _NEWIMAGE(xsiz, ysiz, 32)
  15.     _DEST CN&
  16.     COLOR , col
  17.     CLS
  18.     BevelB xsiz, ysiz, col
  19.     x = LEN(label)
  20.     IF f& > 0 THEN '                                            if font is available
  21.         sx = (xsiz / 2) - (x * _FONTWIDTH(f&)) / 3
  22.         sy = ysiz / 2 - 6
  23.         _FONT f&
  24.     ELSE '                                                      if not
  25.         sx = xsiz / 2 - x * 4: sy = ysiz / 2 - 8
  26.     END IF
  27.     FOR p = 1 TO x '                                            iterate through label characters
  28.         IF p = high THEN '                                      print hotkey highlight color (red) else (black)
  29.             COLOR &HFFFF0000
  30.         ELSE
  31.             COLOR &HFF000000
  32.         END IF
  33.         IF col = &HFFC80000 THEN COLOR 15
  34.         _PRINTSTRING (sx + (p - 1) * 8, sy), MID$(label, p, 1)
  35.     NEXT p
  36.     _FONT 16
  37.     _PUTIMAGE (xpos, ypos), CN&, A&
  38.     _FREEIMAGE CN&
  39.  
  40. END SUB 'Con_Blok
  41.  
  42. SUB BevelB (xsiz AS INTEGER, ysiz AS INTEGER, col AS _UNSIGNED LONG)
  43.  
  44.     'Create control button bevels for 3D effect - called from Con_Blok
  45.     'Inspiration and basic algorithm by SierraKen
  46.     SELECT CASE ysiz
  47.         CASE IS <= xsiz
  48.             brdr = INT(ysiz / 4)
  49.         CASE IS > xsiz
  50.             brdr = INT(xsiz / 4)
  51.     END SELECT
  52.     FOR bb = 0 TO brdr
  53.         c = c + 100 / brdr
  54.         LINE (0 + bb, 0 + bb)-(xsiz - 1 - bb, ysiz - 1 - bb), _RGBA32(_RED32(col) - 100 + c, _GREEN32(col) - 100 + c, _BLUE32(col) - 100 + c, _ALPHA(col)), B
  55.     NEXT bb
  56.  
  57. END SUB 'BevelB
  58.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Line + Draw
« Reply #17 on: September 27, 2020, 04:22:19 pm »
@Unseen Machine  yeah, yours look like 3D pads sticking up from a surface. You might like the fill triangle I used for thic line, no PAINT so no possible interference by other objects.

@OldMoses yeah I like those buttons too.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Line + Draw
« Reply #18 on: September 27, 2020, 04:48:34 pm »
@carloscordeiro

Seeing as you've just begun using graphics screens you might like the QB4.5 colors used in SCREEN 12 converted to _RGB32() colors for your custom designed screen made with _NEWIMAGE

You can tinker with the numbers but I use an qb~& FUNCTION for 0-15 colors converted to 32 bit EGB
Code: QB64: [Select]
  1.     SELECT CASE n
  2.         CASE 0: qb~& = &HFF000000
  3.         CASE 1: qb~& = &HFF000088
  4.         CASE 2: qb~& = &HFF008800
  5.         CASE 3: qb~& = &HFF008888
  6.         CASE 4: qb~& = &HFF880000
  7.         CASE 5: qb~& = &HFF880088
  8.         CASE 6: qb~& = &HFF888800
  9.         CASE 7: qb~& = &HFFCCCCCC
  10.         CASE 8: qb~& = &HFF888888
  11.         CASE 9: qb~& = &HFF0000FF
  12.         CASE 10: qb~& = &HFF00FF00
  13.         CASE 11: qb~& = &HFF00FFFF
  14.         CASE 12: qb~& = &HFFFF0000
  15.         CASE 13: qb~& = &HFFFF00FF
  16.         CASE 14: qb~& = &HFFFFFF00
  17.         CASE 15: qb~& = &HFFFFFFFF
  18.     END SELECT
  19.  

If I want red 12, I use qb~&(12), blue qb~&(9)....

the ~& are the suffix to _UNSIGNED LONG the best type to use for 32 bit colors.

So to PRINT s$ in red on black:
COLOR qb~&(12), qb~&(0)
PRINT s$

What is also cool is you can adjust the colors to your liking! So you can get a real orange and green.
« Last Edit: September 27, 2020, 04:49:44 pm by bplus »

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Line + Draw
« Reply #19 on: September 27, 2020, 05:56:39 pm »
I will keep the two simpler ones for the box I want.

OldMoses:

Code: QB64: [Select]
SCREEN 12
thick = 5
FOR x = 0 TO thick
    LINE (6 + x, 5 + x)-(632 - x, 462 - x), 11, B ' box or frame
    'LINE (7, 6)-(631, 461), 11, B  'Slightly thicker lines
    LINE (6 + x, 5 + x)-(632 - x, 50 - x), 11, B
NEXT x

And Felipe:

Código: QB64 : [Selecionar]
TELA _NOVAIMAGEM ( 800 , 600 , 32 )
caixa 0 , 0 , 200 , 130 , 10 , _RGB32 ( 183 , 133 , 33 )
SUB box ( x , y , w , h , espessura , a cor AS _UNSIGNED LONG )
    LINE ( x , y ) - STEP ( w , h ) , theColor , BF
    LINHA ( x + espessura , y + espessura ) - PASSO ( w - espessura * 2 , h - espessura * 2 ) , _BACKGROUNDCOLOR , BF
END SUB

Felipe's line code is great.
Simple and with few lines.

Thank you all

Carlos
Box.jpg
* Box.jpg (Filesize: 153.15 KB, Dimensions: 1009x901, Views: 234)
« Last Edit: September 27, 2020, 06:20:41 pm by carloscordeiro »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Line + Draw
« Reply #20 on: September 27, 2020, 06:07:40 pm »
Hi
I must admit that all you guys are very active and have so fantastic ideas to develope the request of  carloscordeiro!
I find very interesting your solutions, only Bplus have posted nothing!
However I post my raw two cents :
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. Makeframe 100, 300, 500, 350, 5, _RGB32(255, 0, 0)
  3. Makeframe 70, 400, 700, 10, 5, _RGB32(0, 150, 0)
  4. Makeframe 150, 400, 170, 10, 5, _RGB32(50, 50, 50)
  5. MakeLine 10, 300, 700, 400, 5, _RGB32(10, 100, 255)
  6. MakeLine 100, 200, 500, 400, 4, _RGB32(100, 10, 55)
  7.  
  8. SUB Makeframe (xStart, yStart, xEnd, yEnd, Thik, C AS _UNSIGNED LONG)
  9.     IF xStart > xEnd THEN SWAP xStart, xEnd
  10.     IF yStart > yEnd THEN SWAP yStart, yEnd
  11.     LINE (xStart, yStart)-(xEnd, yEnd), C, B
  12.     LINE (xStart + Thik, yStart + Thik)-(xEnd - Thik, yEnd - Thik), C, B
  13.     PAINT (xStart + INT(Thik / 2), yStart + INT(Thik / 2)), C, POINT(xStart, yStart)
  14.  
  15. SUB MakeLine (xStart, yStart, xEnd, yEnd, Thik, C AS _UNSIGNED LONG)
  16.     LINE (xStart, yStart)-(xEnd, yEnd), C
  17.     LINE (xStart, yStart + Thik)-(xEnd, yEnd + Thik), C
  18.     LINE (xStart, yStart)-(xStart, yStart + Thik), C
  19.     LINE (xEnd, yEnd)-(xEnd, yEnd + Thik), C
  20.     PAINT (xStart + INT(Thik / 2), yStart + INT(Thik / 2)), C, POINT(xStart, yStart)
  21.  
  22. SUB grid (xMin, yMin, xMax, yMax, xDelta, yDelta, C AS _UNSIGNED LONG)
  23.     'this sub creates a costumizable grid on the screen
  24.     FOR a = xMin TO xMax STEP xDelta
  25.         LINE (a, yMin)-(a, yMax), C
  26.     NEXT
  27.     FOR a = yMin TO yMax STEP yDelta
  28.         LINE (xMin, a)-(xMax, a), C
  29.     NEXT

@carloscordeiro
I must point out that with Draw you can increase only one dimension of the line that you draw...
see here this code show this concept.
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. grid 1, 800, 10, 1, 600, 5, _RGB32(0, 155, 0)
  3. LINE (100, 100)-(500, 100), _RGB32(255, 0, 0)
  4. DRAW "s16bm100,200m500,200"
  5. DRAW "s16bm100,300r100" ' the effect is on the direction of movement s4 = 1 pixel
  6. DRAW "s32bm100,350r50" ' s8= 2 pixels, s16 = 4 pixels, s32 = 8 pixels
  7. LINE (100, 400)-(500, 400), _RGB32(255, 0, 0)
  8.  
  9. SUB grid (xMin, yMin, xMax, yMax, xDelta, yDelta, C AS _UNSIGNED LONG)
  10.     'this sub creates a costumizable grid on the screen
  11.     FOR a = xMin TO xMax STEP xDelta
  12.         LINE (a, yMin)-(a, yMax), C
  13.     NEXT
  14.     FOR a = yMin TO yMax STEP yDelta
  15.         LINE (xMin, a)-(xMax, a), C
  16.     NEXT

Thanks to read
Programming isn't difficult, only it's  consuming time and coffee

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Line + Draw
« Reply #21 on: September 27, 2020, 07:21:48 pm »


"  TempodiBasic Thanks to read "


I read and executed all the codes


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Line + Draw
« Reply #22 on: September 27, 2020, 07:45:06 pm »
Quote
I find very interesting your solutions, only Bplus have posted nothing!

@TempodiBasic  what?

What do you mean by this? I doubt it is how it looks. :)
« Last Edit: September 27, 2020, 08:49:10 pm by bplus »

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Line + Draw
« Reply #23 on: September 27, 2020, 08:30:37 pm »
Bplus
Why the error in Felipe's box?
Box.jpg
* Box.jpg (Filesize: 368.11 KB, Dimensions: 1017x1015, Views: 215)
* seque analysis Bplus_10.txt (Filesize: 6.71 KB, Downloads: 129)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Line + Draw
« Reply #24 on: September 27, 2020, 08:39:09 pm »
@carloscordeiro

All SUBs and FUNCTIONs have to be listed after Main code, data statements and or GOSUBS from main code.

Should be OK to cut and paste the SUB lower or last in code.

Caution: Fellippe's box blacks out the interior space but if you use it first and then fill in the space with text you should be OK.

Old Moses has just what you would like I think, he did it without SUBs or FUNCTIONs which I don't think you are use to yet.
« Last Edit: September 27, 2020, 08:55:41 pm by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Line + Draw
« Reply #25 on: September 28, 2020, 01:47:57 pm »
@bplus
Quote
What do you mean by this?

Yes so we can say that this is a joke, can we?
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Line + Draw
« Reply #26 on: September 28, 2020, 01:51:08 pm »
@bplus
Yes so we can say that this is a joke, can we?

LOL OK but you had me wondering :)