Munching squares: Difference between revisions
Content added Content deleted
(→{{header|C sharp}}: Added image.) |
(→{{header|PHP}}: Added PureBasic) |
||
Line 239: | Line 239: | ||
[[File:xor_pattern_php.png|PHP output|200px]] |
[[File:xor_pattern_php.png|PHP output|200px]] |
||
=={{header|PureBasic}}== |
|||
[[File:PureBasic_XOR_Pattern.png|thumb|Sample display of PureBasic solution]] |
|||
<lang purebasic>#palletteSize = 128 |
|||
Procedure.f XorPattern(x, y) ;compute the gradient value from the pixel values |
|||
Protected result = x ! y |
|||
ProcedureReturn Mod(result, #palletteSize) / #palletteSize |
|||
EndProcedure |
|||
Procedure drawPattern() |
|||
StartDrawing(ImageOutput(0)) |
|||
DrawingMode(#PB_2DDrawing_Gradient) |
|||
CustomGradient(@XorPattern()) |
|||
;specify a gradient pallette from which only specific indexes will be used |
|||
For i = 1 To #palletteSize |
|||
GradientColor(1 / i, i * $BACE9B) ; or alternatively use $BEEFDEAD |
|||
Next |
|||
Box(0, 0, ImageWidth(0), ImageHeight(0)) |
|||
StopDrawing() |
|||
EndProcedure |
|||
If OpenWindow(0, 0, 0, 128, 128, "XOR Pattern", #PB_Window_SystemMenu) |
|||
CreateImage(0, WindowWidth(0), WindowHeight(0)) |
|||
drawPattern() |
|||
ImageGadget(0, 0, 0, ImageWidth(0), ImageHeight(0), ImageID(0)) |
|||
Repeat |
|||
event = WaitWindowEvent(20) |
|||
Until event = #PB_Event_CloseWindow |
|||
EndIf</lang> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |