Author Topic: Star Wars Text  (Read 4026 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Star Wars Text
« on: March 28, 2019, 10:57:19 am »
As was mentioned elsewhere, somebody posted a challenge to create a Star Wars text fading effect.  My initial thoughts was to simply take a normal screen of text and then map it to a trapezoidal shape before displaying it, which seems simple enough.

Theory and reality, however, just don't seem to agree with the concept, as illustrated below:

Code: QB64: [Select]
  1.  DEFLNG A-Z
  2.  
  3. ds = _NEWIMAGE(800, 600, 32) 'display screen
  4.  
  5.  
  6. 'my original screen
  7. LINE (100, 100)-(300, 300), &HFFFF0000, BF 'a red square
  8. _PRINTSTRING (160, 190), "Hello World" 'with words
  9.  
  10. 'what I want to copy to, to create a "Star Wars" fade effect
  11. LINE (450, 100)-(550, 100)
  12. LINE -(600, 300)
  13. LINE -(400, 300)
  14. LINE -(450, 100)
  15.  
  16. _MAPTRIANGLE (100, 100)-(100, 300)-(300, 100)TO(450, 100)-(400, 300)-(550, 100)
  17.  
  18.  
  19. _MAPTRIANGLE (100, 300)-(300, 100)-(300, 300)TO(400, 300)-(550, 100)-(600, 300)
  20.  
  21.  

At first, it all appears to be working as intended with the text getting a nice slant and the screen narrowing up top to produce the "fade into distance" effect we see in the movies...

Then we do the other half of the triangle and have the text slant in the opposite direction...

Which *does* create a wild little effect when we scroll information across the screen, but it's not what we're looking for here.

So, it seems my "simple" little solution may not be as simple as I first imagined it would be.  Unless somebody sees something wrong with my process here, I think I'll have to rethink the whole concept.  Maybe if I broke the screen down to a series of a dozen triangles or so, and then mapped them over, it might work as it could give a gradual transition from left slope to right slope with the center simply being shrunk as it goes along, but the math for that might end up being too big a PITA for me to sit down and sort out...

Anywho, I thought I'd share my initial results so folks can see what I'm getting so far, and if you have any idea of how to fix the process, or see an obvious glitch in the works here, I'd love if you'd share it.  Seems like it'd be simple to map from a square to a trapezoid, but I'm just not having much luck with it at the moment. 
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Star Wars Text
« Reply #1 on: March 28, 2019, 11:10:51 am »
Yep! Same cruddy results with scrolling text example:
Code: QB64: [Select]
  1. ' Star Wars Episode V: The Empire Strikes Back opening crawl?
  2. ' http://www.galaxyfaraway.com/gfa/2006/02/what-is-the-text-of-the-star-wars-episode-v-the-empire-strikes-back-opening-crawl/
  3.  
  4. SCREEN _NEWIMAGE(800, 700, 32)
  5. _SCREENMOVE 300, 20
  6. swt& = _NEWIMAGE(320, 512, 32)
  7. _DEST swt&
  8. COLOR _RGB32(0, 180, 0)
  9. nl$ = CHR$(10)
  10. sw$ = "It is a dark time for the Rebellion." + nl$
  11. sw$ = sw$ + "Although the Death Star has been" + nl$
  12. sw$ = sw$ + "destroyed, Imperial troops have driven" + nl$
  13. sw$ = sw$ + "the Rebel forces from their hidden base" + nl$
  14. sw$ = sw$ + "and pursued them across the galaxy." + nl$
  15. sw$ = sw$ + nl$ + nl$
  16. sw$ = sw$ + "Evading the dreaded Imperial Starfleet," + nl$
  17. sw$ = sw$ + "a group of freedom fighters led by Luke" + nl$
  18. sw$ = sw$ + "Skywalker has established a new secret" + nl$
  19. sw$ = sw$ + "base on the remote ice world of Hoth." + nl$
  20. sw$ = sw$ + nl$ + nl$
  21. sw$ = sw$ + "The evil lord Darth Vader, obsessed with" + nl$
  22. sw$ = sw$ + "finding young Skywalker, has dispatched" + nl$
  23. sw$ = sw$ + "thousands of remote probes into the" + nl$
  24. sw$ = sw$ + "far reaches of space.... " + nl$
  25. LOCATE 20, 1
  26. PRINT sw$
  27.  
  28.  
  29. '                                         Disaster!!!!!!!!!!!
  30. FOR y = 0 TO 512
  31.     '_MAPTRIANGLE [{_SEAMLESS}] (sx1, sy1)-(sx2, sy2)-(sx3, sy3), source& TO (dx1, dy1)-(dx2, dy2)-(dx3, dy3)[, destination&][{_SMOOTH|_SMOOTHSHRUNK|_SMOOTHSTRETCHED}]]
  32.     _MAPTRIANGLE (0, y)-(319, y)-(0, y + 319), swt& TO(350, 0)-(449, 0)-(0, 699), 0
  33.     _MAPTRIANGLE (319, y)-(0, y + 319)-(319, y + 319), swt& TO(449, 0)-(0, 699)-(799, 699), 0, _SMOOTHSHRUNK
  34.     _DISPLAY
  35.     _LIMIT 15
  36.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Star Wars Text
« Reply #2 on: March 28, 2019, 11:43:46 am »
Here I tried a bunch of _PUTIMAGE commands at 1 pixel height. It gets us closer but the text at the sides gets too distorted to read.
Code: QB64: [Select]
  1. ' Star Wars Episode V: The Empire Strikes Back opening crawl?
  2. ' http://www.galaxyfaraway.com/gfa/2006/02/what-is-the-text-of-the-star-wars-episode-v-the-empire-strikes-back-opening-crawl/
  3.  
  4. SCREEN _NEWIMAGE(800, 700, 32)
  5. _SCREENMOVE 300, 20
  6. swt& = _NEWIMAGE(320, 512, 32)
  7. _DEST swt&
  8. COLOR _RGB32(0, 180, 0)
  9. nl$ = CHR$(10)
  10. sw$ = "It is a dark time for the Rebellion." + nl$
  11. sw$ = sw$ + "Although the Death Star has been" + nl$
  12. sw$ = sw$ + "destroyed, Imperial troops have driven" + nl$
  13. sw$ = sw$ + "the Rebel forces from their hidden base" + nl$
  14. sw$ = sw$ + "and pursued them across the galaxy." + nl$
  15. sw$ = sw$ + nl$ + nl$
  16. sw$ = sw$ + "Evading the dreaded Imperial Starfleet," + nl$
  17. sw$ = sw$ + "a group of freedom fighters led by Luke" + nl$
  18. sw$ = sw$ + "Skywalker has established a new secret" + nl$
  19. sw$ = sw$ + "base on the remote ice world of Hoth." + nl$
  20. sw$ = sw$ + nl$ + nl$
  21. sw$ = sw$ + "The evil lord Darth Vader, obsessed with" + nl$
  22. sw$ = sw$ + "finding young Skywalker, has dispatched" + nl$
  23. sw$ = sw$ + "thousands of remote probes into the" + nl$
  24. sw$ = sw$ + "far reaches of space.... " + nl$
  25. LOCATE 20, 1
  26. PRINT sw$
  27.  
  28.  
  29. ''                                         Disaster!!!!!!!!!!!
  30. 'FOR y = 0 TO 512
  31. ''    _MAPTRIANGLE [{_SEAMLESS}] (sx1, sy1)-(sx2, sy2)-(sx3, sy3), source& TO (dx1, dy1)-(dx2, dy2)-(dx3, dy3)[, destination&][{_SMOOTH|_SMOOTHSHRUNK|_SMOOTHSTRETCHED}]]
  32. '    _MAPTRIANGLE (0, y)-(319, y)-(0, y + 319), swt& TO(350, 0)-(449, 0)-(0, 699), 0
  33. '    _MAPTRIANGLE (319, y)-(0, y + 319)-(319, y + 319), swt& TO(449, 0)-(0, 699)-(799, 699), 0, _SMOOTHSHRUNK
  34. '    _DISPLAY
  35. '    _LIMIT 15
  36. 'NEXT
  37.  
  38.  
  39. 'try a bunch of putimges
  40. cx = _WIDTH / 2
  41. power = 256 'TO 1 STEP -1
  42. LOCATE 1, 1: PRINT power
  43. x = (_HEIGHT - 20) ^ (1 / power)
  44. dy = 1 '256 pixel height / 50 blocks across
  45. FOR y = 0 TO 512
  46.     CLS
  47.     FOR i = 0 TO power - 1
  48.         '_PUTIMAGE [STEP] [(dx1, dy1)-[STEP][(dx2, dy2)]][, sourceHandle&][, destHandle&][, ][STEP][(sx1, sy1)[-STEP][(sx2, sy2)]]
  49.         _PUTIMAGE (cx - .75 * x ^ i, 10 + x ^ i)-(cx + .75 * x ^ i, 10 + x ^ (i + 1)), swt&, 0, (0, y + dy * i)-(320, y + dy * (i + 1))
  50.  
  51.         'LINE (cx - .75 * x ^ i, 10 + x ^ i)-(cx + .75 * x ^ i, 10 + x ^ (i + 1)), , B
  52.     NEXT
  53.     _DISPLAY
  54.     _LIMIT 10
  55.  
  56.  

