Author Topic: CIRCLE vs LINE for LED effect  (Read 2104 times)

0 Members and 1 Guest are viewing this topic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
CIRCLE vs LINE for LED effect
« on: October 27, 2019, 08:28:01 pm »
Hi
what are of two effects  better for a LED effect?

welcome Yours opinions

Here a little code in Old Style of programming with GOSUB blocks of commands...

Code: QB64: [Select]
  1. REM here we try to compare a circle + paint vs a line to LED a character
  2. CONST White = _RGBA32(255, 255, 255, 255), Black = _RGBA32(0, 0, 0, 255)
  3. CONST Red = _RGBA32(240, 0, 0, 255), Blu = _RGBA32(0, 0, 200, 255)
  4. DEFINT A-L
  5. SCREEN _NEWIMAGE(920, 600, 32)
  6. stringa = "ABab"
  7. PRINT stringa
  8.  
  9. FOR c = 1 TO 4
  10.  
  11.     kPoint = (c - 1) * 8
  12.     kDimension = 10
  13.     hLetter = 10
  14.     lLetter = 50
  15.     lCol~& = Blu
  16.     GOSUB PrintLetterL
  17.     hLetter = 450
  18.     GOSUB printletterC
  19.  
  20.     kDimension = 12
  21.     hLetter = 10
  22.     lLetter = 300
  23.     lCol~& = Red
  24.     GOSUB PrintLetterL
  25.     hLetter = 450
  26.     GOSUB printletterC
  27.  
  28.     kDimension = 5
  29.     hLetter = 10
  30.     lLetter = 200
  31.     lCol~& = White
  32.     GOSUB PrintLetterL
  33.     hLetter = 450
  34.     GOSUB printletterC
  35.  
  36.  
  37.  
  38.  
  39. PrintLetterL:
  40. FOR a = kPoint TO (kPoint + 7) ' horizonthal position on the raw
  41.     FOR b = 1 TO 13 ' vertical position on the raw
  42.         IF POINT(a, b) <> Black THEN col~& = lCol~& ELSE col~& = Black
  43.         LINE (hLetter + (a * kDimension), lLetter + (b * kDimension))-(hLetter + (a * kDimension) + kDimension, lLetter + (b * kDimension) + kDimension), col~&, BF
  44.     NEXT
  45.  
  46. printletterC:
  47. FOR a = kPoint TO (kPoint + 7) ' horizonthal position on the raw
  48.     FOR b = 1 TO 13 ' vertical position on the raw
  49.         IF POINT(a, b) <> Black THEN col~& = lCol~& ELSE col~& = Black
  50.         CIRCLE (hLetter + (a * kDimension), lLetter + (b * kDimension)), kDimension, col~&
  51.     NEXT
  52.  
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CIRCLE vs LINE for LED effect
« Reply #1 on: October 27, 2019, 08:45:08 pm »
A little fix for the circle one:
Code: QB64: [Select]
  1. printletterC:
  2. FOR a = kPoint TO (kPoint + 7) ' horizonthal position on the raw
  3.     FOR b = 1 TO 13 ' vertical position on the raw
  4.         IF POINT(a, b) <> Black THEN col~& = lCol~& ELSE col~& = Black
  5.         CIRCLE (hLetter + (a * kDimension), lLetter + (b * kDimension)), kDimension / 3.1415, col~& '<<<<<<<<<<<<<<<<,,
  6.     NEXT
  7.  

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: CIRCLE vs LINE for LED effect
« Reply #2 on: October 28, 2019, 08:52:58 am »
Hi Bplus thanks
but it seems more a variant that a fix!
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CIRCLE vs LINE for LED effect
« Reply #3 on: October 28, 2019, 10:43:48 am »
Hi Bplus thanks
but it seems more a variant that a fix!

With respect, I must debate that, before the "fix" the circles drawn were not whole because they were drawn so big the spaces printed after them overlapped and made the graphic just a little bit shoddy (sorry). Now circles overlapping themselves should look fine and if you like that effect then don't print the black spaces or whatever is causing the incomplete circle as shown below:

  [ You are not allowed to view this attachment ]  
« Last Edit: October 28, 2019, 10:45:27 am by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: CIRCLE vs LINE for LED effect
« Reply #4 on: October 28, 2019, 02:20:58 pm »
Hi Bplus
1. I premise that I like your variation of the program...it gives me a good sense of order

2. You have got to draw whole circles with not overlapping area... and this is a goal

3. I have coded to draw circles at the place of squares without minding if they overlap themselves or are whole...

  [ You are not allowed to view this attachment ]  

However about the incomplete circles I can agree in the manner that I have used Filled Squares to avoid the effect of incomplete shape that you can see with void circles...and that it comes out from overlapping colored shapes with black shapes...


