Colour pinstripe/Display: Difference between revisions

m
syntax highlighting fixup automation
(→‎{{header|Lua}}: added Lua solution)
m (syntax highlighting fixup automation)
Line 18:
{{works with|https://skilldrick.github.io/easy6502/ Easy6502}}
Output can be seen by copying and pasting this code into the code editor, then clicking "Assemble," then "Run."
<langsyntaxhighlight lang="6502asm">define color $00
define looptemp $01
 
Line 113:
bcc loop_4wide
 
brk ;program end</langsyntaxhighlight>
 
=={{header|Action!}}==
<langsyntaxhighlight Actionlang="action!">PROC Main()
BYTE
i,
Line 164:
DO UNTIL CH#$FF OD
CH=$FF
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Colour_pinstripe_display.png Screenshot from Atari 8-bit computer]
 
=={{header|ActionScript}}==
<syntaxhighlight lang="actionscript3">
<lang ActionScript3>
package {
Line 225:
 
}
</syntaxhighlight>
</lang>
 
=={{header|Ada}}==
{{libheader|SDLAda}}
<langsyntaxhighlight Adalang="ada">with SDL.Video.Windows.Makers;
with SDL.Video.Renderers.Makers;
with SDL.Video.Palettes;
Line 302:
Window.Finalize;
SDL.Finalise;
end Colour_Pinstripe_Display;</langsyntaxhighlight>
 
=={{header|ARM Assembly}}==
Line 310:
This uses the Game Boy Advance's bitmap screen modes; no pre-defined tilemaps are needed.
 
<langsyntaxhighlight ARMlang="arm Assemblyassembly"> .org 0x08000000 ;cartridge ROM begins here
 
b ProgramStart ;branch around the cartridge header
Line 399:
.word 0b0111111111100000 ;cyan
.word 0b0000001111111111 ;yellow
.word 0x7FFF ;white</langsyntaxhighlight>
 
{{out}}
Line 410:
Requires the GDI+ standard library: http://www.autohotkey.com/forum/viewtopic.php?t=32238<br/>
It is worth noting that this fills the whole screen; press Esc to exit.
<langsyntaxhighlight AHKlang="ahk">h := A_ScreenHeight
w := A_ScreenWidth
pToken := gdip_Startup()
Line 452:
Exit:
Gdip_Shutdown(pToken)
ExitApp</langsyntaxhighlight>
 
=={{header|BASIC256}}==
{{trans|Yabasic}}
<langsyntaxhighlight BASIC256lang="basic256">w = 640 : h = 480
graphsize w, h
 
Line 471:
col += 1
next x
next i</langsyntaxhighlight>
 
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<langsyntaxhighlight lang="bbcbasic"> SW_MAXIMIZE = 3
SYS "ShowWindow", @hwnd%, SW_MAXIMIZE
VDU 26
Line 499:
NEXT
NEXT P%
</syntaxhighlight>
</lang>
 
=={{header|Befunge}}==
Line 507:
The dimensions of the image are specified by the first two values on the stack: 1366 (<tt>"%":*3-</tt>) by 768 (<tt>"`"8*</tt>).
 
<langsyntaxhighlight lang="befunge">"%":*3-"`"8*>4/::8%00p8/10p4*\55+"3P",,,:.\.5v
5+:,1vv\%2:%8/-g025:\-1_$$55+,\:v1+*8g01g00_@>
024,.<>2/:2%\2/...1+\:>^<:\0:\-1_$20g1-:20p^1p</langsyntaxhighlight>
 
=={{header|C}}==
Line 515:
The following code uses the BGI graphics library of Borland's Turbo C.
 
<syntaxhighlight lang="c">
<lang C>
#include<graphics.h>
#include<conio.h>
Line 544:
return 0;
}
</syntaxhighlight>
</lang>
 
=={{header|C++}}==
[[File:clr_pinstripe_cpp.png|300px]]
<langsyntaxhighlight lang="cpp">
#include <windows.h>
 
