Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1import { line, solidFillPolygon, patternFillPolygons, rectangle, ellipseWithParams, generateEllipseParams, linearPath, arc, patternFillArc, curve, svgPath } from './renderer.js';2import { randomSeed } from './math.js';3import { curveToBezier } from 'points-on-curve/lib/curve-to-bezier.js';4import { pointsOnBezierCurves } from 'points-on-curve';5import { pointsOnPath } from 'points-on-path';6const NOS = 'none';7export class RoughGenerator {8 constructor(config) {9 this.defaultOptions = {10 maxRandomnessOffset: 2,11 roughness: 1,12 bowing: 1,13 stroke: '#000',14 strokeWidth: 1,15 curveTightness: 0,16 curveFitting: 0.95,17 curveStepCount: 9,18 fillStyle: 'hachure',19 fillWeight: -1,20 hachureAngle: -41,21 hachureGap: -1,22 dashOffset: -1,23 dashGap: -1,24 zigzagOffset: -1,25 seed: 0,26 disableMultiStroke: false,27 disableMultiStrokeFill: false,28 preserveVertices: false,29 fillShapeRoughnessGain: 0.8,30 };31 this.config = config || {};32 if (this.config.options) {33 this.defaultOptions = this._o(this.config.options);34 }35 }36 static newSeed() {37 return randomSeed();38 }39 _o(options) {40 return options ? Object.assign({}, this.defaultOptions, options) : this.defaultOptions;41 }42 _d(shape, sets, options) {43 return { shape, sets: sets || [], options: options || this.defaultOptions };44 }45 line(x1, y1, x2, y2, options) {46 const o = this._o(options);47 return this._d('line', [line(x1, y1, x2, y2, o)], o);48 }49 rectangle(x, y, width, height, options) {50 const o = this._o(options);51 const paths = [];52 const outline = rectangle(x, y, width, height, o);53 if (o.fill) {54 const points = [[x, y], [x + width, y], [x + width, y + height], [x, y + height]];55 if (o.fillStyle === 'solid') {56 paths.push(solidFillPolygon([points], o));57 }58 else {59 paths.push(patternFillPolygons([points], o));60 }61 }62 if (o.stroke !== NOS) {63 paths.push(outline);64 }65 return this._d('rectangle', paths, o);66 }67 ellipse(x, y, width, height, options) {68 const o = this._o(options);69 const paths = [];70 const ellipseParams = generateEllipseParams(width, height, o);71 const ellipseResponse = ellipseWithParams(x, y, o, ellipseParams);72 if (o.fill) {73 if (o.fillStyle === 'solid') {74 const shape = ellipseWithParams(x, y, o, ellipseParams).opset;75 shape.type = 'fillPath';76 paths.push(shape);77 }78 else {79 paths.push(patternFillPolygons([ellipseResponse.estimatedPoints], o));80 }81 }82 if (o.stroke !== NOS) {83 paths.push(ellipseResponse.opset);84 }85 return this._d('ellipse', paths, o);86 }87 circle(x, y, diameter, options) {88 const ret = this.ellipse(x, y, diameter, diameter, options);89 ret.shape = 'circle';90 return ret;91 }92 linearPath(points, options) {93 const o = this._o(options);94 return this._d('linearPath', [linearPath(points, false, o)], o);95 }96 arc(x, y, width, height, start, stop, closed = false, options) {97 const o = this._o(options);98 const paths = [];99 const outline = arc(x, y, width, height, start, stop, closed, true, o);100 if (closed && o.fill) {101 if (o.fillStyle === 'solid') {102 const fillOptions = Object.assign({}, o);103 fillOptions.disableMultiStroke = true;104 const shape = arc(x, y, width, height, start, stop, true, false, fillOptions);105 shape.type = 'fillPath';106 paths.push(shape);107 }108 else {109 paths.push(patternFillArc(x, y, width, height, start, stop, o));110 }111 }112 if (o.stroke !== NOS) {113 paths.push(outline);114 }115 return this._d('arc', paths, o);116 }117 curve(points, options) {118 const o = this._o(options);119 const paths = [];120 const outline = curve(points, o);121 if (o.fill && o.fill !== NOS) {122 if (o.fillStyle === 'solid') {123 const fillShape = curve(points, Object.assign(Object.assign({}, o), { disableMultiStroke: true, roughness: o.roughness ? (o.roughness + o.fillShapeRoughnessGain) : 0 }));124 paths.push({125 type: 'fillPath',126 ops: this._mergedShape(fillShape.ops),127 });128 }129 else {130 const polyPoints = [];131 const inputPoints = points;132 if (inputPoints.length) {133 const p1 = inputPoints[0];134 const pointsList = (typeof p1[0] === 'number') ? [inputPoints] : inputPoints;135 for (const points of pointsList) {136 if (points.length < 3) {137 polyPoints.push(...points);138 }139 else if (points.length === 3) {140 polyPoints.push(...pointsOnBezierCurves(curveToBezier([141 points[0],142 points[0],143 points[1],144 points[2],145 ]), 10, (1 + o.roughness) / 2));146 }147 else {148 polyPoints.push(...pointsOnBezierCurves(curveToBezier(points), 10, (1 + o.roughness) / 2));149 }150 }151 }152 if (polyPoints.length) {153 paths.push(patternFillPolygons([polyPoints], o));154 }155 }156 }157 if (o.stroke !== NOS) {158 paths.push(outline);159 }160 return this._d('curve', paths, o);161 }162 polygon(points, options) {163 const o = this._o(options);164 const paths = [];165 const outline = linearPath(points, true, o);166 if (o.fill) {167 if (o.fillStyle === 'solid') {168 paths.push(solidFillPolygon([points], o));169 }170 else {171 paths.push(patternFillPolygons([points], o));172 }173 }174 if (o.stroke !== NOS) {175 paths.push(outline);176 }177 return this._d('polygon', paths, o);178 }179 path(d, options) {180 const o = this._o(options);181 const paths = [];182 if (!d) {183 return this._d('path', paths, o);184 }185 d = (d || '').replace(/\n/g, ' ').replace(/(-\s)/g, '-').replace('/(\s\s)/g', ' ');186 const hasFill = o.fill && o.fill !== 'transparent' && o.fill !== NOS;187 const hasStroke = o.stroke !== NOS;188 const simplified = !!(o.simplification && (o.simplification < 1));189 const distance = simplified ? (4 - 4 * (o.simplification || 1)) : ((1 + o.roughness) / 2);190 const sets = pointsOnPath(d, 1, distance);191 const shape = svgPath(d, o);192 if (hasFill) {193 if (o.fillStyle === 'solid') {194 if (sets.length === 1) {195 const fillShape = svgPath(d, Object.assign(Object.assign({}, o), { disableMultiStroke: true, roughness: o.roughness ? (o.roughness + o.fillShapeRoughnessGain) : 0 }));196 paths.push({197 type: 'fillPath',198 ops: this._mergedShape(fillShape.ops),199 });200 }201 else {202 paths.push(solidFillPolygon(sets, o));203 }204 }205 else {206 paths.push(patternFillPolygons(sets, o));207 }208 }209 if (hasStroke) {210 if (simplified) {211 sets.forEach((set) => {212 paths.push(linearPath(set, false, o));213 });214 }215 else {216 paths.push(shape);217 }218 }219 return this._d('path', paths, o);220 }221 opsToPath(drawing, fixedDecimals) {222 let path = '';223 for (const item of drawing.ops) {224 const data = ((typeof fixedDecimals === 'number') && fixedDecimals >= 0) ? (item.data.map((d) => +d.toFixed(fixedDecimals))) : item.data;225 switch (item.op) {226 case 'move':227 path += `M${data[0]} ${data[1]} `;228 break;229 case 'bcurveTo':230 path += `C${data[0]} ${data[1]}, ${data[2]} ${data[3]}, ${data[4]} ${data[5]} `;231 break;232 case 'lineTo':233 path += `L${data[0]} ${data[1]} `;234 break;235 }236 }237 return path.trim();238 }239 toPaths(drawable) {240 const sets = drawable.sets || [];241 const o = drawable.options || this.defaultOptions;242 const paths = [];243 for (const drawing of sets) {244 let path = null;245 switch (drawing.type) {246 case 'path':247 path = {248 d: this.opsToPath(drawing),249 stroke: o.stroke,250 strokeWidth: o.strokeWidth,251 fill: NOS,252 };253 break;254 case 'fillPath':255 path = {256 d: this.opsToPath(drawing),257 stroke: NOS,258 strokeWidth: 0,259 fill: o.fill || NOS,260 };261 break;262 case 'fillSketch':263 path = this.fillSketch(drawing, o);264 break;265 }266 if (path) {267 paths.push(path);268 }269 }270 return paths;271 }272 fillSketch(drawing, o) {273 let fweight = o.fillWeight;274 if (fweight < 0) {275 fweight = o.strokeWidth / 2;276 }277 return {278 d: this.opsToPath(drawing),279 stroke: o.fill || NOS,280 strokeWidth: fweight,281 fill: NOS,282 };283 }284 _mergedShape(input) {285 return input.filter((d, i) => {286 if (i === 0) {287 return true;288 }289 if (d.op === 'move') {290 return false;291 }292 return true;293 });294 }295}296 