Setting the background color of a Poly
8 posts
• Page 1 of 1
Setting the background color of a Poly
In the function below, I can set the color of the lines of a Poly to anything I want ("fgr"=the foreground RGB color). But I can't see how to set the background. I tried setting BCol ("bgr"= background RGB color), but that doesn't do anything. I just get the same light gray background. How do you change the background color?
colordisp T;⎕IO;rt;x;y
⎕IO←0
rt←⍴T
x←(rt⍴1 0)/T
y←(rt⍴0 1)/T
x←⌈0.135×x
y←⌈0.25×y
:If ((1↑x)=¯1↑x)∨(1↑y)=¯1↑y
x←x,1↑x
y←y,1↑y
:EndIf
'F'⎕WC'Form'
BCol←bgr
'F.L1'⎕WC'Poly'(y x)(fgr)
colordisp T;⎕IO;rt;x;y
⎕IO←0
rt←⍴T
x←(rt⍴1 0)/T
y←(rt⍴0 1)/T
x←⌈0.135×x
y←⌈0.25×y
:If ((1↑x)=¯1↑x)∨(1↑y)=¯1↑y
x←x,1↑x
y←y,1↑y
:EndIf
'F'⎕WC'Form'
BCol←bgr
'F.L1'⎕WC'Poly'(y x)(fgr)
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: Setting the background color of a Poly
Hi Stu
Depending on what you want to accomplish you would use the BCol property of the form or the poly object or the FillCol property of the poly. If you set the BCol of the form
If you set the BCol of the poly
Finally, you can use FillCol and FStyle properties of poly to fill the area defined by the poly:
Depending on what you want to accomplish you would use the BCol property of the form or the poly object or the FillCol property of the poly. If you set the BCol of the form
F.BCol←255 0 0the entire canvas gets colored.
If you set the BCol of the poly
F.L1.BCol←0 0 255you will only see the effect if you use a non-solid line style (eg. dashed or dotted)
F.L1.LStyle←1.
Finally, you can use FillCol and FStyle properties of poly to fill the area defined by the poly:
F.L1.FStyle←0
F.L1.FillCol←255 255 0
- gil
- Posts: 71
- Joined: Mon Feb 15, 2010 12:42 am
Re: Setting the background color of a Poly
Thanks gil! I just love this group. I get great answers to my questions almost immediately.
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: Setting the background color of a Poly
Having gotten the display of a poly to work, I'd now like to be able to save the pictures in some standard file format (.bmp, .gif, .jpg, etc.). Is this possible?
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: Setting the background color of a Poly
Hi Stu,
To create a bitmap, you could draw the poly on the bitmap.
Example:
Regards,
Vince
To create a bitmap, you could draw the poly on the bitmap.
Example:
BY ← 10 10 50 10
BX ← 15 65 40 15
RY ← 15 15 40 15
RX ← 25 55 40 25
'bmp' ⎕wc 'bitmap' ('size' 1000 1000) ('coord' 'pixel') ('bits' (1000 1000 ⍴ 1))
'bmp.L1'⎕WC'Poly' ('points' (BY BX)(RY RX))
'bmp' ⎕ws 'file' 'c:\tmp\mypoly.bmp'
2 ⎕nq 'bmp' 'filewrite'
Regards,
Vince
- Vince|Dyalog
- Posts: 413
- Joined: Wed Oct 01, 2008 9:39 am
Re: Setting the background color of a Poly
Hi Vince,
That did the trick. I had no idea you could write a poly into a bitmap. There is SO much to learn! I wonder how many people at Dyalog remember APL circa 1980. We did "graphics" with APL characters back then (often on a dumb printing terminal).
-Stu
That did the trick. I had no idea you could write a poly into a bitmap. There is SO much to learn! I wonder how many people at Dyalog remember APL circa 1980. We did "graphics" with APL characters back then (often on a dumb printing terminal).
-Stu
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: Setting the background color of a Poly
Hi Vince,
The code segment you gave me worked fine for black and white line pictures. When I tried to add color as below, the line color and fill color were both correct, but the background always came out the same default color, like the one I'm typing this message on. It makes no difference if I comment out the fourth line or leave it in. If I just display the poly on the screen, all three colors are correct (line, fill, and background colors come from predefined RGB palettes in my program).
-Stu
x←85+24×x-31
y←70+13×y-12
'bmp'⎕WC'bitmap'('size' 1000 1000)('coord' 'pixel')('bits'(1000 1000⍴1))
⍝ bmp.BCol←background
'bmp.L1'⎕WC'Poly'('points'(y x))(line)('FillCol'fill)('BCol'background)('FStyle' 0)
filename←'C:\Users\Stuart Smith\Desktop\study',(⍕seqno),'.bmp'
'bmp'⎕WS'file'filename
2 ⎕NQ'bmp' 'filewrite'
The code segment you gave me worked fine for black and white line pictures. When I tried to add color as below, the line color and fill color were both correct, but the background always came out the same default color, like the one I'm typing this message on. It makes no difference if I comment out the fourth line or leave it in. If I just display the poly on the screen, all three colors are correct (line, fill, and background colors come from predefined RGB palettes in my program).
-Stu
x←85+24×x-31
y←70+13×y-12
'bmp'⎕WC'bitmap'('size' 1000 1000)('coord' 'pixel')('bits'(1000 1000⍴1))
⍝ bmp.BCol←background
'bmp.L1'⎕WC'Poly'('points'(y x))(line)('FillCol'fill)('BCol'background)('FStyle' 0)
filename←'C:\Users\Stuart Smith\Desktop\study',(⍕seqno),'.bmp'
'bmp'⎕WS'file'filename
2 ⎕NQ'bmp' 'filewrite'
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: Setting the background color of a Poly
Hi Stu,
The bitmap does not really have a background colour as such. I've just drawn a 1000 by 1000 pixel picture and set the Bits property.
We can use the CBits property instead to make a green bitmap:
Regards,
Vince
The bitmap does not really have a background colour as such. I've just drawn a 1000 by 1000 pixel picture and set the Bits property.
We can use the CBits property instead to make a green bitmap:
green←256 ⊥ 0 200 0
'bmp'⎕WC'bitmap'('size' 1000 1000)('coord' 'pixel')('CBits'(1000 1000⍴green))
Regards,
Vince
- Vince|Dyalog
- Posts: 413
- Joined: Wed Oct 01, 2008 9:39 am
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group