Line 669:
}
//--------------------------------------------------------------------------------------------------
</syntaxhighlight>
</lang>
 
=={{header|Common Lisp}}==
Line 675:
which causes the line caps to make the edges between regions to be a bit ragged. I mention
a couple of alternatives there which I'm too lazy to implement right now.
<langsyntaxhighlight lang="lisp">(in-package :cg-user)
 
;;; We only need a bitmap pane - nothing fancy
Line 709:
(draw-line win
(make-position xpos top)
(make-position xpos bottom)))))))</langsyntaxhighlight>
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: accessors arrays colors.constants kernel locals math
math.ranges opengl sequences ui ui.gadgets ui.render ;
 
Line 749:
bands [1,b] [ draw-pinstripe ] with each ;
 
<pinstripe> "Color pinstripe" open-window</langsyntaxhighlight>
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">' version 14-03-2017
' compile with: fbc -s console
' or compile with: fbc -s gui
Line 777:
'Print : Print "hit any key to end program"
Sleep
End</langsyntaxhighlight>
 
=={{header|Gambas}}==
<langsyntaxhighlight lang="gambas">'WARNING this takes a time to display
 
Public Sub Form_Open()
Line 807:
 
End
</syntaxhighlight>
</lang>
'''[http://www.cogier.com/gambas/colour_pinstripe.png Click to see output image]'''
 
Line 813:
{{libheader|Go Graphics}}
{{trans|Java}}
<langsyntaxhighlight lang="go">package main
 
import "github.com/fogleman/gg"
Line 845:
pinstripe(dc)
dc.SavePNG("color_pinstripe.png")
}</langsyntaxhighlight>
 
{{out}}
Line 855:
This is a modified version of the [[Pinstripe/Display]] solution. A shrunken screenshot is included.
 
<langsyntaxhighlight Iconlang="icon">link graphics,numbers,printf
procedure main() # pinstripe
Line 884:
}
WDone()
end</langsyntaxhighlight>
 
[[File:Pinstripe_Colour_unicon.jpeg]]
Line 894:
 
=={{header|J}}==
<langsyntaxhighlight lang="j"> load 'viewmat'
size=. 2{.".wd'qm' NB. J6
size=. getscreenwh_jgtk_ '' NB. J7
'rgb'viewmat (4<.@%~{:size)# ({.size) $&> 1 2 3 4#&.> <256#.255*#:i.8</langsyntaxhighlight>
 
=={{header|Java}}==
{{works with|Java|8}}
<langsyntaxhighlight lang="java">import java.awt.*;
import static java.awt.Color.*;
import javax.swing.*;
Line 938:
});
}
}</langsyntaxhighlight>
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">using Gtk, Graphics, Colors
 
function drawline(ctx, p1, p2, color, width)
Line 982:
signal_connect(endit, win, :destroy)
wait(cond)
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
{{trans|Java}}
<langsyntaxhighlight lang="scala">// version 1.1.0
 
import java.awt.*
Line 1,027:
f.isVisible = true
}
}</langsyntaxhighlight>
 
=={{header|Lua}}==
{{libheader|nw}}
{{libheader|cairo}}
<langsyntaxhighlight lang="lua">local nw = require("nw")
local app = nw:app()
local cw, ch = 320, 240
Line 1,052:
end
win:show()
app:run()</langsyntaxhighlight>
 
