Greyscale bars/Display: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(15 intermediate revisions by 6 users not shown)
Line 9:
 
=={{header|ActionScript}}==
<langsyntaxhighlight ActionScriptlang="actionscript">package
{
import flash.display.Sprite;
Line 34:
}
}
}</langsyntaxhighlight>
 
=={{header|Ada}}==
{{libheader|GTK}}
{{libheader|GtkAda}}
<langsyntaxhighlight Adalang="ada">with Gtk.Window; use Gtk.Window;
with Gtk.Enums;
with Gtk.Handlers;
Line 124:
Gtk.Main.Main;
end Greyscale;
</syntaxhighlight>
</lang>
 
=={{header|Amazing Hopper}}==
{{trans|AWK}}
Version: hopper-FLOW!
<syntaxhighlight lang="amazing hopper">
<lang Amazing Hopper>
#include <flow.h>
#include <flow-term.h>
Line 164:
NEXT
RET
</syntaxhighlight>
</lang>
 
=={{header|ANSI Standard BASIC}}==
 
{{trans|BBC BASIC}}
 
<lang ANSI Standard BASIC>100 SET WINDOW 0,1279,0,1023
110 REM (0,0) is the bottom left of the display
120 SET AREA COLOR 1 ! Select color one for drawing
130 FOR row=1 TO 4
140 LET n=IP(2^(row+2))
150 LET w=IP(1280/n)
160 LET py=IP(256*(4-row))
170 FOR b=0 TO n-1
180 LET g=b/(n-1)
190 IF n=16 OR n=64 THEN LET g=1-g
200 SET COLOR MIX(1) g,g,g ! Reprogram color 1 to the gray we want
210 PLOT AREA: w*b,py; w*b+w,py; w*b+w,py+256; w*b,py+256
220 NEXT b
230 NEXT row
240 END</lang>
 
=={{header|AutoHotkey}}==
Requires the GDI+ Standard Library by tic: http://www.autohotkey.com/forum/viewtopic.php?t=32238
<langsyntaxhighlight AHKlang="ahk">h := A_ScreenHeight
w := A_ScreenWidth
pToken := gdip_Startup()
Line 243 ⟶ 223:
QColor(r, g, b){
return 0xFF000000 | (r << 16) | (g << 8) | (b)
}</langsyntaxhighlight>
 
=={{header|AWK}}==
<langsyntaxhighlight lang="awk">
BEGIN {
nrcolors = 8
Line 272 ⟶ 252:
}
}
</syntaxhighlight>
</lang>
 
=={{header|BASIC}}==
==={{header|ANSI BASIC}}===
{{trans|BBC BASIC}}
{{works with|Decimal BASIC}}
<syntaxhighlight lang="basic">100 SET WINDOW 0,1279,0,1023
110 REM (0,0) is the bottom left of the display
120 SET AREA COLOR 1 ! Select color one for drawing
130 FOR row=1 TO 4
140 LET n=IP(2^(row+2))
150 LET w=IP(1280/n)
160 LET py=IP(256*(4-row))
170 FOR b=0 TO n-1
180 LET g=b/(n-1)
190 IF n=16 OR n=64 THEN LET g=1-g
200 SET COLOR MIX(1) g,g,g ! Reprogram color 1 to the gray we want
210 PLOT AREA: w*b,py; w*b+w,py; w*b+w,py+256; w*b,py+256
220 NEXT b
230 NEXT row
240 END</syntaxhighlight>
 
==={{header|BASIC256}}===
<syntaxhighlight lang="text">
h=ceil(graphheight/4)
for row=1 to 4
Line 286:
next n
next row
</syntaxhighlight>
</lang>
 
==={{header|BBC BASIC}}===
<langsyntaxhighlight lang="bbcbasic">MODE 8:REM 640 x 512 pixel display mode: BBC BASIC gives 2 graphics points per pixel
REM (0,0) is the bottom left of the display
GCOL 1 :REM Select colour one for drawing
Line 302:
RECTANGLE FILL w%*b%,py%,w%,256
NEXT b%
NEXT row%</langsyntaxhighlight>
 
=={{header|C}}==
{{libheader|GTK}}
<langsyntaxhighlight lang="c">#include <gtk/gtk.h>
/* do some greyscale plotting */
void gsplot (cairo_t *cr,int x,int y,double s) {
Line 340:
gtk_main ();
return 0;
} </langsyntaxhighlight>
 