so here the real fix to avoid the incomplete circle that occupies about the same area of the square and overlapping
Code: QB64: [Select]
  1. printletterC:
  2. FOR a = kPoint TO (kPoint + 7) ' horizonthal position on the raw
  3.     FOR b = 1 TO 13 ' vertical position on the raw
  4.         IF POINT(a, b) <> Black THEN CIRCLE (hLetter + (a * kDimension), lLetter + (b * kDimension)), kDimension, lCol~&
  5.     NEXT

and this is the result
  [ You are not allowed to view this attachment ]  

and we must fix also the LINE part if we use LINE.....,B at the place of LINE.....,BF
Code: QB64: [Select]
  1. PrintLetterL:
  2. FOR a = kPoint TO (kPoint + 7) ' horizonthal position on the raw
  3.     FOR b = 1 TO 13 ' vertical position on the raw
  4.         IF POINT(a, b) <> Black THEN LINE (hLetter + (a * kDimension), lLetter + (b * kDimension))-(hLetter + (a * kDimension) + kDimension, lLetter + (b * kDimension) + kDimension), lCol~&, B
  5.     NEXT
  6.  

these two fix lead to this result
  [ You are not allowed to view this attachment ]  

while the original code without fix and without LINE....,BF but with LINE ....,B leads to this other result
  [ You are not allowed to view this attachment ]  .

IMHO, You are drawing the inscripted circle of the square and I find it very cool, while I 'm drawing the circlescripted circle (I use the side of the square as radius and not diameter or the circle drawn)


PS it is always fine to talk and to get back different opinions and knownledge and experiences!
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CIRCLE vs LINE for LED effect
« Reply #5 on: October 28, 2019, 02:38:40 pm »
Hi TempodiBasic

Yes the circumscribed circles are nice too, as long as they weren't blacked out by overlapping print and made to look
incomplete. Glad you understood :)

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: CIRCLE vs LINE for LED effect
« Reply #6 on: October 29, 2019, 05:04:52 pm »
Yes and I think you can appreciate the fullshape version

Code: QB64: [Select]
  1. REM here we try TO compare a CIRCLE + PAINT vs a LINE TO LED a character
  2. CONST White = _RGBA32(255, 255, 255, 255), Black = _RGBA32(0, 0, 0, 255)
  3. CONST Red = _RGBA32(240, 0, 0, 255), Blu = _RGBA32(0, 0, 200, 255)
  4. DEFINT A-L
  5. SCREEN _NEWIMAGE(920, 600, 32)
  6. stringa = "ABab"
  7. PRINT stringa
  8.  
  9. FOR c = 1 TO 4
  10.  
  11.     kPoint = (c - 1) * 8
  12.     kDimension = 10
  13.     hLetter = 10
  14.     lLetter = 50
  15.     lCol~& = Blu
  16.     GOSUB PrintLetterL
  17.     hLetter = 450
  18.     GOSUB printletterC
  19.  
  20.     kDimension = 12
  21.     hLetter = 10
  22.     lLetter = 300
  23.     lCol~& = Red
  24.     GOSUB PrintLetterL
  25.     hLetter = 450
  26.     GOSUB printletterC
  27.  
  28.     kDimension = 5
  29.     hLetter = 10
  30.     lLetter = 200
  31.     lCol~& = White
  32.     GOSUB PrintLetterL
  33.     hLetter = 450
  34.     GOSUB printletterC
  35.  
  36.  
  37.  
  38.  
  39. PrintLetterL:
  40. FOR a = kPoint TO (kPoint + 7) ' horizonthal position on the raw
  41.     FOR b = 1 TO 13 ' vertical position on the raw
  42.         IF POINT(a, b) <> Black THEN LINE (hLetter + (a * kDimension), lLetter + (b * kDimension))-(hLetter + (a * kDimension) + kDimension, lLetter + (b * kDimension) + kDimension), lCol~&, BF
  43.     NEXT
  44.  
  45. printletterC:
  46. FOR a = kPoint TO (kPoint + 7) ' horizonthal position on the raw
  47.     FOR b = 1 TO 13 ' vertical position on the raw
  48.         IF POINT(a, b) <> Black THEN CIRCLE (hLetter + (a * kDimension), lLetter + (b * kDimension)), kDimension / 2, lCol~&: PAINT STEP(0, 0), lCol~&
  49.     NEXT
  50.  
  51.  
 [ You are not allowed to view this attachment ]  
thanks for read and discuss.
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CIRCLE vs LINE for LED effect
« Reply #7 on: October 30, 2019, 12:50:08 am »
Ha! TempodiBasic, it looks like you are on the way to yet another LED Scroller! ;-)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: CIRCLE vs LINE for LED effect
« Reply #8 on: October 31, 2019, 02:00:17 am »
Slight side-step question. What would use more memory, the 'paint' command or a 'scanline fill', for the circles? Just curious as to the effect on memory and or speed for scrolling.... Perhaps the size of the circles are too small to make much of a difference? I'm sorry. My caffeine levels are quite low... You can probably guess by the way I am babbling, right?
Logic is the beginning of wisdom.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: CIRCLE vs LINE for LED effect
« Reply #9 on: October 31, 2019, 01:19:56 pm »
Hi Johnno56
here another led scroller in embryo
you can mod ShowString to get how much time it gets to accomplish the scrolling task (3-5 cycles) .