Offline eddy498

  • Newbie
  • Posts: 25
    • View Profile
Re: Star Wars Text
« Reply #3 on: March 28, 2019, 01:59:32 pm »
I see what the problem is with your programs.. not that i understand but i see from the output lol.

um an idea i was gonna try was something a bit simpler but simple things usually dont always work in coding. correct me if im wrong, but cant you create multiple invisible lines every 50-100 pixels that when the text passes through that line it will change font size making it smaller giving the illusion that its fading in the distance??

again i might be wrong. and i still havnt tried it myself since im trying to figure out the simplest way to make text scroll up by itself :)

Offline eddy498

  • Newbie
  • Posts: 25
    • View Profile
Re: Star Wars Text
« Reply #4 on: March 28, 2019, 02:23:15 pm »
Yep! Same cruddy results with scrolling text example:
Code: QB64: [Select]
  1. ' Star Wars Episode V: The Empire Strikes Back opening crawl?
  2. ' http://www.galaxyfaraway.com/gfa/2006/02/what-is-the-text-of-the-star-wars-episode-v-the-empire-strikes-back-opening-crawl/
  3.  
  4. SCREEN _NEWIMAGE(800, 700, 32)
  5. _SCREENMOVE 300, 20
  6. swt& = _NEWIMAGE(320, 512, 32)
  7. _DEST swt&
  8. COLOR _RGB32(0, 180, 0)
  9. nl$ = CHR$(10)
  10. sw$ = "It is a dark time for the Rebellion." + nl$
  11. sw$ = sw$ + "Although the Death Star has been" + nl$
  12. sw$ = sw$ + "destroyed, Imperial troops have driven" + nl$
  13. sw$ = sw$ + "the Rebel forces from their hidden base" + nl$
  14. sw$ = sw$ + "and pursued them across the galaxy." + nl$
  15. sw$ = sw$ + nl$ + nl$
  16. sw$ = sw$ + "Evading the dreaded Imperial Starfleet," + nl$
  17. sw$ = sw$ + "a group of freedom fighters led by Luke" + nl$
  18. sw$ = sw$ + "Skywalker has established a new secret" + nl$
  19. sw$ = sw$ + "base on the remote ice world of Hoth." + nl$
  20. sw$ = sw$ + nl$ + nl$
  21. sw$ = sw$ + "The evil lord Darth Vader, obsessed with" + nl$
  22. sw$ = sw$ + "finding young Skywalker, has dispatched" + nl$
  23. sw$ = sw$ + "thousands of remote probes into the" + nl$
  24. sw$ = sw$ + "far reaches of space.... " + nl$
  25. LOCATE 20, 1
  26. PRINT sw$
  27.  
  28.  
  29. '                                         Disaster!!!!!!!!!!!
  30. FOR y = 0 TO 512
  31.     '_MAPTRIANGLE [{_SEAMLESS}] (sx1, sy1)-(sx2, sy2)-(sx3, sy3), source& TO (dx1, dy1)-(dx2, dy2)-(dx3, dy3)[, destination&][{_SMOOTH|_SMOOTHSHRUNK|_SMOOTHSTRETCHED}]]
  32.     _MAPTRIANGLE (0, y)-(319, y)-(0, y + 319), swt& TO(350, 0)-(449, 0)-(0, 699), 0
  33.     _MAPTRIANGLE (319, y)-(0, y + 319)-(319, y + 319), swt& TO(449, 0)-(0, 699)-(799, 699), 0, _SMOOTHSHRUNK
  34.     _DISPLAY
  35.     _LIMIT 15
  36.  

