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

Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »
Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links below... | Read more »
Marvel Future Fight celebrates nine year...
Announced alongside an advertising image I can only assume was aimed squarely at myself with the prominent Deadpool and Odin featured on it, Netmarble has revealed their celebrations for the 9th anniversary of Marvel Future Fight. The Countdown... | Read more »
HoYoFair 2024 prepares to showcase over...
To say Genshin Impact took the world by storm when it was released would be an understatement. However, I think the most surprising part of the launch was just how much further it went than gaming. There have been concerts, art shows, massive... | Read more »
Explore some of BBCs' most iconic s...
Despite your personal opinion on the BBC at a managerial level, it is undeniable that it has overseen some fantastic British shows in the past, and now thanks to a partnership with Roblox, players will be able to interact with some of these... | Read more »
Play Together teams up with Sanrio to br...
I was quite surprised to learn that the massive social network game Play Together had never collaborated with the globally popular Sanrio IP, it seems like the perfect team. Well, this glaring omission has now been rectified, as that instantly... | Read more »
Dark and Darker Mobile gets a new teaser...
Bluehole Studio and KRAFTON have released a new teaser trailer for their upcoming loot extravaganza Dark and Darker Mobile. Alongside this look into the underside of treasure hunting, we have received a few pieces of information about gameplay... | Read more »

Price Scanner via MacPrices.net

Amazon is offering a $200 discount on 14-inch...
Amazon has 14-inch M3 MacBook Pros in stock and on sale for $200 off MSRP. Shipping is free. Note that Amazon’s stock tends to come and go: – 14″ M3 MacBook Pro (8GB RAM/512GB SSD): $1399.99, $200... Read more
Sunday Sale: 13-inch M3 MacBook Air for $999,...
Several Apple retailers have the new 13″ MacBook Air with an M3 CPU in stock and on sale today for only $999 in Midnight. These are the lowest prices currently available for new 13″ M3 MacBook Airs... Read more
Multiple Apple retailers are offering 13-inch...
Several Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices... Read more
Roundup of Verizon’s April Apple iPhone Promo...
Verizon is offering a number of iPhone deals for the month of April. Switch, and open a new of service, and you can qualify for a free iPhone 15 or heavy monthly discounts on other models: – 128GB... Read more
B&H has 16-inch MacBook Pros on sale for...
Apple 16″ MacBook Pros with M3 Pro and M3 Max CPUs are in stock and on sale today for $200-$300 off MSRP at B&H Photo. Their prices are among the lowest currently available for these models. B... Read more
Updated Mac Desktop Price Trackers
Our Apple award-winning Mac desktop price trackers are the best place to look for the lowest prices and latest sales on all the latest computers. Scan our price trackers for the latest information on... Read more
9th-generation iPads on sale for $80 off MSRP...
Best Buy has Apple’s 9th generation 10.2″ WiFi iPads on sale for $80 off MSRP on their online store for a limited time. Prices start at only $249. Sale prices for online orders only, in-store prices... Read more
15-inch M3 MacBook Airs on sale for $100 off...
Best Buy has Apple 15″ MacBook Airs with M3 CPUs on sale for $100 off MSRP on their online store. Prices valid for online orders only, in-store prices may vary. Order online and choose free shipping... Read more
24-inch M3 iMacs now on sale for $150 off MSR...
Amazon is now offering a $150 discount on Apple’s new M3-powered 24″ iMacs. Prices start at $1149 for models with 8GB of RAM and 256GB of storage: – 24″ M3 iMac/8-core GPU/8GB/256GB: $1149.99, $150... Read more
15-inch M3 MacBook Airs now on sale for $150...
Amazon is now offering a $150 discount on Apple’s new M3-powered 15″ MacBook Airs. Prices start at $1149 for models with 8GB of RAM and 256GB of storage: – 15″ M3 MacBook Air/8GB/256GB: $1149.99, $... Read more

Jobs Board

Early Preschool Teacher - Glenda Drive/ *Appl...
Early Preschool Teacher - Glenda Drive/ Apple ValleyTeacher Share by Email Share on LinkedIn Share on Twitter Read more
Retail Assistant Manager- *Apple* Blossom Ma...
Retail Assistant Manager- APPLE BLOSSOM MALL Brand: Bath & Body Works Location: Winchester, VA, US Location Type: On-site Job ID: 04225 Job Area: Store: Management Read more
Housekeeper, *Apple* Valley Village - Cassi...
Apple Valley Village Health Care Center, a senior care campus, is hiring a Part-Time Housekeeper to join our team! We will train you for this position! In this role, Read more
Sonographer - *Apple* Hill Imaging Center -...
Sonographer - Apple Hill Imaging Center - Evenings Location: York Hospital, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now See Read more
Senior Software Engineer - *Apple* Fundamen...
…center of Microsoft's efforts to empower our users to do more. The Apple Fundamentals team focused on defining and improving the end-to-end developer experience in Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.