grant_PD Posted April 6 Share Posted April 6 I have a simple script but can't figure out why the pen color doesn't change when I run it: PROCEDURE DrawRect; BEGIN PenFore(0,4000,0); Rect(0,0,100,-50); END; Run (DrawRect); must be something simple, right? Quote Link to comment
Jesse Cogswell Posted April 6 Share Posted April 6 In this case it might be better to use SetPenFore instead. The code would look something like this: PROCEDURE DrawRect; BEGIN Rect(0,0,100,-50); SetPenFore(LNewObj,0,4000,0); END; Run (DrawRect); Handles are a tricky thing to get your head around, at least they were for me when I first got into scripting. But they are also usually the "safer" way to script so that you aren't changing your active settings between creating objects. The LNewObj function will always give you the handle to the most recently created object, so typical operating procedure is to create an object, then use LNewObj to set all of the attributes and parameters of the object, then create the next one. You might also need to include a SetPenBack with the same colors you used in SetPenFore. In my experience, setting the pen color requires SetPenFore and setting the fill requires SetFillBack. You don't really need both fore and back unless your fill type is set to Pattern, but if you're feeling unsure or paranoid, you can include both. Quote Link to comment
grant_PD Posted April 6 Author Share Posted April 6 all of those solutions didn't change anything? Here's where I am now and it still makes a black rectangle PROCEDURE DrawRect; BEGIN Rect(0,0,100,-50); SetPenFore(LNewObj,0,4000,0); SetPenBack(LNewObj,0,4000,0); END; Run (DrawRect); Quote Link to comment
Jesse Cogswell Posted April 6 Share Posted April 6 (edited) What are your fill settings when you run the script? You don't specify a fill color in your script, so it's likely using your active fill color, which may very well be black. If you want it to be white, you would need to add SetFillBack(LNewObj,65535,65535,65535); Also, keep in mind that color 0,0,0 is black, 65535,65535,65535 is white. The color you specified in the script above is a very dark green, practically black. Edited April 6 by Jesse Cogswell Quote Link to comment
Jesse Cogswell Posted April 6 Share Posted April 6 Adding an extra 0 to your color script (as in 40000) will produce a rectangle like this: 1 Quote Link to comment
grant_PD Posted April 6 Author Share Posted April 6 @Jesse Cogswell that did the trick! 1 Quote Link to comment
SamIWas Posted April 13 Share Posted April 13 On 4/6/2026 at 12:40 PM, grant_PD said: @Jesse Cogswell that did the trick! I saw this and was going to post...0,4000,0 is only 6% green, so it's going to appear black. Remember that all RGB colors are across a range of 0-65535. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.