2016-06-29 4 views
-2

C#에서 자체 앨리어싱 앨리어싱 알고리즘을 작성하고 싶습니다. 내 그림은 두 가지 색만 있습니다. 검정색과 흰색.C# 앤티 앨리어싱 알고리즘

Define function PlotAntiAliasedPoint (number x, number y) 
    For roundedx = floor (x) to ceil (x) do 
     For roundedy = floor (y) to ceil (y) do 
       percent_x = 1 - abs (x - roundedx) 
       percent_y = 1 - abs (y - roundedy) 
       percent = percent_x * percent_y 
       DrawPixel (coordinates roundedx, roundedy, color percent (range 0-1)) 

가 어떻게 C#에서이 의사를 구현합니까 : (https://en.wikipedia.org/wiki/Spatial_anti-aliasing) 위키 백과에

나는 다음과 같은 pseudecode을 발견?

+2

매우 자명합니다. 구체적으로 도움이 필요한 것은 무엇입니까? – Jashaszun

+0

나는 'for roundedx = floor (x) to ceil (x) do' 행을 이해하지 못한다. –

+3

Python이나 Java 또는 Javascript 또는 C 또는 C++에서 보듯이 보통의 for 루프이다. 정말로 대부분의 언어. (int roundedx = Math.Floor (x); roundedx <= Math.Ceiling (x); roundedx ++) {/ * rest of stuff * /}' – Jashaszun

답변

0
private void PlotAntiAliasedPoint(decimal x, decimal y) 
{ 
    for (var roundedx = Math.Floor(x); roundedx <= Math.Ceiling(x); roundedx++) 
    { 
    for (var roundedy = Math.Floor(y); roundedy <= Math.Ceiling(y); roundedy++) 
    { 
     var percent_x = 1 - Math.Abs(x - roundedx); 
     var percent_y = 1 - Math.Abs(y - roundedy); 
     var percent = percent_x*percent_y; 
     //DrawPixel(coordinates roundedx, roundedy, color percent(range 0 - 1)) 
    } 
    } 
}