2012-11-21 2 views
3

원을 어떻게 VHDL로 그릴 수 있습니까? my BDF design동그라미 그리기

암 ,지, 빨간색 원 ~ 100px 반경을 그릴 필요가 있습니다. 나는 어떤 벡터를 사용해야한다고 생각하지만 어떻게?

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

당신이 157,696을 변경하여 임의의 반경을 설정할 수있다 (160,000은 - (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이 될 것이라는 것을 알기 시작합니다), 그것을 정사각형으로 만들고 R * 2 - X * 2를 각각의 새 X에 대해 비교하여 잘못된 경우 추측을 수정하십시오 너무 많이. Martin의 검색 용어가 도움이 될 것입니다.

화면상의 올바른 위치에 원점 (0,0)을 설정하는 좌표 변환은 비교적 쉽습니다.

+0

죄송합니다. 더 자세한 정보는 여기에서 확인하십시오. 처음에 게시 한 코드를 작성하기에 충분한 VHDL을 알고 있다면 내 대답의 힌트에서 프로젝트를 완료 할 수 있습니다. –