maybe something along the lines of calling out the strings each seperatly like how you did there but instead of maptriangle a transitioning code.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Star Wars Text
« Reply #5 on: March 28, 2019, 02:56:32 pm »
I have fiddled and hacked the 2nd method using _PUTIMAGE technique and have better results:
Code: QB64: [Select]
  1. ' Star Wars Episode V: The Empire Strikes Back opening crawl?
  2. ' http://www.galaxyfaraway.com/gfa/2006/02/what-is-the-text-of-the-star-wars-episode-v-the-empire-strikes-back-opening-crawl/
  3.  
  4. SCREEN _NEWIMAGE(800, 700, 32)
  5. _SCREENMOVE 300, 20
  6. swt& = _NEWIMAGE(320, 512, 32)
  7. _DEST swt&
  8. COLOR _RGB32(0, 180, 0)
  9. nl$ = CHR$(10)
  10. sw$ = "It is a dark time for the Rebellion." + nl$
  11. sw$ = sw$ + "Although the Death Star has been" + nl$
  12. sw$ = sw$ + "destroyed, Imperial troops have driven" + nl$
  13. sw$ = sw$ + "the Rebel forces from their hidden base" + nl$
  14. sw$ = sw$ + "and pursued them across the galaxy." + nl$
  15. sw$ = sw$ + nl$ + nl$
  16. sw$ = sw$ + "Evading the dreaded Imperial Starfleet," + nl$
  17. sw$ = sw$ + "a group of freedom fighters led by Luke" + nl$
  18. sw$ = sw$ + "Skywalker has established a new secret" + nl$
  19. sw$ = sw$ + "base on the remote ice world of Hoth." + nl$
  20. sw$ = sw$ + nl$ + nl$
  21. sw$ = sw$ + "The evil lord Darth Vader, obsessed" + nl$
  22. sw$ = sw$ + "with finding young Skywalker, has" + nl$
  23. sw$ = sw$ + "dispatched thousands of remote probes" + nl$
  24. sw$ = sw$ + "into the far reaches of space.... " + nl$
  25. LOCATE 20, 1
  26. PRINT sw$
  27.  
  28. yy = _HEIGHT / 3
  29. FOR i = 11 TO 60 STEP .5
  30.     CLS
  31.     yy = yy - 60 / i
  32.     cText _WIDTH / 2, yy + yy, yy, _RGB32(230, 220, 50), "Star Wars"
  33.     cText _WIDTH / 2, yy + yy, yy * .96, _RGB32(0, 0, 0), "Star Wars"
  34.     _DISPLAY
  35.     _LIMIT 15
  36.  
  37. cx = _WIDTH / 2
  38. power = 1024 'TO 1 STEP -1
  39. x = (_HEIGHT - 20) ^ (1 / power)
  40. dy = 1 '256 pixel height / 50 blocks across
  41. FOR y = -840 TO -270
  42.     CLS
  43.     FOR i = 0 TO power - 1
  44.         '_PUTIMAGE [STEP] [(dx1, dy1)-[STEP][(dx2, dy2)]][, sourceHandle&][, destHandle&][, ][STEP][(sx1, sy1)[-STEP][(sx2, sy2)]]
  45.         _PUTIMAGE (cx - .75 * x ^ i, 10 + x ^ i)-(cx + .75 * x ^ i, 10 + x ^ (i + 1)), swt&, 0, (0, y + dy * i)-(319, y + dy * (i + 1))
  46.  
  47.         'LINE (cx - .75 * x ^ i, 10 + x ^ i)-(cx + .75 * x ^ i, 10 + x ^ (i + 1)), , B
  48.     NEXT
  49.     PRINT y
  50.     _DISPLAY
  51.     _LIMIT 15
  52. yy = 80
  53. FOR i = 60 TO 0 STEP -.5
  54.     CLS
  55.     yy = yy + 60 / i
  56.     cText _WIDTH / 2, yy + yy, yy, _RGB32(230, 220, 50), "Star Wars"
  57.     cText _WIDTH / 2, yy + yy, yy * .96, _RGB32(0, 0, 0), "Star Wars"
  58.     _DISPLAY
  59.     _LIMIT 75
  60.  
  61. SUB cText (x, y, textHeight, K AS _UNSIGNED LONG, txt$)
  62.     fg = _DEFAULTCOLOR
  63.     'screen snapshot
  64.     cur& = _DEST
  65.     I& = _NEWIMAGE(8 * LEN(txt$), 16, 32)
  66.     _DEST I&
  67.     COLOR K, _RGBA32(0, 0, 0, 0)
  68.     _PRINTSTRING (0, 0), txt$
  69.     mult = textHeight / 16
  70.     xlen = LEN(txt$) * 8 * mult
  71.     _PUTIMAGE (x - .5 * xlen, y - .5 * textHeight)-STEP(xlen, textHeight), I&, cur&
  72.     COLOR fg
  73.     _FREEIMAGE I&
  74.  

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Star Wars Text
« Reply #6 on: March 28, 2019, 08:07:22 pm »
Here's a semi-decent test run of Star Wars type text.  (Note, there's actually no scrolling going on yet, but it illustrates how to create a similar effect.)

