Jump to content
Developer Wiki and Function Reference Links ×

setting pen color


Recommended Posts

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?

Link to comment

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.

Link to comment

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);

Link to comment

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 by Jesse Cogswell
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...