2012-11-21 336 views
3

如何在VHDL中繪製圓圈? 還有my BDF design繪製圓圈vhdl

母豬,我需要繪製紅圈〜100像素的半徑。我想我應該使用一些矢量,但是如何?

entity VGAFrameTest is 
port( yrow, xcolumn : in unsigned(9 downto 0); -- row and column number of VGA video 
     VGA_CLK : in std_logic;    -- pixel clock 
     VGA_R, VGA_G, VGA_B: out std_logic_vector(9 downto 0)); -- color information 
end; 

architecture rtl of VGAFrameTest is 
constant COLOR_ON : std_logic_vector(9 downto 0) := (others=>'1'); 
constant COLOR_OFF : std_logic_vector(9 downto 0) := (others=>'0'); 
constant ROW_HEIGHT : integer := 480; -- number of visible rows 
-- A test of visible range is recommended 
-- VGA [email protected] resolution is not natural for LCD monitors 
-- They support it but some monitors do not display all columns 
-- 1 or 2 last columns can be missing 
constant COLUMN_WIDTH : integer := 640 -1 ; -- number of visible columns - correction 

begin 
    frame:process(VGA_CLK) 
    begin 
    if rising_edge(VGA_CLK) then 
     VGA_R<=COLOR_ON;VGA_G<=COLOR_ON;VGA_B<=COLOR_ON; --initilize color to white 
     if (yrow = 240 and xcolumn = 320) then 
      VGA_B<=COLOR_OFF; VGA_G<=COLOR_OFF; 
     elsif yrow = 1 or yrow = ROW_HEIGHT-2 or xcolumn=1 or xcolumn = COLUMN_WIDTH-2 then 
      VGA_R<=COLOR_OFF; VGA_G<=COLOR_OFF; VGA_B<=COLOR_OFF; -- black frame 
     elsif yrow = ROW_HEIGHT-1 then   
      VGA_B<=COLOR_OFF; VGA_G<=COLOR_OFF; --last column is red 
     end if; 
end if;  
end process; 

end; 
+0

概述或填充? –

+1

潛在有用的搜索詞:bresenham,scanline –

回答

2

您可以通過更改157696設置任何半徑(160000 - R^2)

480和640的圓心乘以2

begin 
     frame:process(VGA_CLK) 
     begin 
     if rising_edge(VGA_CLK) then 
     VGA_R<=COLOR_OFF;VGA_G<=COLOR_OFF;VGA_B<=COLOR_OFF; 
      if yrow>159 and yrow <320 and xcolumn < 440 and xcolumn > 199 then 
       VGA_B<=COLOR_ON; VGA_G<=COLOR_ON;VGA_R<=COLOR_ON; 

       if (480*yrow-yrow*yrow+640*xcolumn-xcolumn*xcolumn)> 157696 then 
       VGA_B<="0001001100"; VGA_G<=COLOR_OFF; VGA_R <= "1011111000"; 
      end if; 
      end if; 


end if;  
end process; 
2

的一種方法是對X**2 + Y**2 = R**2;Y = Sqrt(R**2 - X**2)

特技一些變型中,以一種有效的實現,以避免像SQRT昂貴的操作,並最小化(略)昂貴的乘法。你可以猜測Y,(從某處開始你知道Y會是0),將它平方,並與每個新X的R * 2 - X * 2進行比較,修改你的猜測時間太多了。 Martin的搜索字詞在這裏會有所幫助。

在屏幕上正確位置設置原點(0,0)的座標變換相對容易。

+0

對不起,沒有更多的信息從這裏。如果你知道足夠的VHDL編寫你最初發布的代碼,你就足夠了解我的答案中的提示來完成項目。 –