Code: QB64: [Select]
  1. DEFLNG A-Z
  2.  
  3. ds = _NEWIMAGE(1280, 960, 32)
  4. bs = _NEWIMAGE(1280, 960, 32)
  5.  
  6. _SCREENMOVE (_DESKTOPWIDTH - 1280) / 2, (_DESKTOPHEIGHT - 960) / 2
  7.  
  8.  
  9. CONST FH = 48 'Fontheight
  10. font = _LOADFONT("Starjout.ttf", FH) 'Note: Non-Monospaced font in use.
  11.  
  12.  
  13. _FONT font
  14.  
  15. PRINT "Star Wars, the farce continues, Part 27.4"
  16. FOR i = 2 TO 20
  17.     LOCATE i, 1: PRINT "LiNE"; i; " this is just junk to test formatting";
  18.  
  19.  
  20. FOR i = 0 TO 19 '20 lines of text on the screen
  21.     _MAPTRIANGLE (0, i * FH)-(_WIDTH - 1, i * FH)-(0, FH * (i + 1)), bs TO_
  22.                  (20 * (19 - i), i * FH)-(_WIDTH - 20 * (19 - i), i * FH)-(20 * (19 - i), FH * (i + 1)), ds
  23.     _MAPTRIANGLE (0, (i + 1) * FH)-(_WIDTH - 1, (i + 1) * FH)-(_WIDTH - 1, FH * i), bs TO_
  24.                  (20 * (19 - i), (i +1)* FH)-(_WIDTH - 20 * (19 - i), (i+1) * FH)-(_WIDTH - 20 * (19 - i), FH * i), ds
  25.     SLEEP
  26.  
  27. 'Do shading to black
  28. FOR i = 1 TO 15
  29.     LINE (0, 0)-(1280, 48 * i), _RGBA32(0, 0, 0, 15), BF
  30.     SLEEP
  31.  
  32.  
  33.     _LIMIT 30
  34. LOOP UNTIL _KEYDOWN(27) 'escape to end program
  35.  

