Skip to content

Instantly share code, notes, and snippets.

View PsichiX's full-sized avatar
👨‍🔬
For the Symmetry! [mental health vacation]

Patryk Budzyński PsichiX

👨‍🔬
For the Symmetry! [mental health vacation]
View GitHub Profile
@PsichiX
PsichiX / retained_mode.rs
Created October 12, 2023 02:26
RAUI retained mode experiments
use raui::prelude::*;
use raui_quick_start::RauiQuickStartBuilder;
use std::any::Any;
#[derive(Default)]
struct AppView {
pub icons: View<ListView<IconView>>,
}
impl ViewState for AppView {
@PsichiX
PsichiX / raui_view_model_example.rs
Last active October 9, 2023 23:46
RAUI view-model example
use raui::prelude::*;
use raui_quick_start::{
tetra::{input::Key, Event},
RauiQuickStartBuilder,
};
// Name of View-Model instance.
const DATA: &str = "data";
// Name of View-Model property notification.
const COUNTER: &str = "counter";
@PsichiX
PsichiX / test_view_model.rs
Created October 9, 2023 17:19
View-Model usage test
const FOO_VIEW_MODEL: &str = "foo";
const COUNTER_PROPERTY: &str = "counter";
const FLAG_PROPERTY: &str = "flag";
// view-model data type
struct Foo {
// can hold view-model value wrapper that implicitly notifies on mutation.
counter: ViewModelValue<usize>,
// or can hold raw notifiers to explicitly notify.
flag: bool,
@PsichiX
PsichiX / intuicio_gc_integration_test.rs
Last active October 7, 2023 21:38
Intuicio + GC integration test
use gc::{Finalize as GcFinalize, Gc, Trace as GcTrace};
use intuicio_core::prelude::*;
use intuicio_derive::*;
#[intuicio_function(module_name = "test")]
fn add(a: Gc<i32>, b: Gc<i32>) -> Gc<i32> {
let c = *a + *b;
println!("add | {} + {} = {}", *a, *b, c);
Gc::new(c)
}
@PsichiX
PsichiX / 0_raui_hello.rs
Last active December 5, 2020 03:31
RAUI data oriented API (declarative UI)
#[test]
fn test_hello_world() {
// convenient macro that produces widget component processing function.
widget_component! {
// <component name> ( [list of context data to unpack into scope] )
app(key, named_slots) {
// easy way to get widgets from named slots.
unpack_named_slots!(named_slots => { title, content });
// we always return new widgets tree.
@PsichiX
PsichiX / test-cpp.chrobry
Created April 3, 2020 18:02
Data Driven Template engine
// import './serialization.chrobry'
inject
```
#pragma once
#include <string>
#include <sstream>
```
extern 'int' 'float' {
@PsichiX
PsichiX / side.gml
Last active October 16, 2017 20:14
[GML] Calculate if enemy is on the right or right side of our instance
// calcualte position difference (a.k.a. tangent vector):
var dx = enemy.x - x;
var dy = enemy.y - y;
// calculate angle in radians of instance:
var rad = degtorad(image_angle);
// calculate where is instance right side (a.k.a. binormal vector):
var bx = -sin(rad);
var by = cos(rad);
@PsichiX
PsichiX / CarController.cs
Last active June 28, 2017 16:26
car program
using I4.NET;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
namespace I4.Unity.Example
{
@PsichiX
PsichiX / library.cpp
Created June 2, 2017 16:33
Shared Library Manager
#include "library.h"
#ifdef BUILD_LINUX
#include <dlfcn.h>
#endif
#ifdef BUILD_WIN
#include <windows.h>
#endif
#include <map>
struct Handle
@PsichiX
PsichiX / entry.i4s
Created August 16, 2016 01:38
Intuicio4 Protocols Test
#!/usr/bin/env i4s
#intuicio 4.0;
#stack 8k;
#memory 16k;
#entry @Main;
#pointersize 32;
#import from [IO:print] routine print(format:*i8, ...):;
#import from [IO:get_line_new] routine get_line_new():*i8;