=={{header|M2000 Interpreter}}==
Line 1,064:
We use a thread to move the layer above console (and inside console form), when we push any mouse button (only in console window). Program ends when we close the modal opened window.
 
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module Checkit {
Window 16, 14000,12000;
Line 1,114:
Checkit
 
</syntaxhighlight>
</lang>
 
=={{header|Maple}}==
<syntaxhighlight lang="maple">
<lang Maple>
colors := [yellow, black, red, green, magenta, cyan, white]:
plots:-display( [
Line 1,123:
seq( plot([1+i/10,y,y=4..5], color=colors[i mod 7 + 1],thickness=2), i = 1..500),seq( plot([1+i/10,y,y=3..4], color=colors[i mod 7 + 1],thickness=3), i = 1..500),seq( plot([1+i/10,y,y=2..3], color=colors[i mod 7 + 1],thickness=4,size=[interface(screenwidth)*20,interface(screenheight)*32]), i = 1..500)],
axes=none);
</syntaxhighlight>
</lang>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">color[y_] := {Black, Red, Green, Blue, Magenta, Cyan, Yellow,
White}[[Mod[y, 8] + 1]];
Graphics[Join[{Thickness[1/408]},
Line 1,136:
Range[136]], {Thickness[1/102]},
Flatten[{color[#], Line[{{4 # - 2, 102}, {4 # - 2, 1}}]} & /@
Range[102]]], ImageSize -> {408, 408}]</langsyntaxhighlight>
{{out}}
See [https://www.dropbox.com/s/tg4zk4jkddkok8w/Mathematica_Pinstripes_Colored.png?dl=0 here].
Line 1,142:
=={{header|MIPS Assembly}}==
This isn't perfect, as the edges are cut off due to overscan. But this is as close as I could get:
<langsyntaxhighlight lang="mips">.include "\SrcAll\Header.asm"
.include "\SrcAll\BasicMacros.asm"
.include "\SrcALL\AdvancedMacros.asm"
Line 1,351:
;colors are approximate because I'm not sure how the bit patterns work.
.halfword 0x0000,0xf000,0x0f00,0x00f0,0xf0f0,0x7fff,0xff00,0xffff
.include "\SrcN64\Footer.asm"</langsyntaxhighlight>
 
{{out}}
Line 1,358:
=={{header|Nim}}==
{{libheader|gintro}}
<langsyntaxhighlight Nimlang="nim">import gintro/[glib, gobject, gtk, gio, cairo]
 
const
Line 1,420:
let app = newApplication(Application, "Rosetta.ColorPinstripe")
discard app.connect("activate", activate)
discard app.run()</langsyntaxhighlight>
 
=={{header|OCaml}}==
 
<langsyntaxhighlight lang="ocaml">open Graphics
 
let () =
Line 1,440:
done
done;
ignore(read_key())</langsyntaxhighlight>
 
run with:
Line 1,446:
 
=={{header|Perl}}==
<langsyntaxhighlight Perllang="perl">#!/usr/bin/perl -w
use strict ;
use GD ;
Line 1,481:
binmode DISPLAY ;
print DISPLAY $image->png ;
close DISPLAY ;</langsyntaxhighlight>
 
=={{header|Phix}}==
{{libheader|Phix/pGUI}}
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\Colour_pinstripe.exw
Line 1,574:
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</langsyntaxhighlight>-->
Simply change constant colours to {CD_BLACK, CD_WHITE} for the monochrome tasks (as redirected here).
 
Line 1,584:
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(de *Colors # Black Red Green Blue Magenta Cyan Yellow White
((0 0 0) (255 0 0) (0 255 0) (0 0 255)
(255 0 255) (0 255 255) (255 255 0) (255 255 255) .) )
Line 1,601:
(prinl (length (car Ppm)) " " (length Ppm))
(prinl 255)
(for Y Ppm (for X Y (apply wr X))) ) )</langsyntaxhighlight>
 
=={{header|Plain English}}==
<langsyntaxhighlight lang="plainenglish">To run:
Start up.
Clear the screen.
Line 1,643:
Add 1 pixel to the color pinstripe's width.
Move the color pinstripe's box down the color pinstripe's box's height.
Draw the color pinstripe.</langsyntaxhighlight>
 
=={{header|PureBasic}}==
<langsyntaxhighlight PureBasiclang="purebasic">;Create a Pinstripe image with a pattern of vertical stripe colors
Procedure PinstripeDisplay(width, height, Array psColors(1), numColors = 0)
Protected x, imgID, psHeight = height / 4, psWidth = 1, psTop, horzBand, curColor
Line 1,688:
While WaitWindowEvent() <> #PB_Event_CloseWindow
Wend
EndIf</langsyntaxhighlight>
 
