Skip to content

Instantly share code, notes, and snippets.

;; bezier_study
;; To Edit the Shape:
;; Click each "segment" at the end
;; of this code and drag the point.
(defn adjust_dir [p p1 p2]
(let [angle (vec2/angle (vec2/- p1 p))
len (vec2/dist p1 p2)]
(vec2/+ p1 (vec2/dir angle len))))
@shspage
shspage / loadFile.jsx
Created October 20, 2020 12:05
Adobe Illustrator: loading a file example
// refer to "JavaScript Tools Guide" for more information about File object.
// https://www.adobe.com/content/dam/acom/en/devnet/scripting/estk/javascript_tools_guide.pdf
function loadFile(){
var data;
try{
var f = File.openDialog("select input file");
if(f == null) return;
if(!f.open("r")){
@shspage
shspage / uzumaki.py
Last active November 10, 2020 22:51
カーブ生成 + 渦巻き (blender 2.82a)
import bpy
import math
# カーブ生成 + 渦巻き (blender 2.82a)
# (渦巻きは曲線上の点をプロットしたもので、NURBSのポイントとして適切かは考慮していません。)
def createPolyline(coords, obj_name, closed=False):
# ref: https://blender.stackexchange.com/questions/120074/how-to-make-a-curve-path-from-scratch-given-a-list-of-x-y-z-points
cv = bpy.data.curves.new('cv', 'CURVE')
cv.dimensions = '3D'
@shspage
shspage / 1_simple_delaunay_refinement_for_blender.py
Last active May 27, 2020 10:43
以前書いたドロネー分割簡易最適化のblender版 (blender 2.82a)
import bpy
import mathutils
import numpy as np
import math
NUM_POINTS = 300 # 点の数
MAX_ITERATION = 100 # 最適化試行回数上限
MAX_ERROR_SQUARED = 1e-4 # 前回の最適化との最大誤差(の2乗)
RADIUS = 5 # 半径
@shspage
shspage / blender_simple_anim1.py
Created May 20, 2020 10:57
blenderで形状をアニメーションさせる簡単な例。Run Script してからTimelineで再生 (blender 2.82a)
import bpy
from mathutils import Vector, Matrix
import math
class MyScene:
_freq = 3
_cube_count = 20
_scale = 0.1
_radius = 2
_rotation_x = math.radians(4)
@shspage
shspage / 1_example_mxi_file_for_hybrid_zxp.md
Last active September 15, 2022 01:01
Illustrator用ハイブリッドzxpのmxiファイル

インストールに成功したIllustrator用ハイブリッドzxpのmxiファイル。
ディレクトリ構造はこんなだ。comboMoverUI.zxpはHTMLエクステンション部分単体で作成したzxp。

  • comboMover
    • comboMoverUI.mxi
    • comboMoverUI.zxp
    • mac
      • comboMover.aip
    • win64
  • comboMover.aip
@shspage
shspage / 1_MyToolPlugin_with_sdk.cpp
Last active January 16, 2020 12:06
[Illustrator SDK] シフト+クリックで何かする。 // もっと今時の簡単な書き方あるのかもしれないけど、とりあえず動作する → SDKの機能で簡単に書けた
// @peprintenpa さんに教えていただいた、SDKの機能を使う方法。
// ref: https://twitter.com/peprintenpa/status/1217626021630857216
AIErr MyTool::ToolMouseDown( AIToolMessage* message )
{
if(message->event->modifiers & aiEventModifiers_shiftKey){
sAIUser->MessageAlert(ai::UnicodeString("shift is down"));
}
// ...
}
@shspage
shspage / sort_by_position.jsx
Created August 9, 2019 11:04
Illustrator script。オブジェクトの位置によるソートのサンプル。
#target illustrator
// 選択オブジェクトを位置によってソートし、
// ソート順に連番の名前をつける。
// ソート方法は sortByPosition を参照
function main(){
var sels = app.activeDocument.selection;
if(sels){
@shspage
shspage / nhk_gogaku_LUC.py
Last active July 13, 2019 00:23
NHKゴガク ストリーミング 一括保存用 (レベルアップ中国語 )
#!/usr/bin/env python
# coding:utf-8
from __future__ import print_function
import sys
import os
import traceback
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from time import sleep, strftime