2012-01-18 3 views

답변

1

아무 것도 모르지만 글을 쓰는 것은 그렇게 어렵지 않습니다.

모두는 당신이 그것을 사용하려는 목적에 따라 달라집니다 물론
fn shuffle &arr = 
(
    local temp, swapIndex, counter = arr.count + 1 
    while counter > 1 do 
    (
     swapIndex = random 1 (counter -= 1) 
     temp = arr[counter] 
     arr[counter] = arr[swapIndex] 
     arr[swapIndex] = temp 
    ) 
    OK 
) 

fn incrementCounters &r &g &b step = 
(
    if (b += step) > 256 do 
    (
     b = 1 
     if (g += step) > 256 do 
     (
      g = 1 
      if (r += step) > 256 do r = 1 
     ) 
    ) 
) 

fn assignRandomWirecolor objs simple:true = 
(
    local stepCount = objs.count^(double 1/3) + 1 
    local step = 255./stepCount 
    local redArr = #(0) + #{1..255} 
    local greenArr = copy redArr #noMap 
    local blueArr = copy redArr #noMap 
    local r = local g = local b = 1 

    if simple then 
    (
     shuffle &redArr 
     shuffle &greenArr 
     shuffle &blueArr 
    ) 
    else shuffle &sel -- slower with many objects 

    for obj in objs do 
    (
     obj.wirecolor = [redArr[int(r)], greenArr[int(g)], blueArr[int(b)]] 
     incrementCounters &r &g &b step 
    ) 
) 


sel = selection as array 
clearSelection() 
assignRandomWirecolor sel --simple:false --> if simple is not so cool, try the other option 
select sel 

는이 같은 단지 일반적인 접근하고있다 : 당신이 가서 여기

, 그것은 당신이 그것을 예상 할 것입니다 희망 그 정확한 작업에 적합하지 않을 수도 있습니다. 이 경우 세부 정보를 제공 할 수 있으며 조정할 것입니다.

+0

도움을 주셔서 감사합니다. 이것은 내가 찾고 있던 것이고, 지금은 작동 중입니다! ;) 고마워! –

관련 문제