=={{header|Python}}==
<syntaxhighlight lang="python">
<lang Python>
from turtle import *
 
Line 1,726:
notused = input("Hit enter to continue: ")
</syntaxhighlight>
</lang>
 
=={{header|QBasic}}==
{{works with|QBasic|1.1}}
{{trans|BASIC256}}
<langsyntaxhighlight lang="qbasic">SCREEN 12
w = 640: h = 480
 
Line 1,745:
col = col + 1
NEXT x
NEXT i</langsyntaxhighlight>
 
=={{header|Racket}}==
<syntaxhighlight lang="racket">
<lang Racket>
#lang racket/gui
 
Line 1,779:
 
(void (new full-frame%))
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
<syntaxhighlight lang="raku" perl6line>my ($x,$y) = 1280, 720;
 
my @colors = map -> $r, $g, $b { [$r, $g, $b] },
Line 1,811:
}
 
$img.close;</langsyntaxhighlight>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
# Project : Colour pinstripe/Display
 
Line 1,878:
}
label1 { setpicture(p1) show() }
</syntaxhighlight>
</lang>
 
See image:
Line 1,886:
=={{header|Scala}}==
===Java Swing Interoperability===
<langsyntaxhighlight Scalalang="scala">import java.awt.Color._
import java.awt._
 
Line 1,924:
)
 
}</langsyntaxhighlight>
 
=={{header|Sidef}}==
{{trans|Perl}}
<langsyntaxhighlight lang="ruby">require('GD')
 
func pinstripes(width = 1280, height = 720) {
Line 1,957:
}
 
File('pinstripes.png').write(pinstripes().png, :raw)</langsyntaxhighlight>
 
=={{header|SmileBASIC}}==
<langsyntaxhighlight lang="smilebasic">FOR I=1 TO 4
COLIDX=0
YTOP=(I-1)*60
Line 1,981:
DATA 0,255,255
DATA 255,255,0
DATA 255,255,255</langsyntaxhighlight>
 
=={{header|Tcl}}==
{{libheader|Tk}}
<langsyntaxhighlight lang="tcl">package require Tcl 8.5
package require Tk 8.5
Line 2,001:
}
incr y $dy
}</langsyntaxhighlight>
 
=={{header|True BASIC}}==
<langsyntaxhighlight lang="qbasic">LET w = 640
LET h = 480
SET WINDOW 0, w, 0, h
Line 2,021:
NEXT x
NEXT i
END</langsyntaxhighlight>
 
=={{header|Visual Basic .NET}}==
<langsyntaxhighlight lang="vbnet">Public Class Main
Inherits System.Windows.Forms.Form
Public Sub New()
Line 2,042:
Next
End Sub
End Class</langsyntaxhighlight>
 
=={{header|Wren}}==
{{trans|Go}}
{{libheader|DOME}}
<langsyntaxhighlight lang="ecmascript">import "graphics" for Canvas, Color
import "dome" for Window
 
Line 2,088:
 
static draw(dt) {}
}</langsyntaxhighlight>
 
=={{header|XPL0}}==
[[File:PinsXPL0.gif|right]]
<langsyntaxhighlight XPL0lang="xpl0">code ChIn=7, Point=41, SetVid=45;
int X, Y, W, C;
[SetVid($13); \set 320x200 graphics mode in 256 colors
Line 2,105:
X:= ChIn(1); \wait for keystroke
SetVid(3); \restore normal text mode display
]</langsyntaxhighlight>
 
=={{header|Yabasic}}==
{{trans|SmileBASIC}}
<langsyntaxhighlight Yabasiclang="yabasic">w = 640 : h = 480
open window w, h
h4 = h/4
Line 2,134:
DATA 255,255,0
DATA 255,255,255
</syntaxhighlight>
</lang>
 
{{omit from|AWK}}
10,343

edits