This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Thanks for https://stackoverflow.com/a/72529233/15257426 | |
*/ | |
fun hasBackground(expectedColor: Color, expectedShape: Shape = RectangleShape): SemanticsMatcher = SemanticsMatcher("background color") { | |
it.layoutInfo.getModifierInfo().forEach {info -> | |
println(info.modifier.toString()) | |
} | |
it.layoutInfo.getModifierInfo().any { modifierInfo -> | |
modifierInfo.modifier == Modifier.background(expectedColor, expectedShape) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program sdl_test; | |
uses | |
sdl2, SysUtils, ctypes, Math, SDL_DrawCircles; | |
const | |
Width = 1360; | |
Height = 760; | |
CENTER = SDL_WINDOWPOS_CENTERED; | |
STARS_COUNT = 200; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit SDL_DrawCircles; | |
{$mode objfpc}{$H+} | |
interface | |
uses | |
Classes, SysUtils, sdl2, ctypes; | |
function SDL_RenderFillCircle(renderer: PSDL_Renderer; x: cint32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cnames.structs.SDL_Renderer | |
import cnames.structs.SDL_Window | |
import kotlinx.cinterop.* | |
import platform.SDL2.* | |
typealias EventListener = (SDL_Event) -> Unit | |
class Engine(width: Int, height: Int) { | |
var window: CPointer<SDL_Window> private set |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
SDLEngine(Consts.WIDTH, Consts.HEIGHT) { | |
val fpsCounter = FPSCounter(window) | |
val stars = List(Consts.STARS_COUNT) { Star() } | |
addEventListener("starfield") { event -> | |
if (event.type == SDL_QUIT) stopLoop() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// imports ... | |
const int WIDTH = 1360, HEIGHT = 760; | |
const int H_WIDTH = WIDTH / 2; | |
const int H_HEIGHT = HEIGHT / 2; | |
const int STARS_COUNT = 200; | |
float speed = 0.1; | |
float radius_delta = 0.001; | |
Uint32 fps_lasttime = SDL_GetTicks(); | |
Uint32 fps_frames = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SDL_Init(SDL_INIT_EVERYTHING); | |
SDL_Window *window = SDL_CreateWindow("C++ SDL window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, | |
WIDTH, HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI); | |
if (window == NULL) | |
{ | |
std::cout << "Could not create window: " << SDL_GetError() << std::endl; | |
return 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Star | |
{ | |
float x, y, z, radius, brightness, viewX, viewY; | |
Star() { newStar(); } | |
void newStar() | |
{ | |
x = viewX = std::experimental::randint(0, WIDTH) - H_WIDTH; | |
y = viewY = std::experimental::randint(0, HEIGHT) - H_HEIGHT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import pygame | |
from pygame import gfxdraw | |
SX = 1360 | |
SY = 760 | |
num_stars = 5000 | |
speed = 0.1 | |
radius_delta = 0.001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program primes; | |
uses | |
fgl, SysUtils; | |
type | |
TIntegerList = specialize TFPGList<integer>; | |
function SieveEratosphen(n: integer): TIntegerList; | |
var |
NewerOlder