Skip to content

Instantly share code, notes, and snippets.

Avatar

Davor Hrg hrgdavor

  • RGO communications
  • Croatia
View GitHub Profile
@hrgdavor
hrgdavor / fruit.js
Created Oct 10, 2021
test fruit holder
View fruit.js
const jscad = require('@jscad/modeling')
const { cube, cuboid, cylinder, cylinderElliptic, ellipsoid, geodesicSphere, roundedCuboid, roundedCylinder, sphere, torus } = jscad.primitives
const { translate ,rotate} = jscad.transforms
const { colorize } = jscad.colors
const { union, subtract, intersect } = jscad.booleans
const { degToRad } = jscad.utils
const { hull, hullChain } = jscad.hulls
const getParameterDefinitions = () => {
return [
View index.css
/*bug-in-github-api-content-can-not-be-empty*/
@hrgdavor
hrgdavor / tesseract.jscad
Created Jan 23, 2021
Configurable hypercube(tesseract) for 3D print
View tesseract.jscad
/*
Configurable hypercube(tesseract) https://en.wikipedia.org/wiki/Tesseract
Used it for 3D printing for a friend and to play with jscad.
@author Davor Hrg (https://github.com/hrgdavor)
*/
const {primitives, transforms, maths, extrusions, geometries} = require('@jscad/modeling')
View towel_hanger.js
/*
.\_dev_build\watch_dev.bat -l .\_useful\towel_hnager.jscad
*/
var _parameters = [
{name:'pipeDiameter',caption:'Pipe diameter', type:'int', initial:23},
{name:'pipeDistance',caption:'Pipe distance', type:'int', initial:36},
{name:'width',caption:'width', type:'int', initial:10},
{name:'thick',caption:'Thickness', type:'float', initial:3.5},
{name:'preview',caption:'Preview', type:'checkbox', checked:false},
];
@hrgdavor
hrgdavor / testCylinderFromTo.js
Last active Nov 1, 2020
openjscad utility cylinderFromTo
View testCylinderFromTo.js
const jscad = require('@jscad/modeling')
const { connectors, geometry, math, primitives, text, utils, booleans, expansions, extrusions, hulls, measurements, transforms } = jscad
const { translate, scale, center, rotate } = transforms
const { cuboid, sphere, cylinder, circle, star,cylinderElliptic } = jscad.primitives
function main(){
var ret = [];
function testCylinderFromTo(p1,p2){
ret = [ ...ret,
@hrgdavor
hrgdavor / rounded_top.js
Last active Oct 6, 2020
openjscad V2 rounded top
View rounded_top.js
/**
* Extrude rounded top From Slices
* @description Demonstrating the advanced extrusion using slices to create rounded top
* @tags extrude, slice, slices, extrudefromslices, callback
* @authors Davor Hrg
* @licence MIT License
*/
const { circle, square, roundedRectangle } = require('@jscad/modeling').primitives
@hrgdavor
hrgdavor / organizers.js
Last active Sep 24, 2020
OpenJSCAD example, spoon organizers
View organizers.js
var funcs = {};
function getParameterDefinitions() {
var defs = [];
defs.push({
name:'piece',
caption:'Piece', type:'choice',
values: [
'funcs.Spoon_Small',
View cable.protect.jscad
var len = 200;
var off = 2.5;
function main() {
return shape().subtract(holes()).translate([-100,-25,0]);
// return
}
function shape(){
return prism(len,25,10).union([
@hrgdavor
hrgdavor / TestBitMask.java
Last active May 4, 2017
java Example of generating bit masks with "ones" one the left or on the right // ((1<<x)-1) // (-1<<x)
View TestBitMask.java
public class TestBitMask {
public static void main(String[] args) throws Exception{
System.out.println("Java integer bit mask example");
System.out.println();
System.out.println("Zeroes on the left and x ones on the right. Formula: ((1<<x)-1)");
for(int x=1; x<32;x++) {
System.out.println(x+"\t "+padRight( ((1<<x)-1) ,12) +""+intBitsSpaced(((1<<x)-1)));
}
@hrgdavor
hrgdavor / Bits.java
Last active Apr 25, 2017
java convert long to 64 bits(0|1) string
View Bits.java
public class Bits{
public static void main(String[] args){
long val = -12435L;
System.out.println(longBits(val));
// 1111111111111111111111111111111111111111111111111100111101101101
System.out.println(longBitsSpaced(val));
// 11111111 11111111 11111111 11111111 11111111 11111111 11001111 01101101
}