=={{header|C sharp|C#}}==
{{libheader|System.Windows.Forms}}
<langsyntaxhighlight lang="csharp">using System;
using System.Drawing;
using System.Windows.Forms;
Line 376:
return colorBars;
}
}</langsyntaxhighlight>
 
=={{header|C++}}==
Line 383:
file greytones.h
</PRE>
<langsyntaxhighlight lang="cpp">#ifndef MYWIDGET_H
#define MYWIDGET_H
#include <QWidget>
Line 396:
void paintEvent( QPaintEvent * ) ;
} ;
#endif</langsyntaxhighlight>
<pre>file greytones.cpp</pre>
<langsyntaxhighlight lang="cpp">#include <QtGui>
#include "greytones.h"
 
Line 431:
run++ ;
}
}</langsyntaxhighlight>
<PRE>
file main.cpp
</PRE>
<langsyntaxhighlight lang="cpp">#include <QApplication>
#include "greytones.h"
 
Line 444:
window.show( ) ;
return app.exec( ) ;
}</langsyntaxhighlight>
 
=={{header|Component Pascal}}==
Line 451:
[[File:GreyScaleCp.png|thumb|right]]
 
<langsyntaxhighlight lang="oberon2">
MODULE RosettaGreys;
IMPORT Views, Ports, Properties, Controllers, StdLog;
Line 528:
 
"RosettaGreys.Deposit; StdCmds.Open"
</syntaxhighlight>
</lang>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|Windows,Types,StdCtrls,ExtCtrls,SysUtils,Graphics}}
Uses Delphi graphic objects to create a subroutine which draws rows of bars according to specificification for number of bars and rows, the row number and the direction of the color graident.
 
<syntaxhighlight lang="Delphi">
procedure DrawBar(Image: TImage; Bars,Rows,Row: integer; WhiteToBlack: boolean);
{Draw horizontal bar according the following parameters:}
{Bars = number of color bars to fit into the horizontal space}
{Rows = number of rows to fit into the vertical space}
{Row = the row to place the current bar - numbered 0..n, top to bottom}
{WhiteToBlack - if true, bars in the row go from white to back}
var X: integer;
var Color: integer;
var ColorStep: double;
var BarHeight: integer;
var R,R2: TRect;
begin
{Calculate bar dimensions}
BarHeight:=Image.Height div Rows;
R:=Rect(0,0,(Image.Width div Bars)+1, BarHeight);
OffsetRect(R,0,BarHeight * Row);
R2:=R;
{Calculate color parameters}
ColorStep:=255/(Bars-1);
if WhiteToBlack then
begin
Color:=255;
ColorStep:=-ColorStep
end
else Color:=0;
{Draw bars}
for X:=1 to Bars do
begin
{Set color}
Image.Canvas.Brush.Color:=RGB(Color,Color,Color);
Image.Canvas.Pen.Color:=RGB(Color,Color,Color);
{Draw rectangular bar}
Image.Canvas.Rectangle(R2);
{Move rectangle and calculate color}
OffsetRect(R2,R.Right,0);
Color:=Round(X * ColorStep);
end;
end;
 
 
procedure ShowGrayBars(Image: TImage);
{Draw four bar, with alternating color scheme}
begin
DrawBar(Image,8,4,0,False);
DrawBar(Image,16,4,1,True);
DrawBar(Image,32,4,2,False);
DrawBar(Image,64,4,3,True);
end;
</syntaxhighlight>
{{out}}
[[File:DelphGrayBars.png|thumb|none]]
<pre>
</pre>
 
=={{header|EasyLang}}==
 
