The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Those Pretty Pretty Backgrounds

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Those Pretty Pretty Backgrounds Posted: Mar 19, 2008 1:18 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Those Pretty Pretty Backgrounds
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Travis Griggs - Blog

Advertisement

Some like 'em, some don't. I kind of do. Those "abstract art" pictures people set as their desktop backgrounds. I think I figured out how they make those today. They use something like Cairo. The throw together a code snippet like this:


window := ApplicationWindow new.

random := Random new.

vb := VisualBlock block:

		[:gc :box | 

		gc newCairoContextWhile:

				[:cr | 

				cr groupWhile:

						[cr scale: window bounds extent.

						10 timesRepeat:

								[| source |

								random next < 0.1 ifTrue:

										[source := LinearGradient from: random next @ random next to: random next @ random next.

										source addStopAt: 0

											red: random next

											green: random next

											blue: random next

											alpha: random next squared * 0.25.

										source addStopAt: 1

											red: random next

											green: random next

											blue: random next

											alpha: random next squared * 0.25.

										source extend: ExtendStyle pad]

									ifFalse:

										[source := RadialGradient from: random next @ random next

											radius: random next / 2

											to: random next @ random next

											radius: random next + random next.

										source addStopAt: 0

											red: random next

											green: random next

											blue: random next

											alpha: (random next squared min: 0.5).

										source addStopAt: 1

											red: random next

											green: random next

											blue: random next

											alpha: (random next squared ).

										source extend: ExtendStyle reflect].

								cr

									source: source;

									paint]].

				cr paint]].

window component: vb.

window openWithExtent: 1400 @ 900

Then they just sit back and refresh the window, and wait for the pretty ones to go by, save this off to disk.

Read: Those Pretty Pretty Backgrounds

Topic: IntelliJ IDEA 7.0.3 is Here Previous Topic   Next Topic Topic: Speaking of whole new worlds...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use