Star Wars Jedi Font is needed to run this properly, but it can be downloaded from below.

Sceenshot of final output is attached.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Star Wars Text
« Reply #7 on: March 28, 2019, 08:43:13 pm »
I have fiddled and hacked the 2nd method using _PUTIMAGE technique and have better results:

WOW! It's just like Star Wars, without all the stupid crap to put up with. Great Job!!!

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Star Wars Text
« Reply #8 on: March 28, 2019, 09:44:29 pm »
yes It is fine
I have tested code using Lucon.ttf, it works the same also with minor effect.
Programming isn't difficult, only it's  consuming time and coffee

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Star Wars Text
« Reply #9 on: March 31, 2019, 03:00:52 pm »
In regards to your first example Steve, you did realize your mapping 2 different sized triangles from the square to the trapezoid right? the first triangle that you place(which I think you said was correct) is smaller than the second triangle that you place which distorts the results. would there be anyway to use more triangles to get the sizes closer to equal?
/\ \/ /\  - something like that with 3 triangles maybe? but I'm not sure how you would divide the square into 3 triangles though.
Granted after becoming radioactive I only have a half-life!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Star Wars Text
« Reply #10 on: March 31, 2019, 03:05:55 pm »
In regards to your first example Steve, you did realize your mapping 2 different sized triangles from the square to the trapezoid right? the first triangle that you place(which I think you said was correct) is smaller than the second triangle that you place which distorts the results. would there be anyway to use more triangles to get the sizes closer to equal?
/\ \/ /\  - something like that with 3 triangles maybe? but I'm not sure how you would divide the square into 3 triangles though.

