Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Bitmap-Flood-fill/J/bitmap-flood-fill-1.j
Normal file
10
Task/Bitmap-Flood-fill/J/bitmap-flood-fill-1.j
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
NB. finds and labels contiguous areas with the same numbers
|
||||
NB. ref: http://www.jsoftware.com/pipermail/general/2005-August/023886.html
|
||||
findcontig=: (|."1@|:@:>. (* * 1&(|.!.0)))^:4^:_@(* >:@i.@$)
|
||||
|
||||
NB.*getFloodpoints v Returns points to fill given starting point (x) and image (y)
|
||||
getFloodpoints=: [: 4&$.@$. [ (] = getPixels) [: findcontig ] -:"1 getPixels
|
||||
|
||||
NB.*floodFill v Floods area, defined by point and color (x), of image (y)
|
||||
NB. x is: 2-item list of (y x) ; (color)
|
||||
floodFill=: (1&({::)@[ ;~ 0&({::)@[ getFloodpoints ]) setPixels ]
|
||||
9
Task/Bitmap-Flood-fill/J/bitmap-flood-fill-2.j
Normal file
9
Task/Bitmap-Flood-fill/J/bitmap-flood-fill-2.j
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
'white blue yellow black orange red'=: 255 255 255,0 0 255,255 255 0,0 0 0,255 165 0,:255 0 0
|
||||
myimg=: white makeRGB 50 70
|
||||
lines=: _2]\^:2 ] 0 0 25 0 , 25 0 25 35 , 25 35 0 35 , 0 35 0 0
|
||||
myimg=: (lines;blue) drawLines myimg
|
||||
myimg=: (3 3; yellow) floodFill myimg
|
||||
myimg=: ((25 35 24 ,: 25 35 10);black) drawCircles myimg
|
||||
myimg=: (5 34;orange) floodFill myimg
|
||||
myimg=: (5 36;red) floodFill myimg
|
||||
viewRGB myimg
|
||||
7
Task/Bitmap-Flood-fill/J/bitmap-flood-fill-3.j
Normal file
7
Task/Bitmap-Flood-fill/J/bitmap-flood-fill-3.j
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
NB. ref: http://www.jsoftware.com/pipermail/general/2005-August/024174.html
|
||||
eq=:[:}:"1 [:($$[:([:+/\1:,}:~:}.),) ,&_"1 NB. equal numbers for atoms of y connected in first direction
|
||||
eq_nd=: i.@#@$(<"0@[([:, |:^:_1"0 _)&> [:EQ&.> <@|:"0 _)] NB. n-dimensional eq, gives an #@$,*/@$ shaped matrix
|
||||
repl=: (i.~{.){ {:@] NB. replaces x by applying replace table y
|
||||
cnnct=: [: |:@({."1<.//.]) [: ; <@(,.<./)/.~
|
||||
|
||||
findcontig_nd=: 3 : '($y)${. ([:({.,~}:) ([ repl cnnct)/\.)^:([:+./@(~:/)2&{.)^:_ (,{.) eq_nd (i.~ ~.@,) y'
|
||||
Loading…
Add table
Add a link
Reference in a new issue