Skip to content

Commit

Permalink
off-by-one fix in stroke length;loading old mlt - invert view center
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-rgb committed May 17, 2017
1 parent 135ae5a commit ed00c2b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ milton_imgui_tick(MiltonInput* input, PlatformState* platform_state, MiltonStat
milton_state->flags |= MiltonStateFlags_IGNORE_NEXT_CLICKUP;
}
// History
if ( ImGui::MenuItem("History") ) {
input->mode_to_set = MiltonMode_HISTORY;
}
// if ( ImGui::MenuItem("History") ) {
// input->mode_to_set = MiltonMode_HISTORY;
// }
ImGui::EndMenu();
}
if ( ImGui::BeginMenu(LOC(view)) ) {
Expand Down
4 changes: 2 additions & 2 deletions src/hardware_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1556,8 +1556,7 @@ gpu_render(RenderData* render_data, i32 view_x, i32 view_y, i32 view_width, i32
}

void
gpu_render_to_buffer(MiltonState* milton_state, u8* buffer, i32 scale, i32 x, i32 y,
i32 w, i32 h, f32 background_alpha)
gpu_render_to_buffer(MiltonState* milton_state, u8* buffer, i32 scale, i32 x, i32 y, i32 w, i32 h, f32 background_alpha)
{
CanvasView saved_view = *milton_state->view;
RenderData* render_data = milton_state->render_data;
Expand Down Expand Up @@ -1600,6 +1599,7 @@ gpu_render_to_buffer(MiltonState* milton_state, u8* buffer, i32 scale, i32 x, i3
gpu_clip_strokes_and_update(&milton_state->root_arena, render_data, milton_state->view, milton_state->canvas->root_layer,
&milton_state->working_stroke, 0, 0, buf_w, buf_h);

render_data->flags |= RenderDataFlags_WITH_BLUR;
gpu_render_canvas(render_data, 0, 0, buf_w, buf_h, background_alpha);


Expand Down
2 changes: 1 addition & 1 deletion src/milton.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ milton_stroke_input(MiltonState* milton_state, MiltonInput* input)
}

// Cleared to be appended.
if ( passed_inspection && ws->num_points < STROKE_MAX_POINTS ) {
if ( passed_inspection && ws->num_points < (STROKE_MAX_POINTS-1) ) {
if ( milton_brush_smoothing_enabled(milton_state) ) {
// Stroke smoothing.
// Change canvas_point depending on the average of the last `N` points.
Expand Down
6 changes: 2 additions & 4 deletions src/persist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ milton_load(MiltonState* milton_state)
milton_reset_canvas(milton_state);

CanvasState* canvas = milton_state->canvas;
#define READ(address, size, num, fd) do { ok = fread_checked(address,size,num,fd); if (!ok){goto END;} } while(0)
#define READ(address, size, num, fd) do { ok = fread_checked(address,size,num,fd); if (!ok){ goto END; } } while(0)

// Unload gpu data if the strokes have been cooked.
gpu_free_strokes(milton_state->render_data, milton_state->canvas);
Expand All @@ -110,7 +110,6 @@ milton_load(MiltonState* milton_state)

if ( fd ) {
u32 milton_binary_version = (u32)-1;

u32 milton_magic = (u32)-1;
READ(&milton_magic, sizeof(u32), 1, fd);
READ(&milton_binary_version, sizeof(u32), 1, fd);
Expand Down Expand Up @@ -147,7 +146,7 @@ milton_load(MiltonState* milton_state)
milton_state->view->screen_size = legacy_view.screen_size;
milton_state->view->scale = legacy_view.scale;
milton_state->view->zoom_center = legacy_view.zoom_center;
milton_state->view->pan_center = VEC2L(legacy_view.pan_center);
milton_state->view->pan_center = VEC2L(legacy_view.pan_center * -1);
milton_state->view->background_color = legacy_view.background_color;
milton_state->view->working_layer_id = legacy_view.working_layer_id;
milton_state->view->num_layers = legacy_view.num_layers;
Expand Down Expand Up @@ -201,7 +200,6 @@ milton_load(MiltonState* milton_state)
READ(&stroke.brush, sizeof(Brush), 1, fd);
READ(&stroke.num_points, sizeof(i32), 1, fd);


if ( stroke.num_points >= STROKE_MAX_POINTS || stroke.num_points <= 0 ) {
milton_log("ERROR: File has a stroke with %d points\n",
stroke.num_points);
Expand Down

0 comments on commit ed00c2b

Please sign in to comment.