Code: QB64: [Select]
  1. REM here we try TO compare a CIRCLE + PAINT vs a LINE TO LED a character
  2. REM I like too much to use the block code so in the place
  3. REM of label: GOSUB ... RETURN that is a good first manner to use
  4. REM blocks of code  I prefer following the evolution to SUB and FUNCTION
  5. _TITLE "Scroller Circle vs Line vs Fillcircle, press ESC to quit"
  6. CONST White = _RGBA32(255, 255, 255, 255), Black = _RGBA32(0, 0, 0, 255)
  7. CONST Red = _RGBA32(240, 0, 0, 255), Blu = _RGBA32(0, 0, 200, 255)
  8. DEFINT A-L
  9. SCREEN _NEWIMAGE(920, 600, 32)
  10. stringa = " QB64 and QB64 community are  wonderful "
  11. Astr = LEN(stringa)
  12. stringa2 = stringa
  13.  
  14.     CLS
  15.     PRINT stringa2 ' here we have the info to draw led letters
  16.     ShowString stringa2
  17.     stringa2 = RIGHT$(stringa2, Astr - 1) + LEFT$(stringa2, 1)
  18.     _LIMIT 7 '<----- increase here if you want a faster scroller
  19.     _DISPLAY
  20.  
  21. SUB ShowString (strn)
  22.     FOR c = 1 TO LEN(strn)
  23.         kPoint = (c - 1) * 8
  24.         kDimension = 10
  25.         hLetter = 10
  26.         lLetter = 50
  27.         lCol~& = Blu
  28.         'fillcircle manner
  29.         printletterC2 kPoint, kDimension, hLetter, lLetter, lCol~&
  30.  
  31.         kDimension = 12
  32.         hLetter = 10
  33.         lLetter = 300
  34.         lCol~& = Red
  35.         ' circle + paint manner
  36.         printletterC kPoint, kDimension, hLetter, lLetter, lCol~&
  37.  
  38.         kDimension = 5
  39.         hLetter = 10
  40.         lLetter = 200
  41.         lCol~& = White
  42.         ' line manner
  43.         PrintLetterL kPoint, kDimension, hLetter, lLetter, lCol~&
  44.     NEXT c
  45.  
  46. SUB PrintLetterL (kpoi, dimension, hlet, llet, lC~&)
  47.     FOR a = kpoi TO (kpoi + 7) ' horizonthal position on the raw
  48.         FOR b = 1 TO 13 ' vertical position on the raw
  49.             IF POINT(a, b) <> Black THEN LINE (hlet + (a * dimension), llet + (b * dimension))-(hlet + (a * dimension) + dimension, llet + (b * dimension) + dimension), lC~&, BF
  50.         NEXT
  51.     NEXT
  52.  
  53. SUB printletterC (kPoi, Dimension, hLet, lLet, lC~&)
  54.     FOR a = kPoi TO (kPoi + 7) ' horizonthal position on the raw
  55.         FOR b = 1 TO 13 ' vertical position on the raw
  56.             IF POINT(a, b) <> Black THEN CIRCLE (hLet + (a * Dimension), lLet + (b * Dimension)), Dimension / 2, lC~&: PAINT STEP(0, 0), lC~&
  57.         NEXT
  58.     NEXT
  59.  
  60. SUB printletterC2 (kPoi, Dimension, hLet, lLet, lC~&)
  61.     FOR a = kPoi TO (kPoi + 7) ' horizonthal position on the raw
  62.         FOR b = 1 TO 13 ' vertical position on the raw
  63.             IF POINT(a, b) <> Black THEN CircleFill (hLet + (a * Dimension)), (lLet + (b * Dimension)), INT(Dimension / 2), lC~&
  64.         NEXT
  65.     NEXT
  66.  
  67. SUB CircleFill (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  68.     ' CX = center x coordinate
  69.     ' CY = center y coordinate
  70.     '  R = radius
  71.     '  C = fill color
  72.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  73.     DIM X AS INTEGER, Y AS INTEGER
  74.     Radius = ABS(R)
  75.     RadiusError = -Radius
  76.     X = Radius
  77.     Y = 0
  78.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  79.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  80.     WHILE X > Y
  81.         RadiusError = RadiusError + Y * 2 + 1
  82.         IF RadiusError >= 0 THEN
  83.             IF X <> Y + 1 THEN
  84.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  85.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  86.             END IF
  87.             X = X - 1
  88.             RadiusError = RadiusError - X * 2
  89.         END IF
  90.         Y = Y + 1
  91.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  92.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  93.     WEND
  94.  

thanks to give a look at
Programming isn't difficult, only it's  consuming time and coffee