I tested with that, but still had no luck.  As easy as _MAPTRIANGLE sounds, it just doesn’t work as needed in this instance.  _PUTIMAGE and scale by line is definitely the way to go, as bplus has working.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Star Wars Text
« Reply #11 on: March 31, 2019, 04:30:10 pm »
Far from perfect but sticking with MapTriangle check this one out Steve,
Code: QB64: [Select]
  1. DEFLNG A-Z
  2.  
  3. ds = _NEWIMAGE(640, 480, 32) 'display screen
  4. mx = _NEWIMAGE(640, 480, 32) 'mix layer
  5.  
  6. 'my original screen
  7. FOR i% = 220 TO -200 STEP -1
  8.  LINE (0, 0)-(200, 200), &HFFFF0000, BF 'a red square
  9.  LINE (0, 201)-(200, 480), &HFF000000, BF 'a red square
  10.  _PRINTSTRING (60, i%), "Hello World" 'with words
  11.  _PRINTSTRING (60, 40 + i%), " Star Wars " 'with words
  12.  _PRINTSTRING (60, 60 + i%), "  Scroll!" 'with words
  13.  _PRINTSTRING (60, 100 + i%), " Lets All" 'with words
  14.  _PRINTSTRING (50, 120 + i%), "Marvel at the" 'with words
  15.  _PRINTSTRING (45, 140 + i%), "Magic of BASIC" 'with words
  16.  _PRINTSTRING (45, 180 + i%), "Thank you for" 'with words
  17.  _PRINTSTRING (45, 200 + i%), "your Time long" 'with words
  18.  _PRINTSTRING (45, 220 + i%), "Long ago, on a" 'with words
  19.  _PRINTSTRING (45, 240 + i%), "Screen Far Far" 'with words
  20.  _PRINTSTRING (45, 260 + i%), "    AWAY!" 'with words
  21.  
  22.  TriCopy
  23.  LINE (300, 0)-(600, 180), &HFF000000, BF 'a red square
  24.  _PUTIMAGE , mx, ds
  25.  _DELAY .045
  26. NEXT i%
  27. '_PRINTSTRING (101, 190), "    He   llo  Wo   rld" 'with words
  28.  
  29.  
  30. 'LINE (400, 400)-(600, 400), &HFFFFFFFF
  31. 'LINE -(500, 0), &HFFFFFFFF
  32. 'LINE -(400, 400), &HFFFFFFFF
  33.  
  34. 'what I want to copy to, to create a "Star Wars" fade effect
  35. 'LINE (450, 200)-(550, 200), &HFFFF0000
  36. 'LINE -(600, 400), &HFFFFFF00
  37. 'LINE -(400, 400), &HFFFF00FF
  38. 'LINE -(450, 200), &HFFFFFFFF
  39.  
  40. 'SLEEP
  41. 'right side
  42. '_MAPTRIANGLE (200, 300)-(300, 100)-(300, 300)TO(500, 300)-(550, 100)-(600, 300)
  43.  
  44. 'SLEEP
  45. 'left side
  46. '_MAPTRIANGLE (100, 300)-(200, 300)-(100, 100)TO(400, 300)-(500, 300)-(450, 100)
  47.  
  48. 'SLEEP
  49. 'center
  50. '_MAPTRIANGLE (100, 100)-(200, 300)-(300, 100)TO(450, 100)-(500, 300)-(550, 100)
  51.  
  52. SUB TriCopy
  53.  FOR i%% = 0 TO 100
  54.   _MAPTRIANGLE (0 + i%% * 2, 0)-(0 + i%% * 2, 200)-(1 + i%% * 2, 200)TO(500, 0)-(400 + i%% * 2, 400)-(401 + i%% * 2, 400)
  55.  NEXT i%%
  56.  
  57.  
