task_url stringlengths 30 116 | task_name stringlengths 2 86 | task_description stringlengths 0 14.4k | language_url stringlengths 2 53 | language_name stringlengths 1 52 | code stringlengths 0 61.9k |
|---|---|---|---|---|---|
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #Julia | Julia | using Gtk, Graphics, Colors
function drawline(ctx, p1, p2, color, width)
move_to(ctx, p1.x, p1.y)
set_source(ctx, color)
line_to(ctx, p2.x, p2.y)
set_line_width(ctx, width)
stroke(ctx)
end
const can = @GtkCanvas()
const win = GtkWindow(can, "Colour pinstripe/Display", 400, 400)
const colors = [c... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #Kotlin | Kotlin | // version 1.1.0
import java.awt.*
import java.awt.Color.*
import javax.swing.*
class ColourPinstripeDisplay : JPanel() {
private companion object {
val palette = arrayOf(black, red, green, blue, magenta, cyan, yellow, white)
}
private val bands = 4
init {
preferredSize = Dimensi... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Phix | Phix | integer {r,g,b} = im_pixel(image, x, y) |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #PHP | PHP | $img = imagegrabscreen();
$color = imagecolorat($im, 10, 50);
imagedestroy($im); |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #PicoLisp | PicoLisp | (in '(grabc)
(mapcar hex (cdr (line NIL 1 2 2 2))) ) |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Racket | Racket | #lang racket
(require racket/draw
colors)
(define DIM 500)
(define target (make-bitmap DIM DIM))
(define dc (new bitmap-dc% [bitmap target]))
(define radius 200)
(define center (/ DIM 2))
(define (atan2 y x) (if (= 0 y x) 0 (atan y x)))
(for* ([x (in-range DIM)]
[y (in-range DIM)]
[rx (in... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Raku | Raku | use Image::PNG::Portable;
my ($w, $h) = 300, 300;
my $out = Image::PNG::Portable.new: :width($w), :height($h);
my $center = $w/2 + $h/2*i;
color-wheel($out);
$out.write: 'Color-wheel-perl6.png';
sub color-wheel ( $png ) {
^$w .race.map: -> $x {
for ^$h -> $y {
my $vector = $center... |
http://rosettacode.org/wiki/Combinations | Combinations | Task
Given non-negative integers m and n, generate all size m combinations of the integers from 0 (zero) to n-1 in sorted order (each combination is sorted and the entire table is sorted).
Example
3 comb 5 is:
0 1 2
0 1 3
0 1 4
0 2 3
0 2 4
0 3 4
1 2 3
1 2 4
1 3 4
2 3 4
... | #AWK | AWK | BEGIN {
## Default values for r and n (Choose 3 from pool of 5). Can
## alternatively be set on the command line:-
## awk -v r=<number of items being chosen> -v n=<how many to choose from> -f <scriptname>
if (length(r) == 0) r = 3
if (length(n) == 0) n = 5
for (i=1; i <= r; i++) { ## First combination of items... |
http://rosettacode.org/wiki/Conditional_structures | Conditional structures | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Task
List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions.
Common conditional structures include ... | #Maxima | Maxima | if test1 then (...) elseif test2 then (...) else (...); |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #PARI.2FGP | PARI/GP | (* This is a comment.
It may extend across multiple lines. *)
{ Alternatively curly braces
can be used. }
(* This is a valid comment in Standard Pascal,
but not valid in [[Turbo Pascal]]. }
{ The same is true in this case *) |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #Pascal | Pascal | (* This is a comment.
It may extend across multiple lines. *)
{ Alternatively curly braces
can be used. }
(* This is a valid comment in Standard Pascal,
but not valid in [[Turbo Pascal]]. }
{ The same is true in this case *) |
http://rosettacode.org/wiki/Color_quantization | Color quantization | full color
Example: Gimp 16 color
Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace. There... | #Kotlin | Kotlin | // Version 1.2.41
import java.io.BufferedReader
import java.io.InputStreamReader
fun main(args: Array<String>) {
// convert 'frog' to an image which uses only 16 colors, no dithering
val pb = ProcessBuilder(
"convert",
"Quantum_frog.png",
"-dither",
"None",
"-colors",... |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #XPL0 | XPL0 | def M=3; \array size
char NowGen(M+2, M+2), \size with surrounding borders
NewGen(M+2, M+2);
int X, Y, I, J, N, Gen;
code ChOut=8, CrLf=9;
[for Y:= 0 to M+1 do \set up initial state
for X:= 0 to M+1 do
[NowGen(X,Y):= ^ ; NewGen(X,Y):= ^ ];
NowGen(... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #M2000_Interpreter | M2000 Interpreter |
Module Checkit {
Window 16, 14000,12000;
Module Pinstripe {
Smooth off ' use of GDI32
Dim colors(0 to 7)
Colors(0)=#000000,#FF0000, #00FF00, #0000FF, #FF00FF, #00FFFF, #FFFF00, #FFFFFF
pixelsX=scale.x/twipsX
pixelsY=scale.y/twipsY
zo... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #Maple | Maple |
colors := [yellow, black, red, green, magenta, cyan, white]:
plots:-display( [
seq( plot([1+i/10,y,y=5..6], color=colors[i mod 7 + 1],thickness=1), i = 1..500),
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)... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #Mathematica_.2F_Wolfram_Language | Mathematica / Wolfram Language | color[y_] := {Black, Red, Green, Blue, Magenta, Cyan, Yellow,
White}[[Mod[y, 8] + 1]];
Graphics[Join[{Thickness[1/408]},
Flatten[{color[#], Line[{{# - 1/2, 408}, {# - 1/2, 307}}]} & /@
Range[408]], {Thickness[1/204]},
Flatten[{color[#], Line[{{2 # - 1, 306}, {2 # - 1, 205}}]} & /@
Range[204]], {Thi... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Processing | Processing | void draw(){
color c = get(mouseX,mouseY);
println(c, red(c), green(c), blue(c));
} |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Python | Python | def get_pixel_colour(i_x, i_y):
import win32gui
i_desktop_window_id = win32gui.GetDesktopWindow()
i_desktop_window_dc = win32gui.GetWindowDC(i_desktop_window_id)
long_colour = win32gui.GetPixel(i_desktop_window_dc, i_x, i_y)
i_colour = int(long_colour)
win32gui.ReleaseDC(i_desktop_window_id,i_desktop_window_dc)
... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Racket | Racket | use GD::Raw;
my $file = '/tmp/one-pixel-screen-capture.png';
qqx/screencapture -R 123,456,1,1 $file/;
my $fh = fopen($file, "rb") or die;
my $image = gdImageCreateFromPng($fh);
my $pixel = gdImageGetPixel($image, 0, 0);
my ($red,$green,$blue) =
gdImageRed( $image, $pixel),
gdImageGreen($image, $pixel)... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Ring | Ring |
#===================================================================#
# Sample: Color Wheel
# Author: Gal Zsolt, Bert Mariani, Ilir Liburn & Mahmoud Fayed
#===================================================================#
load "guilib.ring"
xWidth = 400
yHeight = 400
MyApp = new qapp
{
win1 = new qwi... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Ruby | Ruby |
def settings
size(300, 300)
end
def setup
sketch_title 'Color Wheel'
background(0)
radius = width / 2.0
center = width / 2
grid(width, height) do |x, y|
rx = x - center
ry = y - center
sat = Math.hypot(rx, ry) / radius
if sat <= 1.0
hue = ((Math.atan2(ry, rx) / PI) + 1) / 2.0
... |
http://rosettacode.org/wiki/Combinations | Combinations | Task
Given non-negative integers m and n, generate all size m combinations of the integers from 0 (zero) to n-1 in sorted order (each combination is sorted and the entire table is sorted).
Example
3 comb 5 is:
0 1 2
0 1 3
0 1 4
0 2 3
0 2 4
0 3 4
1 2 3
1 2 4
1 3 4
2 3 4
... | #BBC_BASIC | BBC BASIC | INSTALL @lib$+"SORTLIB"
sort% = FN_sortinit(0,0)
M% = 3
N% = 5
C% = FNfact(N%)/(FNfact(M%)*FNfact(N%-M%))
DIM s$(C%)
PROCcomb(M%, N%, s$())
CALL sort%, s$(0)
FOR I% = 0 TO C%-1
PRINT s$(I%)
NEXT
END
DEF PROCcomb(C%, N%, s$())
... |
http://rosettacode.org/wiki/Conditional_structures | Conditional structures | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Task
List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions.
Common conditional structures include ... | #MAXScript | MAXScript | if x == 1 then
(
print "one"
)
else if x == 2 then
(
print "two"
)
else
(
print "Neither one or two"
) |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #PASM | PASM | # This is a comment
print "Hello\n" # This is also a comment
end |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #Peloton | Peloton |
<@ OMT>This is a
multiline
comment</@>
|
http://rosettacode.org/wiki/Color_quantization | Color quantization | full color
Example: Gimp 16 color
Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace. There... | #Mathematica_.2F_Wolfram_Language | Mathematica / Wolfram Language | ColorQuantize[Import["http://rosettacode.org/mw/images/3/3f/Quantum_frog.png"],16,Dithering->False] |
http://rosettacode.org/wiki/Color_quantization | Color quantization | full color
Example: Gimp 16 color
Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace. There... | #Nim | Nim | import algorithm
import nimPNG
type
Channel {.pure.} = enum R, G, B
QItem = tuple
color: array[Channel, byte] # Color of the pixel.
index: int # Position of pixel in the sequential sequence.
#---------------------------------------------------------------------------------------... |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #XSLT | XSLT | <xsl:template match="/table">
<table>
<xsl:apply-templates />
</table>
</xsl:template>
<xsl:template match="tr">
<tr><xsl:apply-templates /></tr>
</xsl:template>
<xsl:template match="td">
<xsl:variable name="liveNeighbours">
<xsl:apply-templates select="current()" mode="countLiveNeig... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #Nim | Nim | import gintro/[glib, gobject, gtk, gio, cairo]
const
Width = 420
Height = 420
const Colors = [[0.0, 0.0, 0.0], [255.0, 0.0, 0.0],
[0.0, 255.0, 0.0], [0.0, 0.0, 255.0],
[255.0, 0.0, 255.0], [0.0, 255.0, 255.0],
[255.0, 255.0, 0.0], [255.0, 255.0, 255.0]]
#-------... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #OCaml | OCaml | open Graphics
let () =
open_graph "";
let width = size_x ()
and height = size_y () in
let colors = [| black; red; green; blue; magenta; cyan; yellow; white |] in
let num_colors = Array.length colors in
let h = height / 4 in
for i = 1 to 4 do
let j = 4 - i in
for x = 0 to pred width do
set_... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Raku | Raku | use GD::Raw;
my $file = '/tmp/one-pixel-screen-capture.png';
qqx/screencapture -R 123,456,1,1 $file/;
my $fh = fopen($file, "rb") or die;
my $image = gdImageCreateFromPng($fh);
my $pixel = gdImageGetPixel($image, 0, 0);
my ($red,$green,$blue) =
gdImageRed( $image, $pixel),
gdImageGreen($image, $pixel)... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #REXX | REXX | /*REXX program obtains the cursor position (within it's window) and displays it's color.*/
parse value cursor() with r c . /*get cursor's location in DOS screen. */
hue=scrRead(r, c, 1, 'A') /*get color of the cursor's location. */
if hue=='00'x then color= 'black' ... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Run_BASIC | Run BASIC | ' -----------------------------------
' color wheel
' -----------------------------------
global pi
pi = 22 / 7
steps = 1
graphic #g, 525, 525
for x =0 to 525 step steps
for y =0 to 525 step steps
angle = atan2(y - 250, x - 250) * 360 / 2 / pi ' full degrees....
sector = int(angle / 60) ... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Rust | Rust | // [dependencies]
// image = "0.23"
use image::error::ImageResult;
use image::{Rgb, RgbImage};
fn hsv_to_rgb(h: f64, s: f64, v: f64) -> Rgb<u8> {
let hp = h / 60.0;
let c = s * v;
let x = c * (1.0 - (hp % 2.0 - 1.0).abs());
let m = v - c;
let mut r = 0.0;
let mut g = 0.0;
let mut b = 0.0... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Sidef | Sidef | require('Imager')
var (width, height) = (300, 300)
var center = Complex(width/2 , height/2)
var img = %O<Imager>.new(xsize => width, ysize => height)
for y=(^height), x=(^width) {
var vector = (center - x - y.i)
var magnitude = (vector.abs * 2 / width)
var direction = ((Num.pi + atan2(vector.real, ... |
http://rosettacode.org/wiki/Combinations | Combinations | Task
Given non-negative integers m and n, generate all size m combinations of the integers from 0 (zero) to n-1 in sorted order (each combination is sorted and the entire table is sorted).
Example
3 comb 5 is:
0 1 2
0 1 3
0 1 4
0 2 3
0 2 4
0 3 4
1 2 3
1 2 4
1 3 4
2 3 4
... | #Bracmat | Bracmat | (comb=
bvar combination combinations list m n pat pvar var
. !arg:(?m.?n)
& ( pat
= ?
& !combinations (.!combination):?combinations
& ~
)
& :?list:?combination:?combinations
& whl
' ( !m+-1:~<0:?m
& chu$(utf$a+!m):?var
& glf$('(%@?.$var)):(=?pvar)
... |
http://rosettacode.org/wiki/Conditional_structures | Conditional structures | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Task
List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions.
Common conditional structures include ... | #MBS | MBS | INT x;
x:=0;
IF x = 1 THEN
! Do something
ELSE
! Do something else
ENDIF; |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #Perl | Perl | # this is commented |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #Phix | Phix | -- This is a comment
|
http://rosettacode.org/wiki/Color_quantization | Color quantization | full color
Example: Gimp 16 color
Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace. There... | #OCaml | OCaml | let rem_from rem from =
List.filter ((<>) rem) from
let float_rgb (r,g,b) = (* prevents int overflow *)
(float r, float g, float b)
let round x =
int_of_float (floor (x +. 0.5))
let int_rgb (r,g,b) =
(round r, round g, round b)
let rgb_add (r1,g1,b1) (r2,g2,b2) =
(r1 +. r2,
g1 +. g2,
b1 +. b2)
... |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #Z80_Assembly | Z80 Assembly | ;MSX Bios calls
CHPUT equ 000A2H ;print character A
CHGET equ 0009FH ;wait for keyboard input
INITXT equ 0006CH ;init TEXT1 mode (40 x 24), based on TXTNAM,TXTCGP and LINL40
LDIRVM equ 0005CH ;write BC times MEM(HL++) to VRAM(DE++)
;MSX system variables
TXTNAM equ... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #Perl | Perl | #!/usr/bin/perl -w
use strict ;
use GD ;
my $image = new GD::Image( 320 , 240 ) ;
my %colors = ( "white" => [ 255 , 255 , 255 ] , "red" => [255 , 0 , 0 ] ,
"green" => [ 0 , 255 , 0 ] , "blue" => [ 0 , 0 , 255 ] ,
"magenta" => [ 255 , 0 , 255 ] , "yellow" => [ 255 , 255 , 0 ] ,
"cyan" => [ 0 , 255 ,... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Ring | Ring |
# Project : Color of a screen pixel
Load "gamelib.ring"
r = 0
g = 0
b = 0
al_init()
al_init_image_addon()
display = al_create_display(1000,800)
al_set_target_bitmap(al_get_backbuffer(display))
al_clear_to_color(al_map_rgb(255,255,255))
image = al_load_bitmap("stock.jpg")
al_draw_rotated_bitmap(image,0,0,250,250,150... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Ruby | Ruby | module Screen
IMPORT_COMMAND = '/usr/bin/import'
# Returns an array with RGB values for the pixel at the given coords
def self.pixel(x, y)
if m = `#{IMPORT_COMMAND} -silent -window root -crop 1x1+#{x.to_i}+#{y.to_i} -depth 8 txt:-`.match(/\((\d+),(\d+),(\d+)\)/)
m[1..3].map(&:to_i)
else
fals... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Scala | Scala | def getColorAt(x: Int, y: Int): Color = new Robot().getPixelColor(x, y) |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Smart_BASIC | Smart BASIC | ' Runs on iOS
GET SCREEN SIZE sw,sh
xmax=0.45*3/7*(sw+sh)
x0=sw/2!y0=sh/2
twopi=2*3.1415926
GRAPHICS
GRAPHICS CLEAR
DIM triX(1000), triY(1000)
triX(0)=x0 ! triY(0)=y0
steps=INT(1^2*360)+1
dAngle=twopi/steps
dAngle2=dAngle/2
REFRESH OFF
FOR i=0 TO steps-1
pal(i/steps+TintOffset)
ANGLE=i*dAngle
FILL COLOR pal.r,pal... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Wren | Wren | import "graphics" for Canvas, Color
import "dome" for Window
import "random" for Random
class Game {
static init() {
Window.title = "Color Wheel"
__width = 640
__height = 640
Window.resize(__width, __height)
Canvas.resize(__width, __height)
colorWheel()
}
... |
http://rosettacode.org/wiki/Combinations | Combinations | Task
Given non-negative integers m and n, generate all size m combinations of the integers from 0 (zero) to n-1 in sorted order (each combination is sorted and the entire table is sorted).
Example
3 comb 5 is:
0 1 2
0 1 3
0 1 4
0 2 3
0 2 4
0 3 4
1 2 3
1 2 4
1 3 4
2 3 4
... | #C | C | #include <stdio.h>
/* Type marker stick: using bits to indicate what's chosen. The stick can't
* handle more than 32 items, but the idea is there; at worst, use array instead */
typedef unsigned long marker;
marker one = 1;
void comb(int pool, int need, marker chosen, int at)
{
if (pool < need + at) return; /* n... |
http://rosettacode.org/wiki/Conditional_structures | Conditional structures | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Task
List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions.
Common conditional structures include ... | #MDL | MDL | <COND (<==? .X 1> <PRINC "one">)
(<==? .X 2> <PRINC "two">)
(T <PRINC "something else">)> |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #PHP | PHP | # this is commented
// this is commented |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #Picat | Picat |
/*
* Multi-line comment
*/
% Single-line Prolog-style comment
|
http://rosettacode.org/wiki/Color_quantization | Color quantization | full color
Example: Gimp 16 color
Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace. There... | #Perl | Perl | use strict;
use warnings;
use Imager;
my $img = Imager->new;
$img->read(file => 'frog.png');
my $img16 = $img->to_paletted({ max_colors => 16});
$img16->write(file => "frog-16.png") |
http://rosettacode.org/wiki/Color_quantization | Color quantization | full color
Example: Gimp 16 color
Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace. There... | #Phix | Phix | -- demo\rosetta\Color_quantization.exw
include pGUI.e
function makeCluster(sequence pixels)
sequence rs = vslice(pixels,1),
gs = vslice(pixels,2),
bs = vslice(pixels,3)
integer n = length(pixels),
rd = max(rs)-min(rs),
gd = max(gs)-min(gs),
bd = ma... |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #Yabasic | Yabasic | // Conway's_Game_of_Life
X = 59 : Y = 35 : H = 4
open window X*H,Y*H
backcolor 0, 0, 0
dim c(X,Y) : dim cn(X,Y) : dim cl(X,Y)
// Thunderbird methuselah
c(X/2-1,Y/3+1) = 1 : c(X/2,Y/3+1) = 1 : c(X/2+1,Y/3+1) = 1
c(X/2,Y/3+3) = 1 : c(X/2,Y/3+4) = 1 : c(X/2,Y/3+5) = 1
s = 0
repeat
clear window
alive = ... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #Phix | Phix | --
-- demo\rosetta\Colour_pinstripe.exw
-- =================================
--
with javascript_semantics -- but not yet CD_PRINTER
include pGUI.e
constant colours = {CD_BLACK, CD_RED, CD_GREEN, CD_MAGENTA, CD_CYAN, CD_YELLOW, CD_WHITE}
--constant colours = {CD_BLACK, CD_WHITE}
procedure draw_to(cdCanvas cdcanvas)
... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Smalltalk | Smalltalk | Display rootView colorAt:(10@10).
Display rootView colorAt:(Display pointerPosition) |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Standard_ML | Standard ML | open XWindows ;
val disp = XOpenDisplay "" ;
val im =
let
val pos = #4 (XQueryPointer (RootWindow disp)) ;
in
XGetImage (RootWindow disp) (MakeRect pos (AddPoint(pos,XPoint{x=1,y=1})) ) AllPlanes ZPixmap
end;
XGetPixel disp im (XPoint {x=0,y=0}) ; |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Tcl | Tcl | package require Tcl 8.5
package require Tk
# Farm out grabbing the screen to an external program.
# If it was just for a Tk window, we'd use the tkimg library instead
proc grabScreen {image} {
set pipe [open {|xwd -root -silent | convert xwd:- ppm:-} rb]
$image put [read $pipe]
close $pipe
}
# Get the RGB... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #XPL0 | XPL0 | def Radius = 480/2;
real Hue, Sat, Dist, I, F, P, Q, T;
real XX, YY, RR, GG, BB;
int X, Y, R, G, B;
def Pi = 3.141592654;
def V = 1.; \Value
[SetVid($112); \640x480x24 graphics
for Y:= -Radius to Radius do
for X:= -Radius to Radius do
[XX:= float(X);
YY:= float(Y);
... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #zkl | zkl | var w=300,h=300,out=PPM(w,h);
colorWheel(out);
out.writeJPGFile("colorWheel.zkl.jpg");
fcn colorWheel(ppm){
zero,R:=ppm.w/2, zero;
foreach x,y in (w,h){
v,hue:=(x - zero).toFloat().toPolar(y - zero);
if(v<=R){ // only render in the circle
if((hue = hue.toDeg())<0) hue+=360; // (-pi..pi] to [0... |
http://rosettacode.org/wiki/Combinations | Combinations | Task
Given non-negative integers m and n, generate all size m combinations of the integers from 0 (zero) to n-1 in sorted order (each combination is sorted and the entire table is sorted).
Example
3 comb 5 is:
0 1 2
0 1 3
0 1 4
0 2 3
0 2 4
0 3 4
1 2 3
1 2 4
1 3 4
2 3 4
... | #C.23 | C# | using System;
using System.Collections.Generic;
public class Program
{
public static IEnumerable<int[]> Combinations(int m, int n)
{
int[] result = new int[m];
Stack<int> stack = new Stack<int>();
stack.Push(0);
while (stack.Count > 0)
{
... |
http://rosettacode.org/wiki/Conditional_structures | Conditional structures | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Task
List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions.
Common conditional structures include ... | #Metafont | Metafont | if conditionA:
% do something
elseif conditionB:
% do something
% more elseif, if needed...
else:
% do this
fi; |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #PicoLisp | PicoLisp | # The rest of the line is ignored
#{
This is a
multiline comment
}#
NIL
Immediately stop reading this file. Because all text in the input file following
a top-level 'NIL' is ignored.
This is typically used conditionally, with a read-macro expression like
`*Dbg
so that this text is only read if in debugging mode... |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #Pike | Pike | // This is a comment.
/* This is a
multi
line
comment */
int e = 3; // end-of-statement comment. |
http://rosettacode.org/wiki/Color_quantization | Color quantization | full color
Example: Gimp 16 color
Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace. There... | #PureBasic | PureBasic |
; ColorQuantization.pb
Structure bestA_ ; table for our histogram
nn.i ; 16,32,...
rc.i ; red count within (0,1,...,255)/(number of colors)
gc.i ; green count within (0,1,...,255)/(number of colors)
bc.i ; blue count within (0,1,...,255)/(number of colors)
EndStructure
; these two functions appear to be rather... |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #zkl | zkl | class Life{
fcn init(n, r1,c1, r2,c2, etc){
var N=n, cells=Data(n*n), tmp=Data(n*n),
ds=T(T(-1,-1),T(-1,0),T(-1,1), T(0,-1),T(0,1), T(1,-1),T(1,0),T(1,1));
icells:=vm.arglist[1,*];
(N*N).pump(Void,cells.append.fpM("1-",0)); // clear board
icells.pump(Void,Void.Read,fcn(row,col){ cells... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #PicoLisp | 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) .) )
(let Ppm # Create PPM of 384 x 288 pixels
(make
(for N 4
(let L
(make
(do (/ 384 N)
(le... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #Plain_English | Plain English | To run:
Start up.
Clear the screen.
Imagine a box with the screen's left and the screen's top and the screen's right and the screen's bottom divided by 4.
Make a color pinstripe given 1 pixel and the box.
Draw the color pinstripe.
Draw the next color pinstripe given the color pinstripe.
Draw the next color pinstripe gi... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #PureBasic | 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
If numColors < 1: numColors = ArraySize(psColors()) + 1: EndIf
imgID = CreateImage(#P... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Wren | Wren | import "dome" for Window, Process
import "graphics" for Canvas, Color
import "input" for Mouse
class Game {
static init() {
Window.title = "Color of a screen pixel"
Canvas.cls(Color.orange) // {255, 163, 0} in the default palette
}
static update() {
// report location and color o... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #XPL0 | XPL0 | code ReadPix=44;
int Color, X, Y;
Color:= ReadPix(X, Y); |
http://rosettacode.org/wiki/Combinations | Combinations | Task
Given non-negative integers m and n, generate all size m combinations of the integers from 0 (zero) to n-1 in sorted order (each combination is sorted and the entire table is sorted).
Example
3 comb 5 is:
0 1 2
0 1 3
0 1 4
0 2 3
0 2 4
0 3 4
1 2 3
1 2 4
1 3 4
2 3 4
... | #C.2B.2B | C++ | #include <algorithm>
#include <iostream>
#include <string>
void comb(int N, int K)
{
std::string bitmask(K, 1); // K leading 1's
bitmask.resize(N, 0); // N-K trailing 0's
// print integers and permute bitmask
do {
for (int i = 0; i < N; ++i) // [0..N-1] integers
{
if (bit... |
http://rosettacode.org/wiki/Conditional_structures | Conditional structures | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Task
List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions.
Common conditional structures include ... | #min | min | (true) ("I'm true") ("I'm false") if ; If first quotation evaluates to true,
; evaluate second quotation.
; Otherwise, evaluate the third.
(true) ("I'm true") when ; If without the false quotation.
(true) ("I'm false") unless ... |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #PL.2FI | PL/I | /* This is a comment. */ |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #PL.2FSQL | PL/SQL | --this is a single line comment |
http://rosettacode.org/wiki/Color_quantization | Color quantization | full color
Example: Gimp 16 color
Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace. There... | #Python | Python | from PIL import Image
if __name__=="__main__":
im = Image.open("frog.png")
im2 = im.quantize(16)
im2.show() |
http://rosettacode.org/wiki/Color_quantization | Color quantization | full color
Example: Gimp 16 color
Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace. There... | #Racket | Racket |
#lang racket/base
(require racket/class
racket/draw)
;; This is an implementation of the Octree Quantization algorithm. This implementation
;; follows the sketch in:
;;
;; Dean Clark. Color Quantization using Octrees. Dr. Dobbs Portal, January 1, 1996.
;; http://www.ddj.com/184409805
;;
;; This code is... |
http://rosettacode.org/wiki/Colour_bars/Display | Colour bars/Display | Task
Display a series of vertical color bars across the width of the display.
The color bars should either use:
the system palette, or
the sequence of colors:
black
red
green
blue
magenta
cyan
yellow
white
| #6502_Assembly | 6502 Assembly | lda #0
tax
tay ;clear regs
;video ram on Easy6502 is four pages ranging from $0200-$0500
loop:
sta $0200,x
sta $0220,x
sta $0240,x
sta $0260,x
sta $0280,x
sta $02A0,x
sta $02C0,x
sta $02E0,x
sta $0300,x
sta $0320,x
sta $0340,x
sta $0360,x
sta $0380,x
sta $03A0,x
sta $03C0,x
sta $03E0,x
sta $0400,x
sta $0... |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #ZPL | ZPL | program Life;
config var
n : integer = 100;
region
BigR = [0 .. n+1, 0 .. n+1];
R = [1 .. n, 1 .. n ];
direction
nw = [-1, -1]; north = [-1, 0]; ne = [-1, 1];
west = [ 0, -1]; east = [ 0, 1];
sw = [ 1, -1]; south = [ 1, 0]; se = [ 1, 1];
var
TW... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #Python | Python |
from turtle import *
colors = ["black", "red", "green", "blue", "magenta", "cyan", "yellow", "white"]
# Middle of screen is 0,0
screen = getscreen()
left_edge = -screen.window_width()//2
right_edge = screen.window_width()//2
quarter_height = screen.window_height()//4
half_height = quarter_height * 2
s... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #QBasic | QBasic | SCREEN 12
w = 640: h = 480
h = h / 4
y2 = h - 1
FOR i = 1 TO 4
col = 0
y = (i - 1) * h
FOR x = 1 TO w STEP i
IF col MOD 15 = 0 THEN col = 0
LINE (x, y)-(x + i, y + h), col, BF
col = col + 1
NEXT x
NEXT i |
http://rosettacode.org/wiki/Combinations | Combinations | Task
Given non-negative integers m and n, generate all size m combinations of the integers from 0 (zero) to n-1 in sorted order (each combination is sorted and the entire table is sorted).
Example
3 comb 5 is:
0 1 2
0 1 3
0 1 4
0 2 3
0 2 4
0 3 4
1 2 3
1 2 4
1 3 4
2 3 4
... | #Clojure | Clojure | (defn combinations
"If m=1, generate a nested list of numbers [0,n)
If m>1, for each x in [0,n), and for each list in the recursion on [x+1,n), cons the two"
[m n]
(letfn [(comb-aux
[m start]
(if (= 1 m)
(for [x (range start n)]
(list x))
(for [x (range start n)
xs (comb-aux (d... |
http://rosettacode.org/wiki/Conditional_structures | Conditional structures | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Task
List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions.
Common conditional structures include ... | #MiniScript | MiniScript | x = 42
if x < 10 then
print "small"
else if x < 20 then
print "small-ish"
else if x > 100 then
print "large"
else
print "just right"
end if |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #Plain_English | Plain English | \A comment like this lasts until the end of the line
Put 1 plus [there are inline comments too] 1 into a number. |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #Plain_TeX | Plain TeX | % this is a comment
This is not. |
http://rosettacode.org/wiki/Color_quantization | Color quantization | full color
Example: Gimp 16 color
Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace. There... | #Raku | Raku | use MagickWand;
use MagickWand::Enums;
my $frog = MagickWand.new;
$frog.read("./Quantum_frog.png");
$frog.quantize(16, RGBColorspace, 0, True, False);
$frog.write('./Quantum-frog-16-perl6.png'); |
http://rosettacode.org/wiki/Color_quantization | Color quantization | full color
Example: Gimp 16 color
Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace. There... | #Sidef | Sidef | require('Image::Magick')
func quantize_image(n = 16, input, output='output.png') {
var im = %O<Image::Magick>.new
im.Read(input)
im.Quantize(colors => n, dither => 1) # 1 = None
im.Write(output)
}
quantize_image(input: 'Quantum_frog.png') |
http://rosettacode.org/wiki/Colour_bars/Display | Colour bars/Display | Task
Display a series of vertical color bars across the width of the display.
The color bars should either use:
the system palette, or
the sequence of colors:
black
red
green
blue
magenta
cyan
yellow
white
| #Action.21 | Action! | PROC Main()
BYTE
i,
CH=$02FC, ;Internal hardware value for last key pressed
PALNTSC=$D014, ;To check if PAL or NTSC system is used
PCOLR0=$02C0,PCOLR1=$02C1,
PCOLR2=$02C2,PCOLR3=$02C3,
COLOR0=$02C4,COLOR1=$02C5,
COLOR2=$02C6,COLOR3=$02C7,
COLOR4=$02C8
Graphics(10)
PCOLR0=$04 ;gra... |
http://rosettacode.org/wiki/Colour_bars/Display | Colour bars/Display | Task
Display a series of vertical color bars across the width of the display.
The color bars should either use:
the system palette, or
the sequence of colors:
black
red
green
blue
magenta
cyan
yellow
white
| #ActionScript | ActionScript |
package {
import flash.display.Sprite;
import flash.events.Event;
public class ColourBars extends Sprite {
public function ColourBars():void {
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = nul... |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #ZX_Spectrum_Basic | ZX Spectrum Basic | 10 REM Initialize
20 LET w=32*22
30 DIM w$(w): DIM n$(w)
40 FOR n=1 TO 100
50 LET w$(RND*w+1)="O"
60 NEXT n
70 REM Loop
80 FOR i=34 TO w-34
90 LET p$="": LET d=0
100 LET p$=p$+w$(i-1)+w$(i+1)+w$(i-33)+w$(i-32)+w$(i-31)+w$(i+31)+w$(i+32)+w$(i+33)
110 LET n$(i)=w$(i)
120 FOR n=1 TO LEN p$
130 IF p$(n)="O" THEN LET d=d+1
... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #Racket | Racket |
#lang racket/gui
(define-values [W H] (get-display-size #t))
(define parts 4)
(define colors
'("Black" "Red" "Green" "Blue" "Magenta" "Cyan" "Yellow" "White"))
(define (paint-pinstripe canvas dc)
(send dc set-pen "black" 0 'transparent)
(send dc set-brush "black" 'solid)
(define H* (round (/ H parts)))
... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #Raku | Raku | my ($x,$y) = 1280, 720;
my @colors = map -> $r, $g, $b { [$r, $g, $b] },
0, 0, 0,
255, 0, 0,
0, 255, 0,
0, 0, 255,
255, 0, 255,
0, 255, 255,
255, 255, 0,
255, 255, 255;
my $img = open "pinstripes.ppm", :w orelse die "Can't create pinstripes.ppm: $_";
$img.print: qq:... |
http://rosettacode.org/wiki/Combinations | Combinations | Task
Given non-negative integers m and n, generate all size m combinations of the integers from 0 (zero) to n-1 in sorted order (each combination is sorted and the entire table is sorted).
Example
3 comb 5 is:
0 1 2
0 1 3
0 1 4
0 2 3
0 2 4
0 3 4
1 2 3
1 2 4
1 3 4
2 3 4
... | #CLU | CLU | % generate the size-M combinations from 0 to n-1
combinations = iter (m, n: int) yields (sequence[int])
if m<=n then
state: array[int] := array[int]$predict(1, m)
for i: int in int$from_to(0, m-1) do
array[int]$addh(state, i)
end
i: int := m
while i>0 do
... |
http://rosettacode.org/wiki/Conditional_structures | Conditional structures | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Task
List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions.
Common conditional structures include ... | #.D0.9C.D0.9A-61.2F52 | МК-61/52 | x=0 XX
x#0 XX
x>=0 XX
x<0 XX |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #Pop11 | Pop11 | ;;; This is a comment |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #PostScript | PostScript |
%This is a legal comment in PostScript
|
http://rosettacode.org/wiki/Color_quantization | Color quantization | full color
Example: Gimp 16 color
Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace. There... | #Tcl | Tcl | package require Tcl 8.6
package require Tk
proc makeCluster {pixels} {
set rmin [set rmax [lindex $pixels 0 0]]
set gmin [set gmax [lindex $pixels 0 1]]
set bmin [set bmax [lindex $pixels 0 2]]
set rsum [set gsum [set bsum 0]]
foreach p $pixels {
lassign $p r g b
if {$r<$rmin} {set rmin $r} else... |
http://rosettacode.org/wiki/Colour_bars/Display | Colour bars/Display | Task
Display a series of vertical color bars across the width of the display.
The color bars should either use:
the system palette, or
the sequence of colors:
black
red
green
blue
magenta
cyan
yellow
white
| #Ada | Ada | with SDL.Video.Windows.Makers;
with SDL.Video.Renderers.Makers;
with SDL.Video.Palettes;
with SDL.Events.Events;
with SDL.Events.Keyboards;
procedure Colour_Bars_Display is
use type SDL.Events.Event_Types;
use SDL.C;
Colours : constant array (0 .. 7) of SDL.Video.Palettes.Colour :=
((0, 0, 0, 255), ... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #Ring | Ring |
# Project : Colour pinstripe/Display
load "guilib.ring"
paint = null
new qapp
{
win1 = new qwidget() {
setwindowtitle("archimedean spiral")
setgeometry(100,100,500,600)
label1 = new qlabel(win1) {
setgeometry(10... |
http://rosettacode.org/wiki/Colour_pinstripe/Display | Colour pinstripe/Display | The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.
The pinstripes should either follow the system palette sequence, or a sequence that includes:
black, red, green, blue, magenta, cyan, yellow, and ... | #Scala | Scala | import java.awt.Color._
import java.awt._
import javax.swing._
object ColourPinstripeDisplay extends App {
private def palette = Seq(black, red, green, blue, magenta, cyan, yellow, white)
SwingUtilities.invokeLater(() =>
new JFrame("Colour Pinstripe") {
class ColourPinstripe_Display extends JPanel... |
Subsets and Splits
Rosetta Code COBOL Python Hard Tasks
Identifies and retrieves challenging tasks that exist in both COBOL and Python, revealing cross-language programming patterns and difficulty levels for comparative analysis.
Rosetta Code Task Comparisons
Identifies tasks common to both COBOL and Python languages that are described as having difficulty levels, revealing cross-language task similarities and providing useful comparative programming examples.
SQL Code Examples from Training Data
Retrieves raw SQL code examples for the SQL language, which is basic data retrieval without meaningful analysis or patterns.
SQL Code Examples from Training Data
Retrieves raw SQL code examples for the SQL language, which is basic filtering that shows what data looks like but doesn't provide meaningful analysis or patterns.
Select Specific Languages Codes
Retrieves specific programming language names and codes from training data, providing basic filtering but limited analytical value beyond identifying these particular languages.