TweetFollow Us on Twitter

Art
Volume Number:3
Issue Number:2
Column Tag:Fun With A Mac

Random MacArt in Basic

By Amy Barger, Waunakee, WI

Random MacArt is an MS Basic program which creates catchy modern art designs. Each design is unique and exciting with a general movement expressed. These designs can be created almost instantaneously and have many potential uses for decorating, entertainment, and experimentation. Figure 1 shows a design created by Random MacArt.

Fig. 1 Our random art program in Basic

Using Random MacArt

Random MacArt is an easy program to use. To create a design, press COMMAND R and watch the random designs appear; the computer screen will seem alive! Each design will finish on its own. After you have admired or printed the design, click the mouse button once and a fresh new design will appear. When you have created all the designs you want, you can save or print them. To save a design, type COMMAND SHIFT 3. This saves the screen. In order to print a design, make sure the printer is on, then type COMMAND SHIFT 4. This will print the active window. Stopping or listing the program follows the normal MS Basic conventions.

How Random MacArt Works

The program is simple to understand. We will begin with the first line and go through the program. RANDOMIZE TIMER bases random numbers according to the time on the Macintosh's internal clock. If you were to use this program again at exactly the same time that you had used it on a previous day, so that the clock reading was the same, the same design would be created. You will most likely never get the same design twice.

DIM shows the highest number of elements in the array specified in the statement. In this program it is set to 10 for both x and y. The DIM statement is really not necessary here because a maximum value of 10 is always assumed for an otherwise unspecified subscript, but it is good practice to routinely use DIM statements.

In order for designs to be created one after another without having to rerun the program each time, a loop is used. When the computer gets to the last line of the program, the statement GOTO loop instructs it to return to the line with the statement "loop".

The WINDOW statement opens a window on the screen within which the design will be drawn. The window-ID, one in this case, specifies the window's identification number. The commas show that there is no title for this window. (If there had been, it would have been in quotes between the two commas.) The numbers in parentheses specify the window size. The x values for this window are 10 and 502, and the y values are 26 and 332. Following the comma, the number three indicates that the type of window desired is an one-line border window.

Following the WINDOW statement is a FOR/NEXT loop that is used in determining ten random values of x and y, labeled as x(n) and y(n). The statements in the loop are executed with n increasing by one each cycle. RND(1) returns a random number in the range of 0 to 1. For x, the random number is multiplied by 440, and for y, by 254. INT converts the numbers into integers, and then two is added to each. These latter steps insure that the design is drawn within the window's border. NEXT n forms the loop. After ten iterations the loop is exited.

Next, nested FOR/NEXT loops are used to create the design based on the array of random x(n), y(n) values generated previously.

The LINE statement draws a straignt line between the coordinates pairs (x(n-1)+s*4), (y(n-1)+s*4) and (x(n)+s*4), (y(n)+s*4). For example, with n=0 and s=0 the statement becomes LINE (x(1),y(1))-(x(2),y(2)). NEXT n forms a loop so that the successive points will be connected. The LINE statement following NEXT n connects the last point with n=10 back to the first point with n=1.

Without the FOR/NEXT loop on s, the design would look flat and simple. On every pass through the s-loop an identical design is created with (x,y) points displaced four pixels away from the previous design. By the time the loop is completed the result consists of 13 superimposed designs.

The WHILE/WEND loop allows the user to view the design until the mouse button is depressed. MOUSE(0) is the state of the mouse button, with MOUSE(0)=0 indicating that the button has not been clicked and MOUSE(0)=-1 indicating that it has been. When the user clicks the mouse the WHILE statement will end with the WEND. (WEND means WHILE end). The colon allows two separate statements to be entered on one line. The CLS line clears the screen and the last line returns to "loop" to start a new design.

Possible Modifications To Improve Random MacArt

