Ombre

Ombre preview image

1 collaborator

Turtlezero2-white-048 James Steiner (Author)

Tags

color 

Tagged by James Steiner almost 3 years ago

colorful 

Tagged by James Steiner almost 3 years ago

demo 

Tagged by James Steiner almost 3 years ago

example 

Tagged by James Steiner almost 3 years ago

gradient 

Tagged by James Steiner almost 3 years ago

pcolor 

Tagged by James Steiner almost 3 years ago

rgb 

Tagged by James Steiner almost 3 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.1 • Viewed 166 times • Downloaded 10 times • Run 0 times
Download the 'Ombre' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [ kind ]

to-report Ombre [ a b steps sample ]
  let t sample / (steps - 1)
  if is-number? a [ set a extract-rgb a ]
  if is-number? b [ set b extract-rgb b ]
  ;; right: square-root of sum of scaled squares
  report (map [ [ aa bb ] -> sqrt(  (aa * aa * t) + (bb * bb * (1 - t) ) ) ] a b)
end 

to-report Bad-Ombre [ a b steps sample ]
  let t sample / (steps - 1)
  let argb a
  let brgb b
  ;; wrong: linear scaled values
  report (map [ [ aa bb ] -> ( (aa * t) + (bb * (1 - t) ) ) ] argb brgb)
end 

to-report Ombre2 [ a b steps sample ]
  if-else kind = "bad"
  [ report bad-ombre a b steps sample ]
  [ report ombre a b steps sample ]
end 

to setup-bad
  set kind "bad"
  setup
end 

to setup-good
  set kind "good"
  setup
end 

to setup
  clear-patches
  clear-turtles
  let t 0
  let rgbRed [255   0   0 ] ;; pure Red
  let rgbGreen [  0 255   0 ] ;; pure Green
  let rgbBlue [  0   0 255 ] ;; pure Blue
  let rgbYellow [ 255 255  0 ] ;; cyber Yellow
  ask patches
  [ let colorRight Ombre2 rgbRed rgbYellow        world-width  (pycor - min-pycor)
    let colorLeft  Ombre2 rgbBlue rgbGreen        world-width  (pycor - min-pycor)
    ;; output of these is then blended to get the final color
    let colorBottom-to-Top Ombre2 colorRight colorLeft world-height (pxcor - min-pxcor)
    set pcolor colorBottom-to-Top
  ]
  reset-ticks
end 

to magnify
  if not any? turtles [ create-turtles 1 [ set shape "circle 3" set size 10 ] ]
  ask turtles
  [ if-else mouse-inside?
    [ setxy mouse-xcor mouse-ycor ]
    [ setxy 0 0]
    set color pcolor
    set label round-rgb color
  ]
end 

to-report round-rgb [ this ]
    report (map [x -> int x ] this)
end 

to-report color-under-mouse
  if mouse-inside? [ report round-rgb [ pcolor ] of patch mouse-xcor mouse-ycor ]
  report "n/a"
end 

to go
   magnify
end 

There is only one version of this model, created about 3 years ago by James Steiner.

Attached files

File Type Description Last updated
Ombre.png preview Preview for 'Ombre' about 3 years ago, by James Steiner Download

This model does not have any ancestors.

This model does not have any descendants.