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
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)); | |
} |
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
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] |
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
# ##### 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 |
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
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 |
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
# ##### 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 |
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
# ##### 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 |
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 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 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
# 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 |
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
def point_on_edge(point, edge): | |
A, B = edge | |
eps = (((A - B).length - (point - B).length) - (A - point).length) | |
return abs(eps) < VTX_PRECISION |
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
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) |