Skip to content

Instantly share code, notes, and snippets.

View zeffii's full-sized avatar

Dealga McArdle zeffii

View GitHub Profile
@zeffii
zeffii / less_liberal_indentation.py
Created August 15, 2011 09:28
sharp from uv isles
# ##### 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 / insert_empty_at_world_location.py
Last active September 26, 2015 21:28
insert empty at selected vertices of a mesh, mesh must be back in object mode
# must select 3 verts.
import bpy
#from mathutils import Vector, Quaternion
ob = bpy.context.object
# needs to be in object mode to check the status, i think?
# check if 3 verts selected.
selected_idx = [i.index for i in ob.data.vertices if i.select]
@zeffii
zeffii / named_tuple_example.py
Created August 26, 2011 09:04
namedtuple example
# http://docs.python.org/library/collections.html
# note to self
import collections
from collections import namedtuple
Robot = namedtuple('Robot', 'base, hinge1, arm_len, hinge2, wrist, hand')
Robot.base = 260
Robot.hinge1 = 20
Robot.arm_len = 120
@zeffii
zeffii / auto_class_example.py
Created August 28, 2011 11:20
alternative to namedtuple is auto_class
# as suggested and clarified by Campbell Barton, in the first response to this post.
# Here's an example of a helper function to do new classes that work like named tuples
# ----
# 1 liner for making new named tuple like classes
def auto_class(name, slots): return type(name, (object, ), {"__slots__": slots})
mytype = auto_class("TrickyClass", ("blah", "whee", "whoo"))
t = mytype()
@zeffii
zeffii / myScript.js
Created October 12, 2011 15:16
descriptor test
var textblock_one = new Array("Line 1", "Line 2", "Line 3", "Line 4");
var textblock_two = new Array("Line 01", "Line 02", "Line 03", "Line 04", "more lines");
var textblock_three = new Array("Line 001", "Line 002", "Line 003", "Line 004");
var thisLineHeight = 18;
var fontSizeValue = 16;
var myDecoratorColour = '#555555';
var myTextColour = '#333333';
@zeffii
zeffii / resource.js
Created October 12, 2011 18:34
Displaying a raster image
<div class="resource">
<img width="260" height="399" src="/path/imagename.extention" id="imaginename" class="hidden">
</div>
// next thing to try is access this rasterized image.
// like with : http://paperjs.org/tutorials/images/working-with-rasters/
@zeffii
zeffii / image_raster_loading.html
Created October 12, 2011 19:17
loading an image
<!DOCTYPE html>
<html>
<head>
<!-- Load the Paper.js library -->
<script type="text/javascript" src="js/paper.js"></script>
<!-- Load external PaperScript and associate it with myCanvas -->
<script type="text/paperscript" src="js/v2_MyScript.js" canvas="myCanvas">
</script>
</head>
@zeffii
zeffii / v2_MyScript.js
Created October 12, 2011 19:21
short declaration of imgtest rasterized image
function displayImage(){
// Create a raster item using the image tag with id='mona'
var raster = new Raster('imgtest');
// Move the raster to the center of the view
raster.position = view.center; // or some integer.
}
displayImage();
@zeffii
zeffii / portfolio_typography.js
Created October 29, 2011 12:37
some typographic approach, reminds me of CNC style G codes.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Stroke Bounds</title>
<link rel="stylesheet" href="../css/style.css">
<script type="text/javascript" src="../../lib/paper.js"></script>
<script type="text/paperscript" canvas="canvas">
@zeffii
zeffii / example_user_display.html
Created November 7, 2011 16:11
Simple Graphical Display of a Progress Report
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Apt Progress</title>
<link rel="stylesheet" href="../css/style.css">
<script type="text/javascript" src="../../lib/paper.js"></script>
<script type="text/paperscript" canvas="canvas">
/*