When you have tried the program and printed out some intricate designs, the next step is to experiment. If you would like your designs to have more sides to make them appear even more complex, or smaller to make them appear simpler, the number of random numbers to be chosen can be changed. Remember that if you increase the number of random numbers to be used, the DIM statement must also be increased. If you would prefer a larger or smaller screen, the window size numbers in the parentheses can be altered. Three other types of windows can be obtained by changing the number three after the parentheses to one, two, or four. Try altering the numbers which are multiplied and added to the random numbers. This will position your designs in different parts of the screen and make your designs larger or smaller. The distance between each line of your designs can be altered by changing the value the variable s is multiplied by. To create more or less lines, change the value of the variable s. As you can see the possiblities of this program are endless! Have a good time and experiment freely to make the most interesting designs possible. Try running this under the new compiler and see if you can notice any speed improvements.


RANDOMIZE TIMER
DIM x(10),y(10)

loop:
WINDOW 1,,(10,26)-(502,332),3
FOR n=1 TO 10
    x(n)=INT(RND(1)*440)+2
    y(n)=INT(RND(1)*254)+2
NEXT n

FOR s=0 TO 12
    FOR n=2 TO 10
        LINE (x(n-1)+s*4,y(n-1)+s*4)-(x(n)+s*4,y(n)+s*4)
    NEXT n
    LINE (x(10)+s*4,y(10)+s*4)-(x(1)+s*4,y(1)+s*4)
NEXT s

WHILE MOUSE(0)=0:WEND
CLS
GOTO loop
 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Tokkun Studio unveils alpha trailer for...
We are back on the MMORPG news train, and this time it comes from the sort of international developers Tokkun Studio. They are based in France and Japan, so it counts. Anyway, semantics aside, they have released an alpha trailer for the upcoming... | Read more »
Win a host of exclusive in-game Honor of...
To celebrate its latest Jujutsu Kaisen crossover event, Honor of Kings is offering a bounty of login and achievement rewards kicking off the holiday season early. [Read more] | Read more »
Miraibo GO comes out swinging hard as it...
Having just launched what feels like yesterday, Dreamcube Studio is wasting no time adding events to their open-world survival Miraibo GO. Abyssal Souls arrives relatively in time for the spooky season and brings with it horrifying new partners to... | Read more »
Ditch the heavy binders and high price t...
As fun as the real-world equivalent and the very old Game Boy version are, the Pokemon Trading Card games have historically been received poorly on mobile. It is a very strange and confusing trend, but one that The Pokemon Company is determined to... | Read more »
Peace amongst mobile gamers is now shatt...
Some of the crazy folk tales from gaming have undoubtedly come from the EVE universe. Stories of spying, betrayal, and epic battles have entered history, and now the franchise expands as CCP Games launches EVE Galaxy Conquest, a free-to-play 4x... | Read more »
Lord of Nazarick, the turn-based RPG bas...
Crunchyroll and A PLUS JAPAN have just confirmed that Lord of Nazarick, their turn-based RPG based on the popular OVERLORD anime, is now available for iOS and Android. Starting today at 2PM CET, fans can download the game from Google Play and the... | Read more »
Digital Extremes' recent Devstream...
If you are anything like me you are impatiently waiting for Warframe: 1999 whilst simultaneously cursing the fact Excalibur Prime is permanently Vault locked. To keep us fed during our wait, Digital Extremes hosted a Double Devstream to dish out a... | Read more »
The Frozen Canvas adds a splash of colou...
It is time to grab your gloves and layer up, as Torchlight: Infinite is diving into the frozen tundra in its sixth season. The Frozen Canvas is a colourful new update that brings a stylish flair to the Netherrealm and puts creativity in the... | Read more »
Back When AOL WAS the Internet – The Tou...
In Episode 606 of The TouchArcade Show we kick things off talking about my plans for this weekend, which has resulted in this week’s show being a bit shorter than normal. We also go over some more updates on our Patreon situation, which has been... | Read more »
Creative Assembly's latest mobile p...
The Total War series has been slowly trickling onto mobile, which is a fantastic thing because most, if not all, of them are incredibly great fun. Creative Assembly's latest to get the Feral Interactive treatment into portable form is Total War:... | Read more »

Price Scanner via MacPrices.net

Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more

Jobs Board

Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.