Skip to content

Instantly share code, notes, and snippets.

View ivanpopelyshev's full-sized avatar

Ivan Popelyshev ivanpopelyshev

View GitHub Profile
export class BlitterRenderState implements core.IPreRenderState {
constructor(public cache: RuntimeCache) {
}
visit(node: Node) {
const vs = node.rendererObject as pixi.VectorSprite;
if (vs && vs.model) {
// && vs.model.preferredCache === pixi.CacheType.RuntimeWebGL ?
this.cache.foundVectors.push(vs);
}
@ivanpopelyshev
ivanpopelyshev / Progress.ts
Created December 6, 2019 12:57
Progress mask
import { Graphics } from "pixi.js";
const angles = [];
export class Progress extends Graphics {
_color: number;
_tWidth: number;
_tHeight: number;
_progress: number;
public invert: boolean = false;
@ivanpopelyshev
ivanpopelyshev / index.js
Last active April 1, 2019 21:18
Old Live2d plugin demo
import {
UtSystem,
UtDebug,
LDTransform,
LDGL,
Live2D,
Live2DModelWebGL,
Live2DModelJS,
Live2DMotion,
MotionQueueManager,
@ivanpopelyshev
ivanpopelyshev / shape.ts
Last active March 31, 2019 11:41
Faster SegmentedPath for Shumway
import PathCommand = Shumway.PathCommand;
import GradientType = Shumway.GradientType;
import GradientSpreadMethod = Shumway.GradientSpreadMethod;
import GradientInterpolationMethod = Shumway.GradientInterpolationMethod;
import Bounds = Shumway.Bounds;
import DataBuffer = Shumway.ArrayUtilities.DataBuffer;
import ShapeData = Shumway.ShapeData;
import ShapeMatrix = Shumway.ShapeMatrix;
import clamp = Shumway.NumberUtilities.clamp;
import assert = Shumway.Debug.assert;
@ivanpopelyshev
ivanpopelyshev / Canvas2DSurface.js
Last active March 20, 2019 13:50
Shumway + WebGL partial texture upload
// Its a custom renderer, pixi fork, it'll be easy to port on vanilla v5
// Careful: Method names differ from V5. Find appropriate fields.
export class Canvas2DSurface implements ISurface, gobi.core.ITextureResource {
width: number;
height: number;
canvas: HTMLCanvasElement;
context: CanvasRenderingContext2D;
private _regionAllocator: RegionAllocator.IRegionAllocator;
export const enum GradientInterpolationMethod {
RGB = 0,
LinearRGB = 1
}
function toSRGB(x: number) {
if (x < 0.00313080) {
return x * 12.92;
}
return Math.pow(x, 1.0 / 2.4) * 1.055 - 0.055;
vec2 invBilinear( in vec2 p, in vec2 a, in vec2 b, in vec2 c, in vec2 d )
{
vec2 e = b-a;
vec2 f = d-a;
vec2 g = a-b+c-d;
vec2 h = p-a;
float k2 = cross2d( g, f );
float k1 = cross2d( e, f ) + cross2d( h, g );
float k0 = cross2d( h, e );
@ivanpopelyshev
ivanpopelyshev / pixi-tween-ticker-hack.js
Created August 4, 2017 12:26
Possible solution for GSAP/tweenlite and pixi integration
PIXI.Ticker.prototype._requestIfNeeded = function()
{
if (!this.gsapTick) {
//do a research, where is the passed time
this.lastTime = performance.now();
this.gsapTick = (event) => { this.update(MILLISECONDS_PASSED_IN_EVENT_I_DONT_KNOW) };
//do a research how to call it after all the other listeners
TweenLite.ticker.addEventListener("tick", this.gsapTick);
}
@ivanpopelyshev
ivanpopelyshev / MiniRunner.ts
Created June 8, 2017 16:12
pixi mini runner in typescript
namespace gobi.core {
export class MiniRunner {
items: Array<object> = [];
private _name: string;
run: Function = null;
get name() {
return this._name;
}
@ivanpopelyshev
ivanpopelyshev / index.html
Created July 30, 2012 22:21
A web page created at CodePen.io.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Canvas Pony &middot; CodePen</title>
<!--
Copyright (c) 2012 ivanpopelyshev, http://codepen.io/ivanpopelyshev
Permission is hereby granted, free of charge, to any person obtaining