-
Notifications
You must be signed in to change notification settings - Fork 138
/icon.Blend() parity and tests
#2591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
6e5984b
getpixel
amylizzle 30ae0c9
more comprehensive test
amylizzle 950e7a6
test that crashes byond lmao
amylizzle 8731acb
fixes
amylizzle 2f4e407
steal the return from #2524
amylizzle 91bab16
Merge branch 'master' into getpixel
amylizzle 2feffe1
add // NOBYOND to test
amylizzle 56dc0ee
Merge branch 'master' into getpixel
amylizzle b783e34
comments
amylizzle 21705db
othercomment
amylizzle 5bf8965
test
amylizzle ba7d561
slightly better reporting
amylizzle 12c1235
Merge remote-tracking branch 'upstream/master' into iconops
amylizzle 1ebcd6a
Merge branch 'master' into iconops
amylizzle 48d1018
Merge remote-tracking branch 'upstream/master' into iconops
amylizzle 67a69a3
mmm parity
amylizzle ece0db5
oh this too
amylizzle 12718a7
reduce copy paste
amylizzle 674bb57
Apply suggestions from code review
amylizzle 106f698
reduce it some more
amylizzle cbec4ce
Merge branch 'iconops' of https://github.com/amylizzle/OpenDream into…
amylizzle 6769ebe
how did OD testing not catch this
amylizzle 5485775
whoops
amylizzle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /proc/RunTest() | ||
| // ICON_ADD | ||
| var/icon/A = icon('hanoi.dmi',"reddot") | ||
| var/icon/B = icon('hanoi.dmi',"bluedot") | ||
| A.Blend(B, ICON_ADD) | ||
| var/list/target_pixels = list(null,null,null,null,null,null,null,null,null,null,"#ff19ff","#ff19ff","#ff19ff","#ff19ff",null,null,null,null,"#ff19ff","#ff19ff","#ff19ff","#ff19ff",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"#ff19ff","#ff19ff","#ff19ff","#ff19ff",null,null,null,null,"#ff19ff","#ff19ff","#ff19ff","#ff19ff",null,null,null,null,null,null,null,null,null,null) | ||
| var/list/actual_pixels = list() | ||
| var/matching = TRUE | ||
| for(var/x in 1 to 32) | ||
| matching &= (A.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += A.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_ADD did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") | ||
|
|
||
| // ICON_SUBTRACT | ||
| A = icon('hanoi.dmi',"reddot") | ||
| B = icon('hanoi.dmi',"bluedot") | ||
| A.Blend(B, ICON_SUBTRACT) | ||
| target_pixels = list(null,null,null,null,null,null,null,null,null,null,"#741900","#741900","#741900","#741900",null,null,null,null,"#ff1900","#ff1900","#ff1900","#ff1900",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"#741900","#741900","#741900","#741900",null,null,null,null,"#ff1900","#ff1900","#ff1900","#ff1900",null,null,null,null,null,null,null,null,null,null) | ||
| actual_pixels = list() | ||
| matching = TRUE | ||
| for(var/x in 1 to 32) | ||
| matching &= (A.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += A.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_SUBTRACT did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") | ||
|
|
||
| // ICON_MULTIPLY | ||
| A = icon('hanoi.dmi',"reddot") | ||
| B = icon('hanoi.dmi',"bluedot") | ||
| A.Blend(B, ICON_MULTIPLY) | ||
| target_pixels = list(null,null,null,null,null,null,null,null,null,null,"#8b0035","#8b0035","#8b0035","#8b0035",null,null,null,null,"#000035","#000035","#000035","#000035",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"#8b0035","#8b0035","#8b0035","#8b0035",null,null,null,null,"#000035","#000035","#000035","#000035",null,null,null,null,null,null,null,null,null,null) | ||
| actual_pixels = list() | ||
| matching = TRUE | ||
| for(var/x in 1 to 32) | ||
| matching &= (A.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += A.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_MULTIPLY did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") | ||
|
|
||
| // ICON_OVERLAY | ||
| A = icon('hanoi.dmi',"reddot") | ||
| B = icon('hanoi.dmi',"bluedot") | ||
| A.Blend(B, ICON_OVERLAY) | ||
| target_pixels = list(null,null,null,"#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#ff1935","#ff1935","#ff1935","#ff1935","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff",null,null,null) | ||
| actual_pixels = list() | ||
| for(var/x in 1 to 32) | ||
| matching &= (A.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += A.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_OVERLAY did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") | ||
|
|
||
| // ICON_AND | ||
| A = icon('hanoi.dmi',"reddot") | ||
| B = icon('hanoi.dmi',"bluedot") | ||
| A.Blend(B, ICON_AND) | ||
| target_pixels = list(null,null,null,null,null,null,null,null,null,null,"#ff19ff","#ff19ff","#ff19ff","#ff19ff",null,null,null,null,"#ff19ff","#ff19ff","#ff19ff","#ff19ff",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"#ff19ff","#ff19ff","#ff19ff","#ff19ff",null,null,null,null,"#ff19ff","#ff19ff","#ff19ff","#ff19ff",null,null,null,null,null,null,null,null,null,null) | ||
| actual_pixels = list() | ||
| matching = TRUE | ||
| for(var/x in 1 to 32) | ||
| matching &= (A.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += A.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_AND did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") | ||
|
|
||
| // ICON_OR | ||
| A = icon('hanoi.dmi',"reddot") | ||
| B = icon('hanoi.dmi',"bluedot") | ||
| A.Blend(B, ICON_OR) | ||
| target_pixels = list(null,null,null,"#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#ff19ff","#ff19ff","#ff19ff","#ff19ff","#ff1935","#ff1935","#ff1935","#ff1935","#ff19ff","#ff19ff","#ff19ff","#ff19ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff",null,null,null,null,null,null,"#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#ff19ff","#ff19ff","#ff19ff","#ff19ff","#ff1935","#ff1935","#ff1935","#ff1935","#ff19ff","#ff19ff","#ff19ff","#ff19ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff",null,null,null) | ||
| actual_pixels = list() | ||
| matching = TRUE | ||
| for(var/x in 1 to 32) | ||
| matching &= (A.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += A.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_OR did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") | ||
|
|
||
| // ICON_UNDERLAY | ||
| A = icon('hanoi.dmi',"reddot") | ||
| B = icon('hanoi.dmi',"bluedot") | ||
| A.Blend(B, ICON_UNDERLAY) | ||
| target_pixels = list(null,null,null,"#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff",null,null,null,null,null,null,"#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#8b00ff","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#ff1935","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff","#0000ff",null,null,null) | ||
| actual_pixels = list() | ||
| matching = TRUE | ||
| for(var/x in 1 to 32) | ||
| matching &= (A.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += A.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_UNDERLAY did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /proc/RunTest() | ||
| // ICON_ADD | ||
| var/icon/B = icon('hanoi.dmi',"gradient") | ||
| B.Blend(rgb(200, 10, 0, 170), ICON_ADD) | ||
| var/list/target_pixels = list("#c80affaa","#c80affaa","#c80affa9","#c80aff9f","#c80aff95","#c80aff8c","#c80aff83","#c80aff7b","#c80aff73","#c80aff6c","#c80aff65","#c80aff5f","#c80aff58","#c80aff52","#c80aff4d","#c80aff47","#c80aff42","#c80aff3d","#c80aff39","#c80aff34","#c80aff30","#c80aff2c","#c80aff28","#c80aff25","#c80aff21","#c80aff1f","#c80aff1b","#c80aff19","#c80aff16","#c80aff14","#c80aff11","#c80aff0f") | ||
| var/list/actual_pixels = list() | ||
| var/matching = TRUE | ||
| for(var/x in 1 to 32) | ||
| matching &= (B.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += B.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_ADD did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") | ||
|
|
||
| // ICON_SUBTRACT | ||
| B = icon('hanoi.dmi',"gradient") | ||
| B.Blend(rgb(200,10,0,170), ICON_SUBTRACT) | ||
| target_pixels = list("#0000ffaa","#0000ffaa","#0000ffa9","#0000ff9f","#0000ff95","#0000ff8c","#0000ff83","#0000ff7b","#0000ff73","#0000ff6c","#0000ff65","#0000ff5f","#0000ff58","#0000ff52","#0000ff4d","#0000ff47","#0000ff42","#0000ff3d","#0000ff39","#0000ff34","#0000ff30","#0000ff2c","#0000ff28","#0000ff25","#0000ff21","#0000ff1f","#0000ff1b","#0000ff19","#0000ff16","#0000ff14","#0000ff11","#0000ff0f") | ||
| actual_pixels = list() | ||
| matching = TRUE | ||
| for(var/x in 1 to 32) | ||
| matching &= (B.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += B.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_SUBTRACT did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") | ||
|
|
||
| // ICON_MULTIPLY | ||
| B = icon('hanoi.dmi',"gradient") | ||
| B.Blend(rgb(200,10,0,170), ICON_MULTIPLY) | ||
| target_pixels = list("#000000aa","#000000aa","#000000a9","#0000009f","#00000095","#0000008c","#00000083","#0000007b","#00000073","#0000006c","#00000065","#0000005f","#00000058","#00000052","#0000004d","#00000047","#00000042","#0000003d","#00000039","#00000034","#00000030","#0000002c","#00000028","#00000025","#00000021","#0000001f","#0000001b","#00000019","#00000016","#00000014","#00000011","#0000000f") | ||
| actual_pixels = list() | ||
| matching = TRUE | ||
| for(var/x in 1 to 32) | ||
| matching &= (B.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += B.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_MULTIPLY did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") | ||
|
|
||
| // ICON_OVERLAY | ||
| B = icon('hanoi.dmi',"gradient") | ||
| B.Blend(rgb(200,10,0,170), ICON_OVERLAY) | ||
| target_pixels = list("#850755","#850755","#850755","#850755f9","#850755f5","#850755f0","#850755ec","#850755e8","#850755e4","#850755e0","#850755dc","#850755d9","#850755d6","#850755d3","#850755d0","#850755cd","#850755cb","#850755c9","#850755c6","#850755c4","#850755c2","#850755c0","#850755be","#850755bc","#850755bb","#850755b9","#850755b8","#850755b6","#850755b5","#850755b4","#850755b3","#850755b2") | ||
| actual_pixels = list() | ||
| for(var/x in 1 to 32) | ||
| matching &= (B.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += B.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_OVERLAY did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") | ||
|
|
||
| // ICON_AND | ||
| B = icon('hanoi.dmi',"gradient") | ||
| B.Blend(rgb(200,10,0,170), ICON_AND) | ||
| target_pixels = list("#c80affaa","#c80affaa","#c80affa9","#c80aff9f","#c80aff95","#c80aff8c","#c80aff83","#c80aff7b","#c80aff73","#c80aff6c","#c80aff65","#c80aff5f","#c80aff58","#c80aff52","#c80aff4d","#c80aff47","#c80aff42","#c80aff3d","#c80aff39","#c80aff34","#c80aff30","#c80aff2c","#c80aff28","#c80aff25","#c80aff21","#c80aff1f","#c80aff1b","#c80aff19","#c80aff16","#c80aff14","#c80aff11","#c80aff0f") | ||
| actual_pixels = list() | ||
| matching = TRUE | ||
| for(var/x in 1 to 32) | ||
| matching &= (B.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += B.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_AND did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") | ||
|
|
||
| // ICON_OR | ||
| B = icon('hanoi.dmi',"gradient") | ||
| B.Blend(rgb(200,10,0,170), ICON_OR) | ||
| target_pixels = list("#c80aff","#c80aff","#c80aff","#c80afff9","#c80afff5","#c80afff0","#c80affec","#c80affe8","#c80affe4","#c80affe0","#c80affdc","#c80affd9","#c80affd6","#c80affd3","#c80affd0","#c80affcd","#c80affcb","#c80affc9","#c80affc6","#c80affc4","#c80affc2","#c80affc0","#c80affbe","#c80affbc","#c80affbb","#c80affb9","#c80affb8","#c80affb6","#c80affb5","#c80affb4","#c80affb3","#c80affb2") | ||
| actual_pixels = list() | ||
| matching = TRUE | ||
| for(var/x in 1 to 32) | ||
| matching &= (B.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += B.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_OR did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") | ||
|
|
||
| // ICON_UNDERLAY | ||
| B = icon('hanoi.dmi',"gradient") | ||
| B.Blend(rgb(200,10,0,170), ICON_UNDERLAY) | ||
| target_pixels = list("#0000ff","#0000ff","#0100fe","#0d01eef9","#1801e0f5","#2302d2f0","#2d02c5ec","#3703b9e8","#4003ade4","#4904a2e0","#520497dc","#59048ed9","#600584d6","#68057bd3","#6e0573d0","#75066acd","#7a0663cb","#80065cc9","#850755c6","#8b074ec4","#900748c2","#940742c0","#99083cbe","#9d0837bc","#a10832bb","#a4082eb9","#a80829b8","#ab0925b6","#ae0921b5","#b0091eb4","#b4091ab3","#b60917b2") | ||
| actual_pixels = list() | ||
| matching = TRUE | ||
| for(var/x in 1 to 32) | ||
| matching &= (B.GetPixel(x,x) == target_pixels[x]) | ||
| actual_pixels += B.GetPixel(x,x) | ||
| if(!matching) | ||
| CRASH("ICON_UNDERLAY did not match, expected [json_encode(target_pixels)] but got [json_encode(actual_pixels)]") |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.