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

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 

Joined: Sat Jul 04, 2015 7:28 am
Posts: 40
Here is a colorful version of the program.
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

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

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

scheme = 0 %flip coins determine which color values to flip
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
next x

until (1=0)


Report this post
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: