NetLogo version NetLogo 4.0.4
Running with NetLogoLite.jar version 404.
NetLogo Version: NetLogo 4.0.4
__includes [ "floss-colors.nls" "color-reduction.nls" "rgb-utilities.nls" "floss-drawing.nls" ] globals [ flosses-in-use original-colors some-line sampler-visible? ;; is the sampler icon in a visible state? ] breed [ stitches a_stitch ] breed [ lines line ] breed [ samplers sampler ] patches-own [ ;; the input color for this stitch my-pixel ;; the pixel object that matches the input-color input-color ] to startup setup end to setup ca cp-rgb floss-setup sampler-setup set-default-shape stitches "x-stitch" draw-grid end to load-map [ #filename ] cp-rgb clear-stitches clear-pixels if #filename = "" [ set #filename user-file ] if is-string? #filename [ import-pcolors-rgb #filename ask patches [ set input-color pcolor ] ] setup-pixels update-floss-colors display clear-output output-print (word "There are " count pixels " colors in this image.") output-print (word "The imported image requires " count unique-floss-in-use " floss colors." ) output-print "ASD color reduction is disabled." floss-used-report end to find-floss update-floss-colors floss-used-report end to clear-stitches ask stitches [ set pcolor [ color] of [my-floss] of my-pixel die ] end to show-stitches ask patches [ let #color [ color ] of [my-floss] of my-pixel if not any? stitches-here [ sprout-stitches 1 [ ] ] ask stitches-here [ set shape "x-stitch" set color #color ; fput 127 #color __set-line-thickness thread-thickness ] set pcolor white ] end to cp-rgb cp ask patches [ set pcolor [ 255 255 255 ] set input-color pcolor ] end ;; to-report stitch-counts ;; report map ;; [ ;; [ (word "#" code ":" label ": " count patches with [ stitch-floss = myself ] "\n") ;; ] of ? ;; ] ;; sort (turtle-set [ stitch-floss] of patches) ;; end to-report count-unique-colors let map-cols 0; length remove-duplicates [ map-pcolor ] of patches let floss-cols 0 ; length remove-duplicates [ floss-color ] of patches let input-cols 0 ; length remove-duplicates [ input-color ] of patches report (word "i: " input-cols " f: " floss-cols " m: " map-cols ) end to-report flosses-used report flosses-in-use ;; (turtle-set [ stitch-floss ] of patches ) end to show-variance ask patches [ let i [ color ] of my-pixel let f [ color ] of [my-floss] of my-pixel let var (map [128 + .5 * (?1 - ?2)] f i ) set pcolor var ] end to execute-color-reduction reduce-colors number-of-colors ask patches [ set pcolor [ map-color ] of my-pixel ] end to draw-grid ask patches with [ pxcor != 0 and pycor = floor (world-height / 2) ] [ sprout-lines 1 [ set shape "line-vert" set size world-height set color black set heading 0 set xcor xcor - .4] ] ask patches with [ pycor != 0 and pxcor = floor (world-width / 2) ] [ sprout-lines 1 [ set shape "line-hori" set size world-width set color black set heading 0 set ycor ycor - .4 ] ] set some-line one-of lines end to-report update-grid-color let new-color item grid-color [ black white 5 15 25 35 45 55 65 75 85 95 105 115 125 135 ] if [ color ] of some-line != new-color [ ask lines [ set color new-color ] display ] monitor-mouse report "" end to monitor-mouse ifelse mouse-inside? [ ask samplers [ setxy floor mouse-xcor floor mouse-ycor set color pcolor set label [ label ] of patch-floss set label-color white - label-color show-turtle display ] set sampler-visible? true ] [ if sampler-visible? = true [ set sampler-visible? false ask samplers [ hide-turtle display ] ] ] end to grid-toggle ask lines [ set hidden? not hidden? ] end to increase-contrast let mnp min [ brightness ] of patches let mxp max [ brightness ] of patches let spanp mxp - mnp let scalep 255 / spanp if scalep < 1.0 [ ask patches [ set pcolor adjust-contrast pcolor mnp scalep ] ] end to-report brightness report mean pcolor end to-report adjust-contrast [ #rgb #min #scale ] report map [ (? - #min) * #scale ] #rgb end to export-image let #filename user-new-file if is-string? #filename [ export-view #filename ] end to sampler-setup create-samplers 1 [ set shape "sample" set size 10 setxy 0 0 set hidden? true ] end
View or download the complete model file (to download: right-click, save-link-as):
-- Download x-stitch-pattern-converter_1 --