Skip to content

Instantly share code, notes, and snippets.

@yoya
yoya / CMYKrectangle.sh
Last active June 21, 2022 11:18
CMYK rectangle by ImageMagick
convert -size 1024x1024 -background transparent xc: -compose darken \
\( xc: -draw "fill Cyan rectangle 100,100,600,650" \) -composite \
\( xc: -draw "fill Magenta rectangle 200,400,750,900" \) -composite \
\( xc: -draw "fill Yellow rectangle 350,250,1000,650" \) -composite \
-font KaiseiDecol-Regular.ttf +gravity -pointsize 256 -fill black -stroke black -strokewidth 18 \
-draw "rotate 15 text 190,270 C" \
-draw "rotate 0 text 350,870 M" \
-draw "rotate -10 text 700,650 Y" \
-draw "rotate 0 fill white stroke white text 390,620 K" \
CMYK.png ;
@yoya
yoya / RGBcircle.sh
Last active June 21, 2022 14:41
RGB circle by ImageMagick
convert -size 1024x1024 -background transparent xc: -compose lighten \
\( xc: -draw "fill red circle 512,350,512,650" \) -composite \
\( xc: -draw "fill green2 circle 324,650,324,950" \) -composite \
\( xc: -draw "fill blue1 circle 676,650,676,950" \) -composite \
-font KaiseiDecol-Regular.ttf +gravity -pointsize 256 -fill black -stroke black -strokewidth 18 \
-draw "text 420,320 R" \
-draw "rotate -10 text -20,850 G" \
-draw "fill white stroke white rotate 25 text 940,410 B" \
RGB.png ;
@yoya
yoya / dropcanvas.html
Last active June 6, 2022 13:20
file drop & canvas draw with petite-vue
<head>
<meta charset="utf-8">
<meta name="copyright" content="Copyright &copy; 2022/06/06- [email protected] . All Rights Reserved.">
<style>
.drop_area { min-width:300px; min-height:300px; border:thick solid red; }
.drop_area:hover { background-color:#FF000040; }
</style>
</head>
<body>
<div v-scope="App()" @vue:mounted="mounted">
@yoya
yoya / convolveRepeatedEdge.py
Last active January 30, 2022 14:40
convolve repeated edge
import math
import numpy as np
def convolveRepeatedEdge(arr, kernel):
arrLen = len(arr)
kernelLen = len(kernel)
kernelLen_harf = math.floor((kernelLen - 1) / 2)
if type(arr) is list:
arr2 = [0] * arrLen
else:
@yoya
yoya / typedarray_concat.js
Last active October 14, 2021 03:28
typedarray concat polyfill
(function() {
for (typedarr of [Int8Array, Uint8Array, Uint8ClampedArray,
Int16Array, Uint16Array, Int32Array, Uint32Array,
Float32Array, Float64Array]) {
if (!typedarr.prototype.concat) {
Object.defineProperty(typedarr.prototype, 'concat', {
value: function(b) {
const a = this;
if (!b || !b.length) return a.slice(0);
const c = new a.constructor(a.length + b.length);
@yoya
yoya / fast_float_testbed_macos.c
Created August 24, 2020 05:54
lcms2 の plugins/fast_float/fast_float_testbed.c から macOS で failed する要素を抜いたもの
//---------------------------------------------------------------------------------
//
// Little Color Management System, fast floating point extensions
// Copyright (c) 1998-2020 Marti Maria Saguer, all rights reserved
//
//
// 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 3 of the License, or
// (at your option) any later version.
function A = DCC(I,k,T)
% This function implements the image interpolation algorithm
% based on the directional cubic convolution interpolation which
% has been described in the paper:
% D. Zhou, X. Shen, and W. Dong,
% Image zooming using directional cubic convolution interpolation,
% IET Image Processing, Vol. 6, No. 6, pp. 627-634, 2012.
%
% I(:,:) inputted low resolution gray image, range 0~1
@yoya
yoya / 8x1colors.ppm
Created November 13, 2019 06:39
8x1colors.ppm (testimage)
P3
8 1
255
#------ --------- --------- ---------- ---------- --------- --------- ---------
255 0 0 0 0 0 0 0 0 0 0 255 0 0 255 0 0 0 0 0 0 0 255 0
@yoya
yoya / 8x8colors.ppm
Created November 6, 2019 07:17
8x8colors.ppm (testimage)
P3
8 8
255
#------ --------- --------- ---------- ---------- --------- --------- ---------
255 0 0 0 0 0 0 0 0 0 0 255 0 0 255 0 0 0 0 0 0 0 255 0
0 0 0 255 0 0 0 0 0 0 0 255 0 0 255 0 0 0 0 255 0 0 0 0
0 0 0 0 0 0 100 0 0 0 0 255 0 0 255 0 100 0 0 0 0 0 0 0
0 0 255 0 0 255 0 0 255 100 0 100 0 100 100 0 0 255 0 0 255 0 0 255
0 0 255 0 0 255 0 0 255 0 100 100 100 0 100 0 0 255 0 0 255 0 0 255
0 0 0 0 0 0 0 100 0 0 0 255 0 0 255 100 0 0 0 0 0 0 0 0
@yoya
yoya / rms.js
Created October 7, 2019 15:26
Root Mean Square
// https://mathtrain.jp/leastsquares
// https://mathtrain.jp/covariance
function rms(xArr, yArr) {
var count = xArr.length;
if (count !== yArr.length) {
return false;
}
var xMean = xArr.reduce(function(a, b) { return a + b; }) / count;
var yMean = yArr.reduce(function(a, b) { return a + b; }) / count;