Posts: 1,586
Threads: 59
Joined: Jul 2022
Reputation:
52
^
|
Why did you assign "colr" twice? Maybe I should have rewritten my example suggesting to Phil to use another LONG integer variable, one for the border color and the other for the shape color. The 32-bit color doesn't have to be _UNSIGNED -- for those looking to save typing.
Posts: 3,965
Threads: 176
Joined: Apr 2022
Reputation:
219
06-28-2023, 02:16 AM
(This post was last modified: 06-28-2023, 02:20 AM by bplus.)
(06-28-2023, 02:08 AM)mnrvovrfc Wrote: ^
|
Why did you assign "colr" twice? Maybe I should have rewritten my example suggesting to Phil to use another LONG integer variable, one for the border color and the other for the shape color. The 32-bit color doesn't have to be _UNSIGNED -- for those looking to save typing.
If you are asking me, I didn't do that. I just did last line that paints. I didn't even notice it.
It is curious how the whole screen gets painted without a border color argument? Oh wait I added 32 to ends of RGB.
Update: the normal command works without 32's
Code: (Select All) Screen _NewImage(1200, 820, 32)
Dim colr As _Unsigned Long: colr = _RGB(255, 0, 0)
colr = _RGB(0, 255, 255)
PSet (500, 300): Draw "C" + Str$(colr) + "R100F100D100G100L100H100U100E100"
Paint (600, 410), colr ', colr
b = b + ...
Posts: 3,965
Threads: 176
Joined: Apr 2022
Reputation:
219
06-28-2023, 02:30 AM
(This post was last modified: 06-28-2023, 03:06 AM by bplus.)
Here we go, this is probably what @PhilofPerth is looking for:
Code: (Select All) Screen _NewImage(1200, 820, 32)
Dim colr As _Unsigned Long: colr = _RGB(255, 0, 0)
colr = _RGB(0, 255, 255)
PSet (500, 300): Draw "C" + Str$(colr) + "R100F100D100G100L100H100U100E100BM600,410P" + Str$(colr) + "," + Str$(colr)
'Paint (600, 410), colr ', colr
BM is Blind? Move, moving without drawing
Quote:"B" (blind) before a line move designates that the line move will be hidden. Use to offset from a "P" or PAINT border.
and for some reason P for Paint needs a border color along with Paint Color? It doesn't work with just the paint color.
Very finicky of Draw to be like that but it does seem to ignore spaces because we don't have to _Trim$(str$(colr))
So to sum up: After drawing the outline, Blind Move inside the object then P for paint the colr, borderColr
Fooling around:
Code: (Select All) Dim colr As _Unsigned Long: colr = _RGB(255, 0, 0)
colr = _RGB(255, 0, 0)
PSet (500, 300): Draw "C" + Str$(colr) + "R100F100D100G100L100H100U100E100BM600,410P" + Str$(colr) + "," + Str$(colr)
'Paint (600, 410), colr ', colr
' R100 does top edge of octagonal so middle x = 500 + 50
midX = 500 + 50
' diagonal down 100 is 100 down (and 100 right) then right edge down 100 want half = 50
midY = 300 + 100 + 50
'check
PSet (midX, midY) ' yep! theres the middle
_Font _LoadFont("Arial.ttf", 100)
_PrintMode _KeepBackground
_PrintString (midX - _PrintWidth("STOP") / 2, midY - 43), "STOP" ' 50 too much 43 better
b = b + ...
Posts: 1,586
Threads: 59
Joined: Jul 2022
Reputation:
52
(06-28-2023, 02:16 AM)bplus Wrote: If you are asking me, I didn't do that. I just did last line that paints. I didn't even notice it.
My bad. Now I noticed it came from the OP. Now we have to figure out if he wanted to draw in yellow but paint in red. That's why I proposed the two different variables for color.
Posts: 3,965
Threads: 176
Joined: Apr 2022
Reputation:
219
06-28-2023, 03:03 AM
(This post was last modified: 06-28-2023, 03:03 AM by bplus.)
(06-28-2023, 02:50 AM)mnrvovrfc Wrote: (06-28-2023, 02:16 AM)bplus Wrote: If you are asking me, I didn't do that. I just did last line that paints. I didn't even notice it.
My bad. Now I noticed it came from the OP. Now we have to figure out if he wanted to draw in yellow but paint in red. That's why I proposed the two different variables for color.
Check out my latest update to here , "Fooling around"
b = b + ...
Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
Thanks for all the tips and advice. I learned a lot from these!
I especially liked the example from bplus, that allowed selection of any fill color easily, and without a second LONG definition.
I'll go and "draw" a few deep breaths now and continue experimenting with the new knowledge.
Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
(06-28-2023, 02:08 AM)mnrvovrfc Wrote: ^
|
Why did you assign "colr" twice? Maybe I should have rewritten my example suggesting to Phil to use another LONG integer variable, one for the border color and the other for the shape color. The 32-bit color doesn't have to be _UNSIGNED -- for those looking to save typing.
My bad! Sorry.
Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
(06-27-2023, 02:19 PM)Petr Wrote: @PhilofPerth
Do you need the exact same shape in red?
In this way you can save to memory more images - and then place it using _PutImage - it is fastest method.
Code: (Select All)
'how create more images from one in different colors
Dim Images(3) As Long
Screen _NewImage(1200, 820, 32)
Dim colr As _Unsigned Long: colr = _RGB(255, 0, 0)
For ImageCreate = 0 To 3
Select Case ImageCreate
Case 0: R = 0: G = 255: B = 255
Case 1: R = 255: G = 255: B = 255
Case 2: R = 255: G = 255: B = 0
Case 3: R = 0: G = 0: B = 255
End Select
Images(ImageCreate) = _NewImage(1200, 820, 32)
_Dest Images(ImageCreate)
colr = _RGB(R, G, B)
PSet (500, 300): Draw "C" + Str$(colr) + "R100F100D100G100L100H100U100E100"
Next
_Dest 0
For ImageView = 0 To 3
Cls
_PutImage , Images(ImageView), 0
Print "Press any key for next image..."
Sleep
Next
Thanks Petr. No, I didn't necessarily want the exact same shape. I wanted a flexible algorithm that I could apply to different shapes to colour them
Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
06-28-2023, 05:36 AM
(This post was last modified: 06-28-2023, 09:08 AM by PhilOfPerth.)
(06-28-2023, 12:19 AM)TempodiBasic Wrote: Hi
all different and working ways
but P of draw is not so bad
Draw wiki page
and taking the example 4
Code: (Select All) SCREEN 12
DO
LOCATE 1, 1: INPUT "Enter a number 0 to 9: ", num
CLS
SELECT CASE num
CASE 0, 2, 3, 5 TO 9: PSET (20, 20), 12
DRAW "E2R30F2G2L30H2BR5P12,12" 'top horiz
END SELECT
SELECT CASE num
CASE 0, 4 TO 6, 8, 9: PSET (20, 20), 12
DRAW "F2D30G2H2U30E2BD5P12,12" 'left top vert
END SELECT
SELECT CASE num
CASE 0, 2, 6, 8: PSET (20, 54), 12
DRAW "F2D30G2H2U30E2BD5P12, 12" 'left bot vert
END SELECT
SELECT CASE num
CASE 2 TO 6, 8, 9: PSET (20, 54), 12
DRAW "E2R30F2G2L30H2BR5P12, 12" 'middle horiz
END SELECT
SELECT CASE num
CASE 0 TO 4, 7 TO 9: PSET (54, 20), 12
DRAW "F2D30G2H2U30E2BD5P12,12" 'top right vert
END SELECT
SELECT CASE num
CASE 0, 1, 3 TO 9: PSET (54, 54), 12
DRAW "F2D30G2H2U30E2BD5P12,12" 'bottom right vert
END SELECT
SELECT CASE num
CASE 0, 2, 3, 5, 6, 8: PSET (20, 88), 12
DRAW "E2R30F2G2L30H2BR5P12,12" 'bottom horiz
END SELECT
LOOP UNTIL num > 9
it is clear that all previous tips told in this thread have been used.
P of DRAW works fine also in 32 bit color
here the same example using a screen 32 and a col$ _RGBA32
Code: (Select All) Screen _NewImage(1000, 800, 32)
Col$ = Str$(_RGBA32(222, 116, 44, 255))
paint$ = "P" + Col$ + "," + Col$
Do
Locate 1, 1: Input "Enter a number 0 to 9: ", num
Cls
Select Case num
Case 0, 2, 3, 5 To 9: PSet (20, 20), Val(Col$)
Draw "E2R30F2G2L30H2BR5" + paint$ 'top horiz
End Select
Select Case num
Case 0, 4 To 6, 8, 9: PSet (20, 20), Val(Col$)
Draw "F2D30G2H2U30E2BD5" + paint$ 'left top vert
End Select
Select Case num
Case 0, 2, 6, 8: PSet (20, 54), Val(Col$)
Draw "F2D30G2H2U30E2BD5" + paint$ 'left bot vert
End Select
Select Case num
Case 2 To 6, 8, 9: PSet (20, 54), Val(Col$)
Draw "E2R30F2G2L30H2BR5" + paint$ 'middle horiz
End Select
Select Case num
Case 0 To 4, 7 To 9: PSet (54, 20), Val(Col$)
Draw "F2D30G2H2U30E2BD5" + paint$ 'top right vert
End Select
Select Case num
Case 0, 1, 3 To 9: PSet (54, 54), Val(Col$)
Draw "F2D30G2H2U30E2BD5" + paint$ 'bottom right vert
End Select
Select Case num
Case 0, 2, 3, 5, 6, 8: PSet (20, 88), Val(Col$)
Draw "E2R30F2G2L30H2BR5" + paint$ 'bottom horiz
End Select
Loop Until num > 9
I remember an exercise of the Terry's tutorial to build a landscape with DRAW, another to create Basic shapes to use for landscape.
In this last case you will find very useful the function S (scale) of DRAW to get different size of the same shape. The S (scale) function looks interesting.
I've experimented with it briefly, and with s2 at the front, the border and fill colors were transposed.
More experimenting needed.
Edit: No, they are not transposed, it seems the shape "leaks"... trying some more...
Edit 2:
The reason for the "leak" was that the point for painting was outside the shape when re-sized.
Posts: 1,586
Threads: 59
Joined: Jul 2022
Reputation:
52
(06-28-2023, 05:20 AM)PhilOfPerth Wrote: Thanks Petr. No, I didn't necessarily want the exact same shape. I wanted a flexible algorithm that I could apply to different shapes to colour them
It's worth studying what Petr and Terry propose, because as I've said before, it could be a chore to find point inside a shape out of only DRAW commands. It would be difficult even to tell from one DRAW string or several strings if the shape is closed, or if it draws several shapes together which are closed and which one to fill in.
A few years ago I wrote a QB64 program that does "interactive" DRAW commands. The user types in the DRAW string as QBasic/QB64 expects in the text editor area at the bottom of the screen, and the program then tries to execute the resulting DRAW string. It has two modes: one which is the text editor mode that I described, and another which is "doodle" mode with the arrow keys and other keys (for color and scale) but which still creates DRAW commands. I have to go find it in my backups.
One might have to build such a program to design the DRAW string for a specific shape and to figure out which is a safe point to use before painting. Otherwise it could cause repeated requests to compile that wear down the disk drive... only for one little adjustment to the DRAW string. Yes I have done that many times before.
|