0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 07:50:43 -05:00

WIP: basic color support

This commit is contained in:
Alejandro Alonso 2024-10-03 08:00:32 +02:00
parent e84622061d
commit 1f8fe2dc4c
3 changed files with 25 additions and 19 deletions

View file

@ -116,11 +116,15 @@ pub unsafe extern "C" fn draw_rect(
top: i32,
right: i32,
bottom: i32,
r: u8,
g: u8,
b: u8,
) {
let state = unsafe { state.as_mut() }.expect("got an invalid state pointer");
let rect = Rect::new(left as f32, top as f32, right as f32, bottom as f32);
let color = Color::from_rgb(r, g, b);
render_rect(&mut state.surface, rect, Color::BLACK);
render_rect(&mut state.surface, rect, color);
state
.gpu_state
.context

View file

@ -7,6 +7,7 @@
(ns app.render-v2.rs
(:require
["./rs.js" :as render-v2]
[app.common.colors :as cc]
[app.config :as cf]
[beicon.v2.core :as rx]
[goog.object :as gobj]
@ -28,9 +29,10 @@
(scale gpu-state zoom zoom)
(translate gpu-state (- (:x vbox)) (- (:y vbox)))
(doseq [shape supported-shapes]
(let [sr (:selrect shape)]
(let [sr (:selrect shape)
[r g b] (cc/hex->rgb (-> shape :fills first :fill-color))]
;; (js/console.log (clj->js shape))
(draw-rect gpu-state (:x1 sr) (:y1 sr) (:x2 sr) (:y2 sr)))))))
(draw-rect gpu-state (:x1 sr) (:y1 sr) (:x2 sr) (:y2 sr) r g b))))))
(defn set-canvas
[canvas vbox zoom objects]

View file

@ -8563,7 +8563,7 @@ var wasmExports = createWasm();
var ___wasm_call_ctors = createExportWrapper('__wasm_call_ctors', 0);
var _init = Module['_init'] = createExportWrapper('init', 2);
var _resize_surface = Module['_resize_surface'] = createExportWrapper('resize_surface', 3);
var _draw_rect = Module['_draw_rect'] = createExportWrapper('draw_rect', 5);
var _draw_rect = Module['_draw_rect'] = createExportWrapper('draw_rect', 8);
var _translate = Module['_translate'] = createExportWrapper('translate', 3);
var _scale = Module['_scale'] = createExportWrapper('scale', 3);
var _reset_canvas = Module['_reset_canvas'] = createExportWrapper('reset_canvas', 1);
@ -8612,10 +8612,10 @@ var dynCall_iiiiij = Module['dynCall_iiiiij'] = createExportWrapper('dynCall_iii
var dynCall_iiiiijj = Module['dynCall_iiiiijj'] = createExportWrapper('dynCall_iiiiijj', 9);
var dynCall_iiiiiijj = Module['dynCall_iiiiiijj'] = createExportWrapper('dynCall_iiiiiijj', 10);
function invoke_iii(index,a1,a2) {
function invoke_vii(index,a1,a2) {
var sp = stackSave();
try {
return getWasmTableEntry(index)(a1,a2);
getWasmTableEntry(index)(a1,a2);
} catch(e) {
stackRestore(sp);
if (!(e instanceof EmscriptenEH)) throw e;
@ -8634,17 +8634,6 @@ function invoke_ii(index,a1) {
}
}
function invoke_vii(index,a1,a2) {
var sp = stackSave();
try {
getWasmTableEntry(index)(a1,a2);
} catch(e) {
stackRestore(sp);
if (!(e instanceof EmscriptenEH)) throw e;
_setThrew(1, 0);
}
}
function invoke_viii(index,a1,a2,a3) {
var sp = stackSave();
try {
@ -8667,10 +8656,10 @@ function invoke_vi(index,a1) {
}
}
function invoke_iiii(index,a1,a2,a3) {
function invoke_iii(index,a1,a2) {
var sp = stackSave();
try {
return getWasmTableEntry(index)(a1,a2,a3);
return getWasmTableEntry(index)(a1,a2);
} catch(e) {
stackRestore(sp);
if (!(e instanceof EmscriptenEH)) throw e;
@ -8700,6 +8689,17 @@ function invoke_iiiiiii(index,a1,a2,a3,a4,a5,a6) {
}
}
function invoke_iiii(index,a1,a2,a3) {
var sp = stackSave();
try {
return getWasmTableEntry(index)(a1,a2,a3);
} catch(e) {
stackRestore(sp);
if (!(e instanceof EmscriptenEH)) throw e;
_setThrew(1, 0);
}
}
function invoke_iiiii(index,a1,a2,a3,a4) {
var sp = stackSave();
try {