Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
47
Task/Draw-a-pixel/Ada/draw-a-pixel.adb
Normal file
47
Task/Draw-a-pixel/Ada/draw-a-pixel.adb
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
with SDL.Video.Windows.Makers;
|
||||
with SDL.Video.Renderers.Makers;
|
||||
with SDL.Events.Events;
|
||||
|
||||
procedure Draw_A_Pixel is
|
||||
|
||||
Width : constant := 320;
|
||||
Height : constant := 200;
|
||||
|
||||
Window : SDL.Video.Windows.Window;
|
||||
Renderer : SDL.Video.Renderers.Renderer;
|
||||
|
||||
procedure Wait is
|
||||
use type SDL.Events.Event_Types;
|
||||
Event : SDL.Events.Events.Events;
|
||||
begin
|
||||
loop
|
||||
while SDL.Events.Events.Poll (Event) loop
|
||||
if Event.Common.Event_Type = SDL.Events.Quit then
|
||||
return;
|
||||
end if;
|
||||
end loop;
|
||||
delay 0.100;
|
||||
end loop;
|
||||
end Wait;
|
||||
|
||||
begin
|
||||
if not SDL.Initialise (Flags => SDL.Enable_Screen) then
|
||||
return;
|
||||
end if;
|
||||
|
||||
SDL.Video.Windows.Makers.Create (Win => Window,
|
||||
Title => "Draw a pixel",
|
||||
Position => SDL.Natural_Coordinates'(X => 10, Y => 10),
|
||||
Size => SDL.Positive_Sizes'(Width, Height),
|
||||
Flags => 0);
|
||||
SDL.Video.Renderers.Makers.Create (Renderer, Window.Get_Surface);
|
||||
Renderer.Set_Draw_Colour ((0, 0, 0, 255));
|
||||
Renderer.Fill (Rectangle => (0, 0, Width, Height));
|
||||
Renderer.Set_Draw_Colour ((255, 0, 0, 255));
|
||||
Renderer.Draw (Point => (100, 100));
|
||||
Window.Update_Surface;
|
||||
|
||||
Wait;
|
||||
Window.Finalize;
|
||||
SDL.Finalise;
|
||||
end Draw_A_Pixel;
|
||||
32
Task/Draw-a-pixel/Odin/draw-a-pixel-1.odin
Normal file
32
Task/Draw-a-pixel/Odin/draw-a-pixel-1.odin
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
import "vendor:sdl2"
|
||||
|
||||
main :: proc() {
|
||||
using sdl2
|
||||
|
||||
window: ^Window = ---
|
||||
renderer: ^Renderer = ---
|
||||
event: Event = ---
|
||||
|
||||
Init(INIT_VIDEO)
|
||||
CreateWindowAndRenderer(
|
||||
640, 480,
|
||||
WINDOW_SHOWN,
|
||||
&window, &renderer
|
||||
)
|
||||
|
||||
SetWindowTitle(window, "Empty window")
|
||||
SetRenderDrawColor(renderer, 50, 255, 100, 255)
|
||||
RenderDrawPoint(renderer, 100, 100)
|
||||
RenderPresent(renderer)
|
||||
|
||||
for event.type != .QUIT {
|
||||
Delay(10)
|
||||
PollEvent(&event)
|
||||
}
|
||||
|
||||
DestroyRenderer(renderer)
|
||||
DestroyWindow(window)
|
||||
Quit()
|
||||
}
|
||||
19
Task/Draw-a-pixel/Odin/draw-a-pixel-2.odin
Normal file
19
Task/Draw-a-pixel/Odin/draw-a-pixel-2.odin
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package main
|
||||
|
||||
import rl "vendor:raylib"
|
||||
|
||||
main :: proc() {
|
||||
rl.InitWindow(320, 240, "Rosetta Code - Draw a pixel")
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.BLACK)
|
||||
|
||||
rl.DrawPixelV({100, 100}, {255, 0, 0, 255})
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
||||
9
Task/Draw-a-pixel/R/draw-a-pixel.r
Normal file
9
Task/Draw-a-pixel/R/draw-a-pixel.r
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
disp_h <- 240
|
||||
disp_w <- 320
|
||||
mat <- matrix(0, nrow = disp_w, ncol = disp_h)
|
||||
mat[100, 100] <- 1
|
||||
png("DrawPixel-R.png", disp_w, disp_h)
|
||||
op <- par(mar = rep(0, 4), mai = rep(0, 4))
|
||||
image(mat, col = c("white", "red"), useRaster = TRUE, axes = FALSE)
|
||||
par(op)
|
||||
dev.off()
|
||||
15
Task/Draw-a-pixel/ReScript/draw-a-pixel-1.res
Normal file
15
Task/Draw-a-pixel/ReScript/draw-a-pixel-1.res
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
type document // abstract type for a document object
|
||||
type context = { mutable fillStyle: string, }
|
||||
|
||||
@val external doc: document = "document"
|
||||
|
||||
@send external getElementById: (document, string) => Dom.element = "getElementById"
|
||||
@send external getContext: (Dom.element, string) => context = "getContext"
|
||||
|
||||
@send external fillRect: (context, int, int, int, int) => unit = "fillRect"
|
||||
|
||||
let canvas = getElementById(doc, "my_canvas")
|
||||
let ctx = getContext(canvas, "2d")
|
||||
|
||||
ctx.fillStyle = "#F00"
|
||||
fillRect(ctx, 100, 100, 1, 1)
|
||||
30
Task/Draw-a-pixel/ReScript/draw-a-pixel-2.res
Normal file
30
Task/Draw-a-pixel/ReScript/draw-a-pixel-2.res
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Draw a Pixel</title>
|
||||
<style rel="stylesheet" type="text/css">
|
||||
body {
|
||||
background-color:#777;
|
||||
}
|
||||
canvas {
|
||||
background-color:#888;
|
||||
margin:60px 120px;
|
||||
border:1px solid #555;
|
||||
box-shadow: -1px 2px 6px 1px rgba(0,0,0,0.3);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<canvas id="my_canvas" width="320" height="240">
|
||||
No support for HTML5 Canvas.<br />
|
||||
</canvas>
|
||||
|
||||
<script type="text/javascript" src="draw.bs.js"></script>
|
||||
|
||||
<noscript>
|
||||
No support for Javascript.<br />
|
||||
</noscript>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
10
Task/Draw-a-pixel/Rebol/draw-a-pixel.rebol
Normal file
10
Task/Draw-a-pixel/Rebol/draw-a-pixel.rebol
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
Rebol [
|
||||
title: "Rosetta code: Draw a pixel"
|
||||
file: %Draw_a_pixel.r3
|
||||
url: https://rosettacode.org/wiki/Draw_a_pixel
|
||||
]
|
||||
|
||||
img: make image! 320x240 ;; Create a new image of size 320x240 pixels
|
||||
img/(100x100): 255.0.0 ;; Set the pixel at position 100x100 to pure red
|
||||
save %test.png img ;; Save the image to a PNG file named "test.png"
|
||||
browse %test.png ;; Open the saved image file using the default browser
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
import gg
|
||||
import gx
|
||||
|
||||
fn main() {
|
||||
mut context := gg.new_context(
|
||||
|
|
@ -12,6 +11,6 @@ fn main() {
|
|||
|
||||
fn frame(mut ctx gg.Context) {
|
||||
ctx.begin()
|
||||
ctx.draw_pixel(100, 100, gx.red)
|
||||
ctx.draw_pixel(100, 100, gg.red)
|
||||
ctx.end()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue