Author Topic: Diagonal Gradient  (Read 4379 times)

0 Members and 1 Guest are viewing this topic.

Offline keybone

  • Forum Regular
  • Posts: 116
  • My name a Nursultan Tulyakbay.
    • View Profile
Diagonal Gradient
« on: August 03, 2018, 07:10:19 am »
Post Deleted
« Last Edit: April 14, 2022, 08:45:53 am by RCcola1987 »
I am from a Kazakhstan, we follow the hawk.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Diagonal Gradient
« Reply #1 on: August 03, 2018, 09:35:24 am »
Oh that's nice! I think there is a nice trick or lesson in there.
« Last Edit: August 03, 2018, 09:53:29 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Diagonal Gradient
« Reply #2 on: August 03, 2018, 11:25:25 am »
I am amazed that all those lines are drawing perfectly without overlap, even when I mess with their slant.

Here is an interesting Interference pattern using gradients:
Code: QB64: [Select]
  1. _TITLE "Interesting Interference Pattern"
  2. 'Bplus mod of diagonal gradient by keybone 2018-08-03
  3. SCREEN _NEWIMAGE(799, 631, 32)
  4. _SCREENMOVE 150, 40
  5. d = 1
  6.     CLS
  7.     gradientDiagonal 0, 0, _WIDTH, _HEIGHT, _RGB(255, 128, 0), _RGB(0, 128, 255), 255
  8.     stepper = stepper + 1 * d
  9.     IF stepper > 100 THEN stepper = 100: d = d * -1
  10.     IF stepper < -100 THEN stepper = -100: d = d * -1
  11.     FOR r = 1 TO 300 STEP 9
  12.         'CIRCLE (799 / 2 + stepper, 631 / 2), r, _RGB32(255)
  13.         CIRCLE (799 / 2 + stepper, 631 / 2), r, _RGB32(128, 0, 0)
  14.         CIRCLE (799 / 2 + stepper, 631 / 2), r + 3, _RGB32(0, 128, 0)
  15.         CIRCLE (799 / 2 + stepper, 631 / 2), r + 6, _RGB32(0, 0, 128)
  16.     NEXT
  17.     _DISPLAY
  18.     _LIMIT 20
  19.  
  20. SUB gradientDiagonal (x0, y0, w, h, c1 AS _UNSIGNED LONG, c2 AS _UNSIGNED LONG, a AS _UNSIGNED _BYTE)
  21.     DIM mr AS DOUBLE, mg AS DOUBLE, mb AS DOUBLE
  22.     dw = w + h
  23.     mr = (_RED(c2) - _RED(c1)) / dw
  24.     mg = (_GREEN(c2) - _GREEN(c1)) / dw
  25.     mb = (_BLUE(c2) - _BLUE(c1)) / dw
  26.     FOR d = 0 TO dw - 1 STEP 5
  27.         r = _RED(c2) + (d - dw) * mr
  28.         g = _GREEN(c2) + (d - dw) * mg
  29.         b = _BLUE(c2) + (d - dw) * mb
  30.         IF d <= h - 1 THEN
  31.             LINE (x0 + d, y0)-(x0, y0 + d), _RGBA32(r, g, b, a)
  32.         ELSEIF d >= h AND d <= w - 1 THEN
  33.             LINE (x0 + d, y0)-(x0 + (d - h), y0 + h), _RGBA32(r, g, b, a)
  34.         ELSEIF d >= w AND d <= dw - 1 THEN
  35.             LINE (x0 + w, y0 + (d - w))-(x0 + (d - h), y0 + h), _RGBA32(r, g, b, a)
  36.         END IF
  37.     NEXT d
  38.  

I remember spending quite some time trying to figure out how to draw a grid of diagonal lines.
Now I have another idea for mod... :)
« Last Edit: August 03, 2018, 11:35:23 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Diagonal Gradient
« Reply #3 on: August 03, 2018, 11:54:12 am »
OH! They are all perfect because they are all 45 degrees! Aha!