Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

pygcodeでgcodeを生成 その1:環境構築

実際のところ

導入

$ pip3 install pygcode

スクリプト

from pygcode import *
gcodes = [
     GCodeRapidMove(Z=5),
     GCodeStartSpindleCW(),
     GCodeRapidMove(X=10, Y=20),
     GCodeFeedRate(200),
     GCodeLinearMove(Z=-1.5),
     GCodeRapidMove(Z=5),
     GCodeStopSpindle(),
 ]

print('\n'.join(str(g) for g in gcodes))
G00 Z5
M03
G00 X10 Y20
F200
G01 Z-1.5
G00 Z5
M05

参考もと

github.com

Node-RedでSVGを描画する その7:CSSを反映する

実際のところ

<svg x="0" y="0" height="300" viewBox="0 0 100 100" width="300" 
     xmlns="http://www.w3.org/2000/svg" 
     xmlns:svg="http://www.w3.org/2000/svg" 
     xmlns:xlink="http://www.w3.org/1999/xlink">
  <image x="0" y="0"  width="100" height="100" href="data:image/png;base64,iVBORw0KGgoAAA..." />
  <rect x="0"  y="0"  width="50"  height="50" class="rect rectBlue" />
  <rect x="50" y="0"  width="50"  height="50" class="rect rectPink" />
  <rect x="0"  y="50" width="50"  height="50" class="rect rectGreen" />
  <rect x="50" y="50" width="50"  height="50" class="rect rectYellow" />
</svg>

この状態でCSSタブ

div.ui-svg svg{
    color: var(--nr-dashboard-widgetColor);
    fill: currentColor !important;
}
div.ui-svg path {
    fill: inherit;
}

.rect {
    stroke:black;
    stroke-width:1;
}

.rectBlue {
    fill:blue;
    fill-opacity:0.2;
}

.rectPink {
    fill:pink;
    fill-opacity:0.2;
}

.rectGreen {
    fill:green;
    fill-opacity:0.2;
}

.rectYellow {
    fill:yellow;
    fill-opacity:0.2;
}


Node-RedでSVGを描画する その6:HTMLタグを植え込む

shuzo-kino.hateblo.jp
の続き

実際のところ

<svg x="0" y="0" height="300" viewBox="0 0 100 100" width="300" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <!-- Add here your SVG shapes (circles, rectangles, ...) -->
  <image x="0" y="0" width="100" height="100" href=""data:image/png;base64,iVBORw0K..." />
  <circle cx="50" cy="50" r={{msg.payload}} fill="red" stroke="red" stroke-width="4px" />
  <foreignObject x="0" y="0" width="100" height="40">
    <input type="number" id="temp_living" min="10" max="25">
    <label for="temp_living" id="temp_living_label">°C</label>
  </foreignObject>
</svg>