How to resolve the algorithm Cantor set step by step in the FutureBasic programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Cantor set step by step in the FutureBasic programming language
Table of Contents
Problem Statement
Draw a Cantor set.
See details at this Wikipedia webpage: Cantor set
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Cantor set step by step in the FutureBasic programming language
Source code in the futurebasic programming language
_window = 1
_width = 81
_height = 5
window _window, @"FutureBasic Cantor Set", ( 0, 0, 695, 100 )
WindowSetBackgroundColor( _window, fn ColorWhite )
text @"Menlo", 14.0, fn ColorRed
begin globals
CFStringRef gInterval( _height, _width )
end globals
local fn Init
NSInteger i, j
for i = 0 to _height - 1
for j = 0 to _width - 1
gInterval( i, j ) = @"◼︎"
next
next
end fn
local fn CantorSet( start as NSInteger, length as NSInteger, index as NSInteger )
NSInteger i, j, segment = length / 3
if segment == 0 then exit fn
for i = index to _height - 1
for j = start + segment to start + segment * 2 - 1
gInterval( i, j ) = @" "
next
next
fn CantorSet( start, segment, index + 1 )
fn CantorSet( start + segment * 2, segment, index + 1 )
end fn
NSInteger i, j
fn Init
fn CantorSet ( 0, _width, 1 )
for i = 0 to _height - 1
for j = 0 to _width - 1
print gInterval( i, j );
next
print
next
HandleEvents
You may also check:How to resolve the algorithm Sorting algorithms/Selection sort step by step in the Tcl programming language
You may also check:How to resolve the algorithm Queue/Definition step by step in the Stata programming language
You may also check:How to resolve the algorithm Speech synthesis step by step in the Sidef programming language
You may also check:How to resolve the algorithm Meissel–Mertens constant step by step in the Sidef programming language
You may also check:How to resolve the algorithm Binary digits step by step in the Panda programming language