返回列表 回复 发帖
UF代码

Rings_Coloring {
  ; Paul W. Carlson
  ; Variant #1 extracted from "RsNewtMset1".
  ; Variant #2 extracted from "R4Julia".
  ; By Ken Childress June 1999.
init:
  bool first = TRUE
  bool trapped = FALSE
  int iter = 0
  float HalfT = 0.5 * @T
  float Phi = #pi * 0.125
  float Ro = @Rm + HalfT
  float Py = @Rm * sin(Phi)
  float Px = @Rm * cos(Phi)
  float Dsqd = @Rm * @Rm + Ro * Ro - 2 * Ro * Px
  float color_index = 252
  float index_factor = @colors_in_range - 1
   
  ; Initialization for Variant #1
  complex k = (0.5, 0.5)
  float index_factor1 = (@colors_in_range - 1) / @Rm

loop:
  IF @Variant == 0
  
    IF (!trapped && (abs(cabs(#z) - @Rm) < HalfT) && \
      first == FALSE && iter >= @skip)
      
      trapped = TRUE
      float X = real(#z)
      float Y = imag(#z)
      float Xabs = abs(X)
      float Yabs = abs(Y)
      IF (Xabs >= Yabs)
        float WtoPsqd = (Xabs-Px)*(Xabs-Px) + (Yabs-Py)*(Yabs-Py)
      ELSE
        WtoPsqd = (Xabs-Py)*(Xabs-Py) + (Yabs-Px)*(Yabs-Px)
      ENDIF
      IF (X >= 0 && Y >= 0)
        IF (Xabs >= Yabs)
          float Segment = 0
        ELSE
          Segment = 1
        ENDIF
      ELSEIF (X < 0 && Y >= 0)
        IF (Xabs < Yabs)
          Segment = 2
        ELSE
          Segment = 3
        ENDIF
      ELSEIF (X < 0 && Y < 0)
        IF (Xabs >= Yabs)
          Segment = 4
        ELSE
          Segment = 5
        ENDIF
      ELSE
        IF (Xabs < Yabs)
          Segment = 6
        ELSE
          Segment = 7
        ENDIF
      ENDIF
      float Ratio = sqrt(WtoPsqd/Dsqd)
      ; Modulate Segment for less than eight ranges.
      float range_num = Segment % @num_ranges
      color_index = index_factor * Ratio + range_num * @colors_in_range
    ENDIF
    first = FALSE
   
  ELSEIF @Variant == 1
  
    IF !trapped && iter >= @skip
      float dist = abs(|#z - k| - 0.01)
      IF dist < @Rm
        trapped = TRUE
        float range_num = iter % @num_ranges
        color_index = index_factor1 * dist + range_num * @colors_in_range
      ENDIF
    ENDIF

  ENDIF
  
  iter = iter + 1

final:
  if trapped
    ; Adjust color index to gradient range.
    #index = (color_index + 1) % 256 / 256 + @randomness * real(#random)
  else
    if @solid
      #solid = true
    else
    ; For the purists we don't have to be solid.
      #index = @back_color / 256
    endif
  endif

default:
  title = "Ring Coloring"
  
  param Variant
    caption = "Ring Variant"
    enum = "Variant #1" "Variant #2"
    default = 0
    hint = "The Ring variant to use."
  endparam

  param Rm
    caption = "Ring radius"
    default = 1.0
    hint = "The radius to the midline of the ring."
  endparam

  param T
    caption = "Ring thickness"
    default = 0.2
    hint = "The thickness of the ring. This is not used for Variant #2."
  endparam
  
  param skip
    caption = "Iterations to Skip"
    default = 0
    hint = "The number of iterations to skip.  This is not used for Normal."
  endparam

  param num_ranges
    Caption = "Color ranges"
    hint = "This is the number of separate color ranges."
    default = 8
  endparam

  param colors_in_range
    Caption = "Colors in range"
    hint = "This is the number of colors in each color range."
    default = 30
  endparam

  param back_color
    caption = "Background Color"
    hint = "This is the color used for orbits that aren't trapped. It has \
           no effect if the background is solid."
    default = 254
  endparam

  param solid
    caption = "Solid Background"
    hint = "If this is enabled orbits that aren't trapped become solid."
    default = false
  endparam
  
  param randomness
    caption = "Random Texture"
    default = 0.0
    hint = "This adds a random texture to the coloring."
  endparam
}
New.jpg

一园一环陷阱
New.jpg

同臂同色
New.jpg
New.jpg
New.jpg
New.jpg
New.jpg
New.jpg
New.jpg
New.jpg
New.jpg
New.jpg
返回列表