« Last Edit: March 31, 2019, 04:37:01 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Star Wars Text
« Reply #12 on: March 31, 2019, 07:36:35 pm »
Hi Cobalt,

Persistence pays! This is very interesting result.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Star Wars Text
« Reply #13 on: March 31, 2019, 09:06:16 pm »
Thanks B+, odd thing is I can't seem to get it to enlarge with _putimage. Justs gives me a blank screen, double checked my position and if I wait till the end of the for/next or exit it mid way I can get it to show but trying in the loop fails.
If you run this as is everything seems great and at the end it will show the 'zoomed' area correctly(if you hit ESC with text on the scroll area its show up) BUT if you change the 'mx' in the second _PUTIMAGE to 'fs' all you see is blank screen! but the first _PUTIMAGE must work cause it shows when you esc the loop, or the loop ends normally. So I'm getting the correct area of screen but its just not working inside the loop. Has me baffled at the moment.
I cleaned the code up a bit and tweaked a few things, I think I liked the stretched texted a little better though.

 
Code: QB64: [Select]
  1. DEFLNG A-Z
  2.  
  3. ds = _NEWIMAGE(640, 480, 32) 'display screen
  4. mx = _NEWIMAGE(640, 480, 32) 'mix layer
  5. fs = _NEWIMAGE(640, 480, 32) 'full screen layer
  6.  
  7. _SETALPHA 255, , fs
  8.  
  9. 'my original screen
  10. FOR i% = 420 TO -200 STEP -1
  11.  LINE (0, 0)-(200, 400), &HFFFF0000, BF 'a red square
  12.   _PRINTSTRING (60, i%), "Hello World" 'with words
  13.  _PRINTSTRING (60, 40 + i%), " Star Wars " 'with words
  14.  _PRINTSTRING (60, 60 + i%), "  Scroll!" 'with words
  15.  _PRINTSTRING (60, 100 + i%), " Lets All" 'with words
  16.  _PRINTSTRING (50, 120 + i%), "Marvel at the" 'with words
  17.  _PRINTSTRING (45, 140 + i%), "Magic of BASIC" 'with words
  18.  _PRINTSTRING (45, 180 + i%), "Thank you for" 'with words
  19.  _PRINTSTRING (41, 200 + i%), "your Time. Long" 'with words
  20.  _PRINTSTRING (45, 220 + i%), "Long ago, on a" 'with words
  21.  _PRINTSTRING (45, 240 + i%), "Screen Far Far" 'with words
  22.  _PRINTSTRING (45, 260 + i%), "    AWAY!" 'with words
  23. LINE (0, 401)-(200, 480), &HFF000000, BF 'a black area
  24.  
  25.  TriCopy
  26.  LINE (300, 0)-(600, 180), &HFF000000, BF 'a black area
  27.  _PUTIMAGE (0, 0)-STEP(639, 479), mx, fs, (400, 180)-STEP(200, 220)
  28.  _DELAY .045
  29. NEXT i%
  30.  
  31.  
  32. SUB TriCopy
  33.  FOR i%% = 0 TO 100
  34.   _MAPTRIANGLE (0 + i%% * 2, 0)-(0 + i%% * 2, 400)-(1 + i%% * 2, 400)TO(500, 0)-(400 + i%% * 2, 400)-(401 + i%% * 2, 400)
  35.  NEXT i%%
  36.  
Granted after becoming radioactive I only have a half-life!