It is currently Tue May 23, 2017 9:42 am



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Color Block Mondrian
Unread postPosted: Thu May 11, 2017 6:51 am 
Offline

Joined: Sat Jul 04, 2015 7:28 am
Posts: 40
Here is a colorful version of the program.

gr.open
gr.orientation 0
do %ensure that the orientation has set to landscape before proceeding. This could take a few seconds.
gr.screen wide, high
until wide > high
gr.bitmap.create canvas, wide, high

gr.bitmap.draw workspace, canvas, 0, 0 %create a starting bitmap with a random color
red = Floor(Rnd() * 256)
green = Floor(Rnd() * 256)
blue = Floor(Rnd() * 256)
gr.color , red, green, blue
gr.bitmap.fill canvas, 10, 10
gr.bitmap.drawinto.start canvas
gr.set.stroke 2
gr.render

do %Main loop continues until the program is manually ended

let startx = Floor(Rnd() * (wide - 1)) %choose random starting and ending X positions
let stopx = Floor(Rnd() * (wide - 1))
if stopx < startx then %go from right to left
let temp = startx
let startx = stopx
let stopx = temp
Endif

let starty = Floor(Rnd() * (high - 1)) %choose random starting and ending Y positions
let stopy = Floor(Rnd() * (high - 1))
if stopy < starty then %go from top to bottom
let temp = starty
let starty = stopy
let stopy = temp
endif

scheme = 0 %flip coins determine which color values to flip
do
let flipred = Floor(rnd() * 2)
let flipgreen = Floor(rnd() * 2)
let flipblue = Floor(rnd() * 2)
let scheme = flipred + 2 * flipgreen + 4 * flipblue
until scheme > 0

for x = startx to stopx %change the actual graphics in the random block
for y = starty to stopy
gr.get.bmpixel canvas, x, y, alpha, red, green, blue %get the current values and reverse the color values based on coin flips
if flipred = 1 then let red = 255 - red
if flipgreen = 1 then let green = 255 - green
if flipblue = 1 then let blue = 255- blue
gr.color alpha, red, green, blue
gr.point dummy, x, y
if mod(y,10) = 0 then gr.render %make the program run faster by not rendering every change
next y
gr.render
next x
gr.render

until (1=0)
gr.close

End


Report this post
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred