Text Only
|
Text with Attachments
QB64.org Forum
Active Forums => Programs => Topic started by: keybone on August 03, 2018, 07:10:19 am
Title:
Diagonal Gradient
Post by:
keybone
on
August 03, 2018, 07:10:19 am
Post Deleted
Title:
Re: Diagonal Gradient
Post by:
bplus
on
August 03, 2018, 09:35:24 am
Oh that's nice! I think there is a nice trick or lesson in there.
Title:
Re: Diagonal Gradient
Post by:
bplus
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]
_TITLE
"Interesting Interference Pattern"
'Bplus mod of diagonal gradient by keybone 2018-08-03
SCREEN
_NEWIMAGE
(
799
,
631
,
32
)
_SCREENMOVE
150
,
40
d
=
1
WHILE
NOT
_KEYDOWN
(
27
)
CLS
gradientDiagonal
0
,
0
,
_WIDTH
,
_HEIGHT
,
_RGB
(
255
,
128
,
0
)
,
_RGB
(
0
,
128
,
255
)
,
255
stepper
=
stepper
+
1
*
d
IF
stepper
>
100
THEN
stepper
=
100
: d
=
d
*
-
1
IF
stepper
<
-
100
THEN
stepper
=
-
100
: d
=
d
*
-
1
FOR
r
=
1
TO
300
STEP
9
'CIRCLE (799 / 2 + stepper, 631 / 2), r, _RGB32(255)
CIRCLE
(
799
/
2
+
stepper
,
631
/
2
)
,
r
,
_RGB32
(
128
,
0
,
0
)
CIRCLE
(
799
/
2
+
stepper
,
631
/
2
)
,
r
+
3
,
_RGB32
(
0
,
128
,
0
)
CIRCLE
(
799
/
2
+
stepper
,
631
/
2
)
,
r
+
6
,
_RGB32
(
0
,
0
,
128
)
NEXT
_DISPLAY
_LIMIT
20
WEND
SUB
gradientDiagonal
(
x0
,
y0
,
w
,
h
,
c1
AS
_UNSIGNED
LONG
,
c2
AS
_UNSIGNED
LONG
,
a
AS
_UNSIGNED
_BYTE
)
DIM
mr
AS
DOUBLE
,
mg
AS
DOUBLE
,
mb
AS
DOUBLE
dw
=
w
+
h
mr
=
(
_RED
(
c2
)
-
_RED
(
c1
)
)
/
dw
mg
=
(
_GREEN
(
c2
)
-
_GREEN
(
c1
)
)
/
dw
mb
=
(
_BLUE
(
c2
)
-
_BLUE
(
c1
)
)
/
dw
FOR
d
=
0
TO
dw
-
1
STEP
5
r
=
_RED
(
c2
)
+
(
d
-
dw
)
*
mr
g
=
_GREEN
(
c2
)
+
(
d
-
dw
)
*
mg
b
=
_BLUE
(
c2
)
+
(
d
-
dw
)
*
mb
IF
d
<=
h
-
1
THEN
LINE
(
x0
+
d
,
y0
)
-
(
x0
,
y0
+
d
)
,
_RGBA32
(
r
,
g
,
b
,
a
)
ELSEIF
d
>=
h
AND
d
<=
w
-
1
THEN
LINE
(
x0
+
d
,
y0
)
-
(
x0
+
(
d
-
h
)
,
y0
+
h
)
,
_RGBA32
(
r
,
g
,
b
,
a
)
ELSEIF
d
>=
w
AND
d
<=
dw
-
1
THEN
LINE
(
x0
+
w
,
y0
+
(
d
-
w
)
)
-
(
x0
+
(
d
-
h
)
,
y0
+
h
)
,
_RGBA32
(
r
,
g
,
b
,
a
)
END
IF
NEXT
d
END
SUB
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... :)
Title:
Re: Diagonal Gradient
Post by:
bplus
on
August 03, 2018, 11:54:12 am
OH! They are all perfect because they are all 45 degrees! Aha!
Text Only
|
Text with Attachments