- 情況不同於 rand 函數,很幸運,max 函數,Scheme 與 Python ,用法類似。
(define amplitude (max 0 amplitude))
(define wavelength (max 0 wavelength))
(define num-frames (max 1 num-frames))
Python code
amplitude = max(0, amplitude)
wavelength = max(0, wavelength)
num_frames = max(1, num_frames)
Scheme code
(define layer-name (string-append "Frame "
(number->string (- (+ num-frames 2) remaining-frames) 10) " (replace)"))
Python code
layer_name = "Frame " + str(num_frames + 2 - remaining_frames) + " (replace)"
Scheme code
(define phaseshift (/ 360 num-frames))
Python code
phaseshift = 360 / num_frames
Scheme code
(set! remaining-frames (- remaining-frames 1))
(set! phase (- phase phaseshift))
Python code
remaining_frames = remaining_frames - 1
phase = phase - phaseshift
Scheme code 要注意括號對齊
(while (> remaining-frames 1) (define waves-layer (car (...))) ...... (set! phase (- phase phaseshift)) )
Python code 要注意縮排
while remaining_frames > 1: waves_layer = pdb.gimp_layer_copy(...) ...... phase = phase - phaseshift
Scheme code
(define text-color "black")
(define bg-color "white")
Python code
text_color = (0, 0, 0)
bg_color = (255, 255, 255)