Skip to content

Instantly share code, notes, and snippets.

View zeffii's full-sized avatar

Dealga McArdle zeffii

View GitHub Profile
@zeffii
zeffii / duplo.nut
Last active August 29, 2015 13:57 — forked from anonymous/duplo.sq
function writeRGBString(tpixel, color)
{
local r = color[0] * BYTESPERCOLOR;
local g = color[1] * BYTESPERCOLOR;
local b = color[2] * BYTESPERCOLOR;
tpixel.writestring(bits.slice(g, g+BYTESPERCOLOR));
tpixel.writestring(bits.slice(r, r+BYTESPERCOLOR));
tpixel.writestring(bits.slice(b, b+BYTESPERCOLOR));
}
@zeffii
zeffii / promonade.py
Last active August 29, 2015 13:57 — forked from anonymous/promonade.py
if isPointOnEdge(vX, vA, vB):
oe[edge_count].vertices = [vc, vc+1]
oe[edge_count+1].vertices = [vc, vc+2]
# find which of C and D is farthest away from X
if mDist(vD, vX) > mDist(vC, vX):
oe[edge_count+2].vertices = [vc, vc+3]
oe[edge_count+3].vertices = [vc+3, vc+4]
if mDist(vC, vX) > mDist(vD, vX):
oe[edge_count+2].vertices = [vc, vc+4]
oe[edge_count+3].vertices = [vc+3, vc+4]
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@zeffii
zeffii / prob.nut
Last active August 29, 2015 13:57 — forked from kgleeson/gist:9493653
const BYTESPERPIXEL = 27;
const BYTESPERCOLOR = 9; // BYTESPERPIXEL / 3
const SPICLK = 7500; // SPI clock speed in kHz
const bits = "\xE0\x70\x38\x1C\x0E\x07\x03\x81\xC0\xE0\x70\x38\x1C\x0E\x07\x03\x81\xF8\xE0\x70\x38\x1C\x0E\x07\x03\xF1\xC0\xE0\x70\x38\x1C\x0E\x07\x03\xF1\xF8\xE0\x70\x38\x1C\x0E\x07\xE3\x81\xC0\xE0\x70\x38\x1C\x0E\x07\xE3\x81\xF8\xE0\x70\x38\x1C\x0E\x07\xE3\xF1\xC0\xE0\x70\x38\x1C\x0E\x07\xE3\xF1\xF8\xE0\x70\x38\x1C\x0F\xC7\x03\x81\xC0\xE0\x70\x38\x1C\x0F\xC7\x03\x81\xF8\xE0\x70\x38\x1C\x0F\xC7\x03\xF1\xC0\xE0\x70\x38\x1C\x0F\xC7\x03\xF1\xF8\xE0\x70\x38\x1C\x0F\xC7\xE3\x81\xC0\xE0\x70\x38\x1C\x0F\xC7\xE3\x81\xF8\xE0\x70\x38\x1C\x0F\xC7\xE3\xF1\xC0\xE0\x70\x38\x1C\x0F\xC7\xE3\xF1\xF8\xE0\x70\x38\x1F\x8E\x07\x03\x81\xC0\xE0\x70\x38\x1F\x8E\x07\x03\x81\xF8\xE0\x70\x38\x1F\x8E\x07\x03\xF1\xC0\xE0\x70\x38\x1F\x8E\x07\x03\xF1\xF8\xE0\x70\x38\x1F\x8E\x07\xE3\x81\xC0\xE0\x70\x38\x1F\x8E\x07\xE3\x81\xF8\xE0\x70\x38\x1F\x8E\x07\xE3\xF1\xC0\xE0\x70\x38\x1F\x8E\x07\xE3\xF1\xF8\xE0\x70\x38\x1F\x8
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
import bpy
import bmesh
obj = bpy.context.active_object
me = obj.data
bm = bmesh.from_edit_mesh(me)
me.update()
edges = bm.edges
ok = lambda v: v.select and not v.hide
# This example assumes we have a mesh object in edit-mode
import bpy
import bmesh
from mathutils import Vector
from mathutils.geometry import intersect_point_line as pt_on_line
# or
# from mathutils.geometry import intersect_point_line as PtLineIntersect
def point_on_edge(point, edge):
A, B = edge
eps = (((A - B).length - (point - B).length) - (A - point).length)
return abs(eps) < VTX_PRECISION
@zeffii
zeffii / mesh_VTXb.py
Last active August 29, 2015 13:57 — forked from anonymous/mesh_VTXb.py
def point_on_edge(p, edge):
'''
> p: vector
> edge: tuple of 2 vectors
< returns: True / False if a point happens to lie on an edge
'''
pt, _percent = PtLineIntersect(p, *edge)
on_line = (pt-p).length < AutoVTX.VTX_PRECISION
return on_line and (0.0 <= _percent <= 1.0)