[https://easylang.dev/show/#cod=PY5BDoMgEEX3nOIvK00RMKbdeBqKCYkyDZqa9PSdMSAr5v3PGzImvNRMBYUOvlvshEEB2H48OmvRI8ssndQaGQ84oXwCw8St2wm7StN8Gld6w4uo4tp3XA0VmeahhcrAcbiilb5RPqJ5wXPkN6LU8GPNSwy75HcWXnBbYvzAGutVs2foCV4Z9Qc= Run it]
[https://easylang.online/apps/_greyscale.html Run it]
 
<syntaxhighlight lang="text">
<lang>n = 8
n = 8
for row range 4
for szrow = 1000 /to n3
for isz range= 100 / n
for ci = i0 /to (n - 1)
if row mod 2c = i / (n - 1)
cif =row 1mod -2 c= 1
. c = 1 - c
color3 c c c.
move sz *color3 ic rowc * 25c
rect move sz +* i 75 - row 1* 25
rect sz + 1 25
.
n *= 2 sleep 0.02
.
.</lang>
n *= 2
.
</syntaxhighlight>
 
=={{header|Eiffel}}==
Line 555 ⟶ 618:
[https://github.com/ljr1981/rosettacode_answers/blob/main/testing/rc_greyscale_bars/eifgreyscale.png PNG Output]
 
<langsyntaxhighlight lang="eiffel">
feature -- Test routines
 
Line 624 ⟶ 687:
black: REAL = 0.0
white: REAL = 1.0
 
down: INTEGER = -1
updown: INTEGER = -1 --| From `white' to `black' or ...
up: INTEGER = 1 --| From `black' to `white'
</lang>
</syntaxhighlight>
 
=={{header|Euler Math Toolbox}}==
<syntaxhighlight lang="euler math toolbox">
<lang Euler Math Toolbox>
>function grayscale(y1,y2,n,direction=1) ...
$ loop 0 to n-1;
Line 650 ⟶ 714:
$endfunction
>grayscales:
</syntaxhighlight>
</lang>
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">' version 01-09-2017
' compile with: fbc -s console
' or compile with: fbc -s gui
Line 687 ⟶ 751:
 
Sleep
End</langsyntaxhighlight>
 
=={{header|Frink}}==
<langsyntaxhighlight lang="frink">
fakewidth =!= dummy
 
Line 712 ⟶ 776:
}
}
</syntaxhighlight>
</lang>
 
=={{header|FutureBasic}}==
[[File:GrayscalesR.png|thumb|right]]
<langsyntaxhighlight lang="futurebasic">
_window = 1
 
Line 771 ⟶ 835:
 
HandleEvents
</syntaxhighlight>
</lang>
{{output}}
<pre>
Line 777 ⟶ 841:
</pre>
And here's another clever and shorter solution:
<langsyntaxhighlight lang="futurebasic">void local fn BuildWindow
CGRect r = {0,0,640,400}
long i, j, bars = 8
Line 801 ⟶ 865:
fn BuildWindow
 
HandleEvents</langsyntaxhighlight>
 
=={{header|Gambas}}==
<langsyntaxhighlight lang="gambas">Public Sub Form_Open()
Dim iRow, iCol, iClr As Integer 'For Row, Column and Colour
Dim iInc As Integer = 4 'To calculate RGB colour
Line 832 ⟶ 896:
Next
 
End</langsyntaxhighlight>
 
'''[http://www.cogier.com/gambas/GreyScale.png Click here for image of the output]'''
Line 839 ⟶ 903:
{{libheader|Go Graphics}}
{{trans|Java}}
<langsyntaxhighlight lang="go">package main
 
import (
Line 878 ⟶ 942:
greyBars(dc)
dc.SavePNG("greybars.png")
}</langsyntaxhighlight>
 
{{out}}
Line 888 ⟶ 952:
This program uses an inlined XPM file which is scaled to fill an entire GTK fullscreen window
 
<langsyntaxhighlight Haskelllang="haskell">import Graphics.UI.Gtk
import Graphics.UI.Gtk.Gdk.GC
import Control.Monad.Trans (liftIO)
Line 945 ⟶ 1,009:
"AADDFFHHJJLLNNPPRRTTVVXXZZbbddffhhjjllnnpprrttvvxxzz11336688..**",
"*+.9876543210zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCA"
]</langsyntaxhighlight>
 
=={{header|Icon}} and {{header|Unicon}}==
Line 952 ⟶ 1,016:
 
[[File:Greyscale_unicon.png|thumb|right]]
<langsyntaxhighlight Iconlang="icon">link graphics,printf,numbers
procedure main()
Line 982 ⟶ 1,046:
put(TC.bands,band(height)) # bottom sentinal
return TC
end</langsyntaxhighlight>
 
