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

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... | Read more »
Price of Glory unleashes its 1.4 Alpha u...
As much as we all probably dislike Maths as a subject, we do have to hand it to geometry for giving us the good old Hexgrid, home of some of the best strategy games. One such example, Price of Glory, has dropped its 1.4 Alpha update, stocked full... | Read more »
The SLC 2025 kicks off this month to cro...
Ever since the Solo Leveling: Arise Championship 2025 was announced, I have been looking forward to it. The promotional clip they released a month or two back showed crowds going absolutely nuts for the previous competitions, so imagine the... | Read more »
Dive into some early Magicpunk fun as Cr...
Excellent news for fans of steampunk and magic; the Precursor Test for Magicpunk MMORPG Crystal of Atlan opens today. This rather fancy way of saying beta test will remain open until March 5th and is available for PC - boo - and Android devices -... | Read more »
Prepare to get your mind melted as Evang...
If you are a fan of sci-fi shooters and incredibly weird, mind-bending anime series, then you are in for a treat, as Goddess of Victory: Nikke is gearing up for its second collaboration with Evangelion. We were also treated to an upcoming... | Read more »
Square Enix gives with one hand and slap...
We have something of a mixed bag coming over from Square Enix HQ today. Two of their mobile games are revelling in life with new events keeping them alive, whilst another has been thrown onto the ever-growing discard pile Square is building. I... | Read more »
Let the world burn as you have some fest...
It is time to leave the world burning once again as you take a much-needed break from that whole “hero” lark and enjoy some celebrations in Genshin Impact. Version 5.4, Moonlight Amidst Dreams, will see you in Inazuma to attend the Mikawa Flower... | Read more »
Full Moon Over the Abyssal Sea lands on...
Aether Gazer has announced its latest major update, and it is one of the loveliest event names I have ever heard. Full Moon Over the Abyssal Sea is an amazing name, and it comes loaded with two side stories, a new S-grade Modifier, and some fancy... | Read more »
Open your own eatery for all the forest...
Very important question; when you read the title Zoo Restaurant, do you also immediately think of running a restaurant in which you cook Zoo animals as the course? I will just assume yes. Anyway, come June 23rd we will all be able to start up our... | Read more »
Crystal of Atlan opens registration for...
Nuverse was prominently featured in the last month for all the wrong reasons with the USA TikTok debacle, but now it is putting all that behind it and preparing for the Crystal of Atlan beta test. Taking place between February 18th and March 5th,... | Read more »

Price Scanner via MacPrices.net

AT&T is offering a 65% discount on the ne...
AT&T is offering the new iPhone 16e for up to 65% off their monthly finance fee with 36-months of service. No trade-in is required. Discount is applied via monthly bill credits over the 36 month... Read more
Use this code to get a free iPhone 13 at Visi...
For a limited time, use code SWEETDEAL to get a free 128GB iPhone 13 Visible, Verizon’s low-cost wireless cell service, Visible. Deal is valid when you purchase the Visible+ annual plan. Free... Read more
M4 Mac minis on sale for $50-$80 off MSRP at...
B&H Photo has M4 Mac minis in stock and on sale right now for $50 to $80 off Apple’s MSRP, each including free 1-2 day shipping to most US addresses: – M4 Mac mini (16GB/256GB): $549, $50 off... Read more
Buy an iPhone 16 at Boost Mobile and get one...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering one year of free Unlimited service with the purchase of any iPhone 16. Purchase the iPhone at standard MSRP, and then choose... Read more
Get an iPhone 15 for only $299 at Boost Mobil...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering the 128GB iPhone 15 for $299.99 including service with their Unlimited Premium plan (50GB of premium data, $60/month), or $20... Read more
Unreal Mobile is offering $100 off any new iP...
Unreal Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering a $100 discount on any new iPhone with service. This includes new iPhone 16 models as well as iPhone 15, 14, 13, and SE... Read more
Apple drops prices on clearance iPhone 14 mod...
With today’s introduction of the new iPhone 16e, Apple has discontinued the iPhone 14, 14 Pro, and SE. In response, Apple has dropped prices on unlocked, Certified Refurbished, iPhone 14 models to a... Read more
B&H has 16-inch M4 Max MacBook Pros on sa...
B&H Photo is offering a $360-$410 discount on new 16-inch MacBook Pros with M4 Max CPUs right now. B&H offers free 1-2 day shipping to most US addresses: – 16″ M4 Max MacBook Pro (36GB/1TB/... Read more
Amazon is offering a $100 discount on the M4...
Amazon has the M4 Pro Mac mini discounted $100 off MSRP right now. Shipping is free. Their price is the lowest currently available for this popular mini: – Mac mini M4 Pro (24GB/512GB): $1299, $100... Read more
B&H continues to offer $150-$220 discount...
B&H Photo has 14-inch M4 MacBook Pros on sale for $150-$220 off MSRP. B&H offers free 1-2 day shipping to most US addresses: – 14″ M4 MacBook Pro (16GB/512GB): $1449, $150 off MSRP – 14″ M4... Read more

Jobs Board

All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.