How do I paint a shape? - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10) +---- Thread: How do I paint a shape? (/showthread.php?tid=1790) |
RE: How do I paint a shape? - mnrvovrfc - 06-28-2023 ^ | 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. RE: How do I paint a shape? - bplus - 06-28-2023 (06-28-2023, 02:08 AM)mnrvovrfc Wrote: ^ 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) RE: How do I paint a shape? - bplus - 06-28-2023 Here we go, this is probably what @PhilofPerth is looking for: Code: (Select All) Screen _NewImage(1200, 820, 32) 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) RE: How do I paint a shape? - mnrvovrfc - 06-28-2023 (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. RE: How do I paint a shape? - bplus - 06-28-2023 (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. Check out my latest update to here , "Fooling around" RE: How do I paint a shape? - PhilOfPerth - 06-28-2023 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. RE: How do I paint a shape? - PhilOfPerth - 06-28-2023 (06-28-2023, 02:08 AM)mnrvovrfc Wrote: ^ My bad! Sorry. RE: How do I paint a shape? - PhilOfPerth - 06-28-2023 (06-27-2023, 02:19 PM)Petr Wrote: @PhilofPerth 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 RE: How do I paint a shape? - PhilOfPerth - 06-28-2023 (06-28-2023, 12:19 AM)TempodiBasic Wrote: HiThe 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. RE: How do I paint a shape? - mnrvovrfc - 06-28-2023 (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. |