It is currently Tue May 23, 2017 9:40 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: Photo Mondrian
Unread postPosted: Mon Apr 24, 2017 5:44 pm 

Joined: Sat Jul 04, 2015 7:28 am
Posts: 40
Way back in high school in the 80s, we used to make a program that would create a random rectangle and then flip all of the white pixels to black and all of the black pixels to white. The rectangles would then start to overlap.

Here is a version that uses photos to flip pixels to negative values and back to the original values.


Fn.Def Extension (FileName$, Type$)
Correct = 1
Extension$ = Upper$ (Right$ (FileName$, 3))
If Extension$ <> "JPG" & Extension$ <> "PNG" & Type$ = "Graphics" Then Correct = 0
If Extension$ <> "TXT" & Type$ = "Text" Then Correct = 0
If Extension$ <> "BIN" & Type$ = "Binary" Then Correct = 0
Fn.Rtn Correct

Fn.Def PickFile$(Type$)
flag = 0
file.dir "", Existing$[]
Array.length filecount, Existing$[]
list.create s, allfiles
for count = 1 to filecount
if Extension(Existing$[count], Type$) = 1 then list.add allfiles, Existing$[count]
list.size allfiles, filecount
list.toarray allfiles, FilesofType$[]
Filesoftype$[1] = ">" + Filesoftype$[1]
FileSelect = GW_NEW_PAGE()
Message$ = "Select a " + Type$ + " File:"
myselbx = GW_ADD_SELECTBOX(FileSelect, Message$ ,FilesofType$[])
GW_ADD_LISTENER (FileSelect, myselbx, "Submit", "Submit")
inpaxn3 = GW_ADD_SUBMIT (FileSelect, "Select")
GW_RENDER (FileSelect)
if is_in (GW_ID$(inpaxn3), r$) then
File = GW_GET_VALUE(myselbx)
If File < 1 then File = 1
File$ = FilesofType$[File]
GW_CLOSE_PAGE (FileSelect)
Fn.Rtn File$

File$ = PickFile$("Graphics")
gr.bitmap.load source, File$
gr.bitmap.size source, wide, high
gr.screen scwide, schigh

gr.screen scwide, schigh %resize the bitmap to fit the screen if necessary
ratio1 = 1
ratio2 = 1
if wide > scwide then ratio1 = scwide / wide
if high > schigh then ratio2 = schigh / high
ratio = min(ratio1, ratio2)
If ratio < 1 then
wide = wide * ratio
high = high * ratio
gr.bitmap.scale newsize, source, wide, high
source = newsize

gr.bitmap.draw workarea, source, 0, 0
gr.screen.to_bitmap canvas

gr.bitmap.draw newarea, canvas, 0, 0

gr.bitmap.drawinto.start canvas

gr.set.stroke 2


let startx = Floor(Rnd() * (wide - 1))
let stopx = Floor(Rnd() * (wide - 1))
if stopx < startx then
temp = startx
startx = starty
starty = temp

let starty = Floor(Rnd() * (high - 1))
let stopy = Floor(Rnd() * (high - 1))
if stopy < starty then
temp = stopx
stopx = stopy
stopy = temp

for x = startx to stopx
for y = starty to stopy
gr.get.bmpixel canvas, x, y, alpha, red, green, blue
let red = 255 - red
let green = 255 - green
let blue = 255- blue
gr.color alpha, red, green, blue
gr.point dummy, x, y
if mod(y,10) = 0 then gr.render
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: