Author Topic: Block Printing  (Read 4230 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Block Printing
« on: November 20, 2019, 12:31:58 am »
Code: QB64: [Select]
  1. _TITLE "Cube It"
  2. CONST xmax = 1200, ymax = 600
  3. SCREEN _NEWIMAGE(xmax, ymax, 32)
  4. _SCREENMOVE 100, 40
  5.  
  6. PRINT " bplus was here "
  7. DIM section(127, 16)
  8. FOR y = 0 TO 16
  9.     FOR x = 0 TO 127
  10.         IF POINT(x, y) <> _RGB32(0, 0, 0) THEN section(x, y) = 1
  11.     NEXT
  12.  
  13. FOR l = 0 TO -32 * 4 STEP -4
  14.     FOR y = 8 TO 8 * 16 STEP 8
  15.         FOR x = 127 * 8 TO 0 STEP -8
  16.             IF section(x / 8, y / 8) THEN cube2 x - l + 25, 350 + y + l, 16, &HFF88BBFF
  17.         NEXT
  18.     NEXT
  19.     _DISPLAY
  20.     _LIMIT 30
  21.  
  22. SUB cube2 (x, y, side, c~&)
  23.     sd2 = side / 2
  24.     LINE (x + sd2, y)-STEP(sd2 - 1, sd2 - 1), c~&, BF
  25.     r = _RED32(c~&): g = _GREEN32(c~&): b = _BLUE32(c~&)
  26.     fquad x + sd2, y, x + sd2, y + sd2, x, y + side, x, y + sd2, _RGB32(.25 * r, .5 * g, .75 * b)
  27.     fquad x, y + side, x + sd2, y + sd2, x + side, y + sd2, x + sd2, y + side, _RGB32(.75 * r, .3 * g, .3 * b)
  28.  
  29. 'this text was fetched
  30. SUB ftri (x1, y1, x2, y2, x3, y3, K AS _UNSIGNED LONG)
  31.     DIM a&
  32.     a& = _NEWIMAGE(1, 1, 32)
  33.     _DEST a&
  34.     PSET (0, 0), K
  35.     _DEST 0
  36.     _MAPTRIANGLE _SEAMLESS(0, 0)-(0, 0)-(0, 0), a& TO(x1, y1)-(x2, y2)-(x3, y3)
  37.     _FREEIMAGE a& '<<< this is important!
  38.  
  39. 'need 4 non linear points (not all on 1 line) list them clockwise so x2, y2 is opposite of x4, y4
  40. SUB fquad (x1, y1, x2, y2, x3, y3, x4, y4, K AS _UNSIGNED LONG)
  41.     ftri x1, y1, x2, y2, x4, y4, K
  42.     ftri x3, y3, x2, y2, x4, y4, K
  43.  
  44.  
block printing.PNG
* block printing.PNG (Filesize: 21.62 KB, Dimensions: 1207x631, Views: 228)