From 0cbe4778d2bbf9545b32129bc749fd8155f5584f Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 2 Oct 2021 19:21:59 +0800 Subject: [PATCH] nac3standalone: demonstrate scalar conversion functions in mandelbrot --- nac3standalone/demo/mandelbrot.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nac3standalone/demo/mandelbrot.py b/nac3standalone/demo/mandelbrot.py index bb133b7d8..dc64d2218 100644 --- a/nac3standalone/demo/mandelbrot.py +++ b/nac3standalone/demo/mandelbrot.py @@ -6,18 +6,18 @@ def output_asciiart(x: int32): def run() -> int32: minX = -2.0 maxX = 1.0 - width = 78.0 - height = 36.0 + width = 78 + height = 36 aspectRatio = 2.0 - yScale = (maxX-minX)*(height/width)*aspectRatio + yScale = (maxX-minX)*(float(height)/float(width))*aspectRatio - y = 0.0 + y = 0 while y < height: - x = 0.0 + x = 0 while x < width: - c_r = minX+x*(maxX-minX)/width - c_i = y*yScale/height-yScale/2.0 + c_r = minX+float(x)*(maxX-minX)/float(width) + c_i = float(y)*yScale/float(height)-yScale/2.0 z_r = c_r z_i = c_i i = 0 @@ -29,7 +29,7 @@ def run() -> int32: z_r = new_z_r i = i + 1 output_asciiart(i) - x = x + 1.0 + x = x + 1 output_asciiart(-1) - y = y + 1.0 + y = y + 1 return 0