render picture : ratio and resizing to board
This commit is contained in:
@ -15,9 +15,9 @@
|
||||
create1dInitialState,
|
||||
create2dRandomGrid,
|
||||
} from "../modules/board.js";
|
||||
import { picToBoard } from "../modules/picture.js";
|
||||
|
||||
const store = globalStore();
|
||||
|
||||
const available2dRules = {
|
||||
conway: conwayRules,
|
||||
overpopulation: overpopulationRules,
|
||||
@ -149,12 +149,20 @@
|
||||
|
||||
// draw 2d automaton from an uploaded picture.
|
||||
// use the picture representation as an initial state
|
||||
const draw2dPicture = () => {
|
||||
store.renderer.renderImage(store.picture);
|
||||
const newBoard = store.renderer.getResizedImageData(
|
||||
const draw2dPicture = async () => {
|
||||
store.renderer.renderImage(
|
||||
store.picture,
|
||||
store.board
|
||||
store.renderer.ctx,
|
||||
store.renderer.width,
|
||||
store.renderer.height
|
||||
);
|
||||
const resized = store.renderer.renderImage(
|
||||
store.picture,
|
||||
store.renderer.workCtx,
|
||||
store.board.width,
|
||||
store.board.height
|
||||
);
|
||||
const newBoard = picToBoard(resized.data, store.board);
|
||||
store.board.grid = Object.freeze(newBoard);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user