{{libheader|Icon Programming Library}}
Line 991 ⟶ 1,055:
=={{header|J}}==
'''Solution:'''
<langsyntaxhighlight lang="j"> load 'viewmat'
NB. size=. 2{.".wd'qm' NB. J6
NB. size=. getscreenwh_jgtk_ '' NB. J7
Line 999 ⟶ 1,063:
togreyscale=. (256#. [:<.255 255 255&*)"0
'rgb' viewmat (4<.@%~{:size)# (64<.@%~{.size)#"1 togreyscale bars
wd 'pmove 0 _30 ',":size [ wd 'psel ',1{::,hforms_jviewmat_'' NB. J9</langsyntaxhighlight>
 
Note that hardware changes over the years have left their mark on interface protocols, which shows up here as language changes.
Line 1,005 ⟶ 1,069:
=={{header|Java}}==
using basically the same code as in the C++ example
<langsyntaxhighlight Javalang="java">import javax.swing.* ;
import java.awt.* ;
 
Line 1,051 ⟶ 1,115:
Greybars gb = new Greybars( ) ;
}
}</langsyntaxhighlight>
 
=={{header|JavaScript}}==
Live Demo: http://jsfiddle.net/gcN9g/embedded/result/
<langsyntaxhighlight JavaScriptlang="javascript"><html><body>
<script type="text/javascript">
var width = 640; var height = 400;
Line 1,084 ⟶ 1,148:
</script>
</body></html>
</syntaxhighlight>
</lang>
 
=={{header|Julia}}==
<langsyntaxhighlight Julialang="julia">using Gtk, Cairo, ColorTypes
 
function generategrays(n, screenwidth)
Line 1,141 ⟶ 1,205:
endit(w) = notify(cond)
signal_connect(endit, win, :destroy)
wait(cond)</langsyntaxhighlight>
 
=={{header|Kotlin}}==
{{trans|Java}}
<langsyntaxhighlight lang="scala">// version 1.1
 
import java.awt.Color
Line 1,195 ⟶ 1,259:
fun main(args: Array<String>) {
GreyBars()
}</langsyntaxhighlight>
 
=={{header|Liberty BASIC}}==
Black boxes were added around each color for ease of counting the boxes.
<syntaxhighlight lang="lb">
<lang lb>
nomainwin
 
Line 1,232 ⟶ 1,296:
end
 
</syntaxhighlight>
</lang>
Resulting [http://www.diga.me.uk/greyscale.gif GreyScale image] without the outlines.
 
Line 1,238 ⟶ 1,302:
{{libheader|nw}}
{{libheader|cairo}}
<langsyntaxhighlight lang="lua">local nw = require("nw")
local app = nw:app()
local cw, ch = 320, 240
Line 1,258 ⟶ 1,322:
end
win:show()
app:run()</langsyntaxhighlight>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
 
<langsyntaxhighlight lang="mathematica">CreateDocument[ Graphics[ Flatten@Table[
{ If[EvenQ[#3], GrayLevel[ 1. - j/#1 ], GrayLevel[ j/#1 ]],
Rectangle[{j #2, 7*#3}, {#2 (j + 1), (#3 + 1) 7}]}, {j, 0, #1}] & @@@
{{7, 8, 3}, {15, 4, 2}, {31, 2, 1}, {63, 1, 0} }
,ImageSize -> Full], WindowFrame -> "Frameless", WindowSize -> Full]</langsyntaxhighlight>
[[File:greyscales.jpg|thumb|right]]
 
Line 1,272 ⟶ 1,336:
 
3ds max provides customizable maps like gradient to the user, but you can also write it:
<syntaxhighlight lang="maxscript">
<lang MAXScript>
fn drawBarRow _bmp _row _width _number _inverse=
(
Line 1,342 ⟶ 1,406:
b = bitmap_verticalBars()
display b
</syntaxhighlight>
</lang>
 
=={{header|Nim}}==
{{libheader|gintro}}
<langsyntaxhighlight Nimlang="nim">import gintro/[glib, gobject, gtk, gio, cairo]
 
const
Line 1,412 ⟶ 1,476:
let app = newApplication(Application, "Rosetta.GreyscaleBars")
discard app.connect("activate", activate)
discard app.run()</langsyntaxhighlight>
 
=={{header|OCaml}}==
 
<langsyntaxhighlight lang="ocaml">open Graphics
 
let round x = truncate (floor (x +. 0.5))
Line 1,437 ⟶ 1,501:
done
) bars;
ignore(read_key())</langsyntaxhighlight>
 
Run with:
Line 1,443 ⟶ 1,507:
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">sub partition {
my($all, $div) = @_;
my @marks = 0;
Line 1,479 ⟶ 1,543:
bars($h2,$w,4,1),
bars($h3,$w,5,0),
bars($h4,$w,6,1);</langsyntaxhighlight>
[https://github.com/SqrtNegInf/Rosettacode-Perl5-Smoke/blob/master/ref/Greyscale-bars-perl5.png See Greyscale-bars-perl5] (offsite image)
 
Line 1,487 ⟶ 1,551:
{{libheader|Phix/online}}
You can run this online [http://phix.x10.mx/p2js/Greyscale_bars.htm here].
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\Greyscale_bars.exw
Line 1,550 ⟶ 1,614:
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</langsyntaxhighlight>-->
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(let Pgm # Create PGM of 384 x 288 pixels
(make
(for N 4
Line 1,568 ⟶ 1,632:
(prinl (length (car Pgm)) " " (length Pgm))
(prinl 255)
(for Y Pgm (apply wr Y)) ) )</langsyntaxhighlight>
 
=={{header|Plain English}}==
<langsyntaxhighlight lang="plainenglish">To run:
Start up.
Clear the screen.
Line 1,615 ⟶ 1,679:
If the flag is set, put "right-to-left" into the gradient's direction.
If the flag is not set, put "left-to-right" into the gradient's direction.
Draw the gradient.</langsyntaxhighlight>
 
=={{header|Processing}}==
<langsyntaxhighlight lang="java">
//Aamrun, 3rd July 2022
 
Line 1,640 ⟶ 1,704:
drawPanel(255,0,64,3*height/4);
}
</syntaxhighlight>
</lang>
 
=={{header|PureBasic}}==
<langsyntaxhighlight PureBasiclang="purebasic">EnableExplicit
 
Macro Check(Function)
Line 1,705 ⟶ 1,769:
CloseScreen()
EndIf
End</langsyntaxhighlight>
Press Enter or Escape to exit the programs's display.
 
=={{header|Python}}==
{{libheader|livewires}}
<langsyntaxhighlight Pythonlang="python">#!/usr/bin/env python
#four gray scaled stripes 8:16:32:64 in Python 2.7.1
 
Line 1,735 ⟶ 1,799:
while keys_pressed() != [' ']: # press spacebar to close window
pass
</syntaxhighlight>
</lang>
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="Quackery"> [ $ "turtleduck.qky" loadfile ] now!
 
[ 1280 1 ] is width ( --> s )
[ 720 1 ] is height ( --> s )
 
[ dip [ 1 - dup ]
255 * swap /
1 swap
3 of dup colour fill
[ 2 times
[ width 2over v/ walk
-1 4 turn
height 4 1 v/ walk
-1 4 turn ]
2drop ] ] is bar ( n n --> )
 
[ 1 over times
[ over i bar
width 2over v/ fly ]
2drop ] is line ( n --> )
 
[ turtle
10 frames
width 2 1 v/ fly
1 4 turn
height 2 1 v/ fly
1 2 turn
height fly
-1 4 turn
' [ 8 16 32 64 ]
2 times
[ behead line
1 4 turn
height -2 1 v/ fly
1 4 turn
behead line
1 2 turn ]
drop
1 frames ] is greyscale-bars ( --> )
 
greyscale-bars</syntaxhighlight>
 
{{out}}
[[File:Quackery greyscale.png|center|thumb]]
 
=={{header|R}}==
Create a 4x64 matrix representing the described pattern, set margins to 0 so the image will fill the display, and plot the matrix in grayscale using the "image" function:
[[File:GrayscalesR.png|thumb|right]]
<syntaxhighlight lang="r">
<lang R>
mat <- matrix(c(rep(1:8, each = 8) / 8,
rep(16:1, each = 4) / 16,
Line 1,748 ⟶ 1,859:
par(mar = rep(0, 4))
image(t(mat[4:1, ]), col = gray(1:64/64), axes = FALSE)
</syntaxhighlight>
</lang>
 
Or, this can be generalized with the function below, which produces the pattern for an arbitrary number of rows (though rows become visibly indistinguishable after about row 5):
[[File:GrayscalesR-6.png|thumb|right]]
<syntaxhighlight lang="r">
<lang R>
grayscalesImage <- function(nrow = 4) {
X <- matrix(NA, nrow = nrow, ncol = 2^(nrow + 2))
Line 1,764 ⟶ 1,875:
## Example ##
grayscalesImage(6) # produces image shown in screenshot to the right
</syntaxhighlight>
</lang>
 
=={{header|Racket}}==
Line 1,772 ⟶ 1,883:
[[File:Grayscale-pict.png|thumb|right]]
 
<langsyntaxhighlight lang="racket">
#lang racket/gui
(require slideshow/pict)
Line 1,793 ⟶ 1,904:
(vc-append (grays 1/8 'right) (grays 1/16 'left)
(grays 1/32 'right) (grays 1/64 'left))
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
<syntaxhighlight lang="raku" perl6line>my ($width,$height) = 1280,768;
my $PGM = open "Greyscale-bars-perl6.pgm", :w orelse die "Can't create Greyscale-bars-perl6.pgm: $_";
Line 1,831 ⟶ 1,942:
my @marks = ((1/$div,2/$div ... 1) X* $all)».round;
@marks Z- 0,|@marks;
}</langsyntaxhighlight>
[https://github.com/SqrtNegInf/Rosettacode-Perl6-Smoke/blob/master/ref/Greyscale-bars-perl6.png See Greyscale-bars-perl6] (offsite image)
 
=={{header|RapidQ}}==
<syntaxhighlight lang="vb">
<lang vb>
Declare Sub PaintCanvas
 
Line 1,864 ⟶ 1,975:
 
Form.showmodal
</syntaxhighlight>
</lang>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
# Project : Greyscale bars/Display
 
Line 1,926 ⟶ 2,037:
}
label1 { setpicture(p1) show() }
</syntaxhighlight>
</lang>
Output:
https://www.dropbox.com/s/01iywg04iwubf55/GreyscaleBars.jpg?dl=0
 
=={{header|Run BASIC}}==
<langsyntaxhighlight Runbasiclang="runbasic">for i = 1 to 4
incr = int(256 / (i * 8))
c = 256
Line 1,942 ⟶ 2,053:
next i
html "</table>"
end</langsyntaxhighlight>
<pre>Run in a browser</pre>
 
=={{header|Scala}}==
<langsyntaxhighlight lang="scala">import scala.swing._
 
class GreyscaleBars extends Component {
Line 1,964 ⟶ 2,075:
}
}
}</langsyntaxhighlight>
Open window:
[[File:greyscalebars_scala.png|thumb|right]]
<langsyntaxhighlight lang="scala">new MainFrame(){
title="Greyscale bars"
visible=true
preferredSize=new Dimension(640, 320)
contents=new GreyscaleBars()
}</langsyntaxhighlight>
 
=={{header|Seed7}}==
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "draw.s7i";
include "keybd.s7i";
Line 2,005 ⟶ 2,116:
end for;
ignore(getc(KEYBOARD));
end func;</langsyntaxhighlight>
 
=={{header|Tcl}}==
{{libheader|Tk}}
<langsyntaxhighlight lang="tcl">package require Tcl 8.5
package require Tk 8.5
Line 2,029 ⟶ 2,140:
}
incr y $dy
}</langsyntaxhighlight>
 
=={{header|Wren}}==
{{libheader|DOME}}
<langsyntaxhighlight ecmascriptlang="wren">import "graphics" for Canvas, Color
import "dome" for Window
import "math" for Math
Line 2,083 ⟶ 2,194:
}
 
var Game = GreyBars.new(640, 320)</langsyntaxhighlight>
 
=={{header|XPL0}}==
Floating point is used to get the full range of black to white.
 
<langsyntaxhighlight XPL0lang="xpl0">include c:\cxpl\codes; \intrinsic 'code' declarations
int Q, N, W, B, C, Y;
[SetVid($112); \640x480x24 graphics
Line 2,103 ⟶ 2,214:
Q:= ChIn(1); \wait for keystroke
SetVid(3); \restore normal text mode
]</langsyntaxhighlight>
 
=={{header|Yabasic}}==
<langsyntaxhighlight Yabasiclang="yabasic">open window 1024, 600
w = peek("winwidth")
h = peek("winheight")
Line 2,128 ⟶ 2,239:
pause .1
next n
next row</langsyntaxhighlight>
 
=={{header|zkl}}==
Line 2,134 ⟶ 2,245:
{{trans|XPL0}}
Uses the PPM class from http://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#zkl
<langsyntaxhighlight lang="zkl">img:=PPM(640,480);
foreach q in ([0..3]){ //quarter of screen
n:=(8).shiftLeft(q); //number of bars
Line 2,146 ⟶ 2,257:
}
}
img.write(File("foo.ppm","wb"));</langsyntaxhighlight>
{{out}}
Same as the R image (but smaller):
Line 2,156 ⟶ 2,267:
and we have a set of 8 bars:
 
<langsyntaxhighlight lang="zxbasic">10 REM wind the colour down or use a black and white television to see greyscale bars
20 REM The ZX Spectrum display is 32 columns wide, so we have 8 columns of 4 spaces
25 BORDER 0: CLS
Line 2,164 ⟶ 2,275:
60 NEXT c
70 REM at this point the cursor has wrapped, so we don't need a newline
80 NEXT r</langsyntaxhighlight>
 
{{omit from|GUISS}}
9,476

edits