Skip to content

Instantly share code, notes, and snippets.

View yknishidate's full-sized avatar

Yuki Nishidate yknishidate

View GitHub Profile
#include <iostream>
#include <array>
class Particle
{
public:
Particle() : m_frameLeft(0) {}
void init(double x, double y, int lifeTime)
{
// create images
std::vector<vk::Image> images = ...;
// gather information
uint32_t memoryTypeBits = ~0; // 0b11111111...
vk::DeviceSize totalSize = 0;
std::vector<vk::DeviceSize> offsets;
for (auto&& image : images) {
offsets.push_back(totalSize);
#include <chrono>
struct Timer
{
void start()
{
startTime = std::chrono::steady_clock::now();
}
long long elapsed()
struct Array1D
{
float vals[WIDTH];
float& operator[] (int index)
{
return vals[index];
}
};
import math
import random
import matplotlib.pyplot as plt
class UniformDistribution:
def __init__(self, a: float, b: float) -> None:
self.a = a
self.b = b
import math
import random
import matplotlib.pyplot as plt
class UniformDistribution:
def __init__(self, a: float, b: float) -> None:
self.a = a
self.b = b
import math
import random
import matplotlib.pyplot as plt
class UniformDistribution:
def __init__(self, a: float, b: float) -> None:
self.a = a
self.b = b
#include <vector>
#include <iostream>
#include <functional>
struct Obj
{
float speed = 10.0;
float velocity = 1.0;
std::function<void(void)> Update = [](){ };
};
ImGui::StyleColorsDark();
ImVec4 red80 = ImVec4(0.8f, 0.0f, 0.0f, 1.0f);
ImVec4 red60 = ImVec4(0.6f, 0.0f, 0.0f, 1.0f);
ImVec4 red40 = ImVec4(0.4f, 0.0f, 0.0f, 1.0f);
ImVec4 black100 = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
ImVec4 black90 = ImVec4(0.1f, 0.1f, 0.1f, 1.0f);
ImVec4 black80 = ImVec4(0.2f, 0.2f, 0.2f, 1.0f);
ImVec4 black60 = ImVec4(0.4f, 0.4f, 0.4f, 1.0f);
#include <chrono>
#include <vector>
#include <random>
#include <optional>
#include <iostream>
#include <execution>
#include <functional>
void calcTime(const std::function<void(void)>& func)
{